From 90696365ddfd5c6cdcfebaa8741474b0f8ba0719 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Mon, 8 Jul 2024 05:09:51 +0200 Subject: [PATCH] small fix --- .../net/t2code/commandguiv2/Spigot/Main.java | 1 - .../Spigot/cmdManagement/Commands.java | 28 +++++++++++++------ .../commandguiv2/Spigot/gui/OpenGUI.java | 8 ++++++ .../java/net/t2code/commandguiv2/Util.java | 6 +--- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/Main.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/Main.java index 11209bb..e55a2ea 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/Main.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/Main.java @@ -54,7 +54,6 @@ public final class Main extends JavaPlugin { autor = this.getDescription().getAuthors(); version = this.getDescription().getVersion(); if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; - Util.load(); if (T2C_McVersion.isMc1_8() || T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12() || T2C_McVersion.isMc1_13() || T2C_McVersion.isMc1_14() || T2C_McVersion.isMc1_15() || T2C_McVersion.isNms1_16_R1()) { legacy = true; diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Commands.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Commands.java index 866f762..3c44369 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Commands.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Commands.java @@ -174,18 +174,28 @@ public class Commands { } else T2C_Send.player(player, Languages.VALUES.NoPermissionForCommand.getValue().toString().replace("[cmd]", "/commandgui") .replace("[perm]", "commandgui.command")); } else T2C_Send.player(player, Languages.VALUES.GUIIsDisabled.getValue().toString().replace("[gui]", gui.guiName)); + } else { + T2C_Send.player(player, Languages.VALUES.guiNotFound.getValue().toString()); + T2C_Send.error(Main.getPlugin(), ""); + T2C_Send.console(Util.getPrefix()+ " The gui [gui] that the player [player] wanted to open does not exist!".replace("[gui]", Config.VALUES.defaultGUI.getValue().toString()).replace("[player]", player.getName())); //todo in lang + T2C_Send.error(Main.getPlugin(), ""); } } public static void gui(Player player, String arg) { - if (Main.guiHashMap.containsKey(arg)) { - Gui gui = Main.guiHashMap.get(arg); - if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { - if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, arg, true); - } else T2C_Send.player(player, Languages.VALUES.NoPermissionForCommand.getValue().toString().replace("[cmd]", "/commandgui " + gui.key) - .replace("[perm]", "commandgui.command." + arg.toLowerCase())); - } else T2C_Send.player(player, Languages.VALUES.GUIIsDisabled.getValue().toString().replace("[gui]", gui.key)); - } else T2C_Send.player(player, Languages.VALUES.guiNotFound); + Gui gui = Main.guiHashMap.get(arg); + if (gui == null) { + T2C_Send.player(player, Languages.VALUES.guiNotFound.getValue().toString()); + T2C_Send.error(Main.getPlugin(), ""); + T2C_Send.console(Util.getPrefix()+ " The gui [gui] that the player [player] wanted to open does not exist!".replace("[gui]", arg).replace("[player]", player.getName())); //todo in lang + T2C_Send.error(Main.getPlugin(), ""); + return; + } + if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { + if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) { + OpenGUI.openGUI(player, arg, true); + } else T2C_Send.player(player, Languages.VALUES.NoPermissionForCommand.getValue().toString().replace("[cmd]", "/commandgui " + gui.key) + .replace("[perm]", "commandgui.command." + arg.toLowerCase())); + } else T2C_Send.player(player, Languages.VALUES.GUIIsDisabled.getValue().toString().replace("[gui]", gui.key)); } } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/gui/OpenGUI.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/gui/OpenGUI.java index 87c764b..9af9cdc 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/gui/OpenGUI.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/gui/OpenGUI.java @@ -30,7 +30,15 @@ public class OpenGUI { private static final String prefix = Util.getPrefix(); public static void openGUI(Player player, String guiString, Boolean sound) { + if (!Main.guiHashMap.containsKey(guiString)) { + T2C_Send.player(player, Languages.VALUES.guiNotFound.getValue().toString()); + T2C_Send.error(Main.getPlugin(), ""); + T2C_Send.console(Util.getPrefix() + " The gui [gui] that the player [player] wanted to open does not exist!".replace("[gui]", guiString).replace("[player]", player.getName())); + T2C_Send.error(Main.getPlugin(), ""); + return; + } Gui gui = Main.guiHashMap.get(guiString); + long long_ = System.currentTimeMillis(); switch (guiString) { //case "plugin.PlotSquaredGUI": diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Util.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Util.java index bbdfefd..3ab6176 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Util.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Util.java @@ -34,7 +34,7 @@ public class Util { private static final String spigot = "https://www.spigotmc.org/resources/" + getSpigotID(); @Getter - private static String discord; + private static final String discord = "http://dc.t2code.net"; public static String[] getConfigLogo() { ArrayList arrayList = new ArrayList<>(T2C_Util.getConfigT2CodeLogo()); @@ -42,10 +42,6 @@ public class Util { return arrayList.toArray(new String[0]); } - public static void load() { - discord = T2C_Util.getDiscord(); - } - public static void replace(T2C_ConfigItem item) { if (item.getValue() instanceof List) { item.setValue(T2C_Replace.replace(Config.VALUES.prefix.getValue().toString(), (List) item.getValue()));