From 2abdcdd3ad5569c998df7cd581c169e0ec6c6bf2 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Wed, 4 Jan 2023 05:58:48 +0100 Subject: [PATCH] big changes --- .../net/t2code/commandguiv2/Spigot/Main.java | 5 - .../Spigot/cmdManagement/CmdExecuter_GUI.java | 6 +- .../cmdManagement/CmdExecuter_GUIItem.java | 41 +++- .../Spigot/cmdManagement/Commands.java | 45 ++-- .../Spigot/cmdManagement/Help.java | 13 +- .../cmdManagement/register/AliasRegister.java | 9 +- .../register/RegisterCommand.java | 3 +- .../Spigot/config/config/ConfigSelect.java | 6 +- .../config/{Config.java => ConfigValues.java} | 6 +- .../configConverter/ConfigConverterV5.java | 4 +- .../configConverter/ConfigConverterV6.java | 156 ++++++------ .../config/functions/SelectFunctions.java | 5 +- .../Spigot/config/gui/SelectGui.java | 11 +- .../config/languages/SelectMessages.java | 8 +- .../Spigot/config/useItems/UseItemSelect.java | 74 ++++++ .../Spigot/config/useItems/UseItemValues.java | 69 ++++++ .../commandguiv2/Spigot/database/MySQL.java | 12 +- .../Spigot/database/SelectDatabase.java | 8 +- .../Spigot/function/gui/GUIListener.java | 17 +- .../Spigot/function/gui/GuiBuilder.java | 23 +- .../Spigot/function/gui/OpenGUI.java | 19 +- .../Spigot/function/useItem/Events.java | 80 +++--- .../function/useItem/EventsFrom110.java | 14 +- .../Spigot/function/useItem/ItemChange.java | 41 ++-- .../Spigot/function/useItem/UseItem.java | 62 ++--- .../Spigot/objects/player/PlayerObject.java | 11 + .../objects/player/UseItemPlayerObject.java | 13 + .../commandguiv2/Spigot/sound/PlaySound.java | 30 +-- .../commandguiv2/Spigot/system/Load.java | 14 +- .../Spigot/system/Permissions.java | 3 +- .../Spigot/system/Placeholder.java | 6 +- .../net/t2code/commandguiv2/api/CGuiAPI.java | 6 +- .../net/t2code/commandguiv2/cache/Cache.java | 17 ++ .../resources/UseItems/useItemDeclaration.yml | 231 ++++++------------ .../src/main/resources/configDeclaration.yml | 167 ++++--------- 35 files changed, 645 insertions(+), 590 deletions(-) rename CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/{Config.java => ConfigValues.java} (98%) create mode 100644 CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemSelect.java create mode 100644 CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemValues.java create mode 100644 CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/PlayerObject.java create mode 100644 CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/UseItemPlayerObject.java create mode 100644 CommandGUI V2/src/main/java/net/t2code/commandguiv2/cache/Cache.java 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 5e26d09..715ee2e 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 @@ -39,11 +39,6 @@ public final class Main extends JavaPlugin { public static Boolean LuckyBox = false; public static Boolean PlugManGUI = false; - public static HashMap guiHashMap = new HashMap<>(); - public static ArrayList allAliases = new ArrayList<>(); - - public static HashMap functionHashMap = new HashMap<>(); - @Override public void onEnable() { // Plugin startup logic diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java index 97cf3fa..b99ddda 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java @@ -1,7 +1,7 @@ package net.t2code.commandguiv2.Spigot.cmdManagement; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Util; @@ -30,7 +30,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter { Player player = (Player) sender; Commands.gui(player); } else { - if (args[0].equals(String.valueOf(Config.adminSubCommand.value))) { + if (args[0].equals(String.valueOf(ConfigValues.adminSubCommand.value))) { if (args.length == 1) { Help.sendHelp(sender, prefix); return false; @@ -105,7 +105,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter { List list = new ArrayList<>(); T2Ctab.tab(list, sender, 0, args, arg1); - T2Ctab.tab(list, sender, 0, String.valueOf(Config.adminSubCommand.value), 1, args, arg2); + T2Ctab.tab(list, sender, 0, String.valueOf(ConfigValues.adminSubCommand.value), 1, args, arg2); T2Ctab.tab(list, sender, 1, "give", 2, args, "commandgui.giveitem.other", true); return list; } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java index be22ddf..397e2e7 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java @@ -1,8 +1,9 @@ package net.t2code.commandguiv2.Spigot.cmdManagement; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -20,26 +21,44 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; + + + + + + + + if (sender.hasPermission("commandgui.useitem.toggle")) { if (args.length == 0) { - if ((Boolean) Config.useItemAllowToggle.value) { + if ((Boolean) ConfigValues.useItemAllowToggle.value) { Help.sendGUIItemHelp(sender); } else T2Csend.sender(sender, "§4UseItem toggle is disabled!");// todo } else { - if (args.length == 1 || args.length == 2) { + if (args.length == 2 || args.length == 3) { + String useItemKey= args[0]; + + if (!Cache.useItemHash.containsKey(useItemKey)){ + T2Csend.sender(sender,"das useitem " +useItemKey+" exestiert nicht"); + return false; + } + + + + if (sender instanceof Player) { - if ((Boolean) Config.useItemAllowToggle.value) { - switch (args[0].toLowerCase()) { + if ((Boolean) ConfigValues.useItemAllowToggle.value) { + switch (args[1].toLowerCase()) { case "on": - Commands.itemOn(player); + Commands.itemOn(player, useItemKey); break; case "off": - Commands.itemOff(player); + Commands.itemOff(player, useItemKey); break; case "slot": - if (args.length == 2) { + if (args.length == 3) { try { - Commands.onSetSlot(player, Integer.valueOf(args[1])); + Commands.onSetSlot(player, useItemKey, Integer.valueOf(args[2])); } catch (Exception e5) { T2Csend.player(player, SelectMessages.ItemSlot_wrongValue); } @@ -65,7 +84,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter { private static HashMap arg1 = new HashMap() {{ put("on", "commandgui.useitem.toggle"); put("off", "commandgui.useitem.toggle"); - if ((Boolean) Config.useItemAllowToggle.value) { + if ((Boolean) ConfigValues.useItemAllowToggle.value) { put("slot", "commandgui.useitem.toggle"); } }}; @@ -74,7 +93,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter { public List onTabComplete(CommandSender sender, Command cmd, String s, String[] args) { List list = new ArrayList<>(); if (sender instanceof Player) { - if ((Boolean) Config.useItemAllowToggle.value) { + if ((Boolean) ConfigValues.useItemAllowToggle.value) { Player p = (Player) sender; if (args.length == 1) { for (String command : arg1.keySet()) { 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 6ade349..ea7a472 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 @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.cmdManagement; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect; import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions; import net.t2code.commandguiv2.Spigot.config.gui.SelectGui; @@ -17,6 +17,7 @@ import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.sound.PlaySound; import net.t2code.commandguiv2.Spigot.enums.SoundEnum; import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; @@ -48,9 +49,9 @@ public class Commands { Main.getPlugin().reloadConfig(); CmdExecuter_GUI.arg1.clear(); - CmdExecuter_GUI.arg1.put(String.valueOf(Config.adminSubCommand.value), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); + CmdExecuter_GUI.arg1.put(String.valueOf(ConfigValues.adminSubCommand.value), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); - if (!Objects.equals(SelectDatabase.getStorage().toString(), Config.storage.value)) { + if (!Objects.equals(SelectDatabase.getStorage().toString(), ConfigValues.storage.value)) { if (sender instanceof Player) T2Csend.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!"); T2Csend.warning(Main.getPlugin(), "You have changed the storage medium! To apply this change, you must restart the server!"); } @@ -68,7 +69,7 @@ public class Commands { e.printStackTrace(); } SelectMessages.onSelect(Util.getPrefix()); - Config.sound(); + ConfigValues.sound(); try { AliasRegister.onRegister(); @@ -97,8 +98,8 @@ public class Commands { public static void give(CommandSender sender, Player target) { if (Bukkit.getPlayer(target.getName()) != null) { UseItem.giveUseItem(target); - T2Csend.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", String.valueOf(Config.useItemName.value))); - T2Csend.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", String.valueOf(Config.useItemName.value))); + T2Csend.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", String.valueOf(ConfigValues.useItemName.value))); + T2Csend.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", String.valueOf(ConfigValues.useItemName.value))); PlaySound.play(target, SoundEnum.Give); } else { sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName())); @@ -106,17 +107,17 @@ public class Commands { } } - public static void itemOn(Player player) { + public static void itemOn(Player player, String useItemKey) { UseItem.removeItem(player); Integer slot = null; - if ((Boolean) Config.useItemInventorySlotEnforce.value) { - slot = (Integer) Config.useItemInventorySlot.value; + if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) { + slot = (Integer) ConfigValues.useItemInventorySlot.value; } else { slot = Events.useItemSlotHashMap.get(player.getName()); } T2Csend.debug(Main.getPlugin(), String.valueOf(slot)); if (player.getInventory().getItem(slot - 1) == null) { - SelectDatabase.setItemStatus(player, true); + SelectDatabase.setItemStatus(player, useItemKey, true); UseItem.giveUseItem(player); } else { boolean empty = false; @@ -127,7 +128,7 @@ public class Commands { } } if (empty) { - SelectDatabase.setItemStatus(player, true); + SelectDatabase.setItemStatus(player, useItemKey, true); UseItem.addUseItem(player); T2Csend.player(player, SelectMessages.ItemON); } else { @@ -137,14 +138,14 @@ public class Commands { } } - public static void itemOff(Player player) { - SelectDatabase.setItemStatus(player, false); + public static void itemOff(Player player, String useItemKey) { + SelectDatabase.setItemStatus(player, useItemKey, false); UseItem.removeItem(player); T2Csend.player(player, SelectMessages.ItemOFF); } - public static void onSetSlot(Player player, Integer setSlot) { - if (!(Boolean) Config.useItemAllowSetSlot.value) { + public static void onSetSlot(Player player, String useItemKey, Integer setSlot) { + if (!(Boolean) ConfigValues.useItemAllowSetSlot.value) { T2Csend.player(player, Util.getPrefix() + " §4Function disabled"); return; } @@ -165,13 +166,13 @@ public class Commands { } } - if ((Boolean) Config.useItemInventorySlotEnforce.value || player.getInventory().getItem(setSlot - 1) != null) { + if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value || player.getInventory().getItem(setSlot - 1) != null) { T2Csend.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString())); return; } UseItem.removeItem(player); - SelectDatabase.setSlot(player, setSlot); + SelectDatabase.setSlot(player, useItemKey, setSlot); Events.useItemSlotHashMap.replace(player.getName(), setSlot); if (Events.useItemHashMap.get(player.getName())) { @@ -182,11 +183,11 @@ public class Commands { } public static void gui(Player player) { - if (Main.guiHashMap.containsKey(String.valueOf(Config.defaultGUI.value))) { - GuiObject gui = Main.guiHashMap.get(String.valueOf(Config.defaultGUI.value)); + if (Cache.guiHashMap.containsKey(String.valueOf(ConfigValues.defaultGUI.value))) { + GuiObject gui = Cache.guiHashMap.get(String.valueOf(ConfigValues.defaultGUI.value)); if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, String.valueOf(Config.defaultGUI.value), true); + OpenGUI.openGUI(player, String.valueOf(ConfigValues.defaultGUI.value), true); } else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui") .replace("[perm]", "commandgui.command")); } else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName)); @@ -194,8 +195,8 @@ public class Commands { } public static void gui(Player player, String arg) { - if (Main.guiHashMap.containsKey(arg)) { - GuiObject gui = Main.guiHashMap.get(arg); + if (Cache.guiHashMap.containsKey(arg)) { + GuiObject gui = Cache.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); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Help.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Help.java index b28a19d..4bd97ce 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Help.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/Help.java @@ -1,10 +1,11 @@ package net.t2code.commandguiv2.Spigot.cmdManagement; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.objects.GuiObject; import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.command.CommandSender; @@ -14,7 +15,7 @@ public class Help { private static String prefix = Util.getPrefix(); public static void sendHelp(CommandSender sender, String Prefix) { - GuiObject gui = Main.guiHashMap.get(String.valueOf(Config.defaultGUI.value)); + GuiObject gui = Cache.guiHashMap.get(String.valueOf(ConfigValues.defaultGUI.value)); T2Csend.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----"); cgui(sender, gui); @@ -40,12 +41,12 @@ public class Help { private static void open(CommandSender sender) { if (!sender.hasPermission("commandgui.command")) return; - for (String alias : Main.allAliases) { - if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) { + for (String alias : Cache.allAliases) { + if (Cache.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) { if (sender instanceof Player) { - T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Main.guiHashMap.get(alias).guiName))); + T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Cache.guiHashMap.get(alias).guiName))); } else - T2Csend.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Main.guiHashMap.get(alias).guiName))); + T2Csend.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Cache.guiHashMap.get(alias).guiName))); } } } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java index 5ec5b06..c3d4cc9 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java @@ -2,6 +2,7 @@ package net.t2code.commandguiv2.Spigot.cmdManagement.register; import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.Bukkit; import org.bukkit.command.CommandMap; @@ -14,13 +15,13 @@ public class AliasRegister { public static void onRegister() { Plugin plugin = Main.getPlugin(); T2Csend.debug(plugin, Bukkit.getServer().getClass().getPackage().getName()); - if (Main.allAliases.toString().equals("[]")) { + if (Cache.allAliases.toString().equals("[]")) { T2Csend.console(Util.getPrefix() + " §4No GUI files available"); return; } - for (String alias : Main.allAliases) { - if (Main.guiHashMap.get(alias) != null) { - if (Main.guiHashMap.get(alias).commandAliasEnable) { + for (String alias : Cache.allAliases) { + if (Cache.guiHashMap.get(alias) != null) { + if (Cache.guiHashMap.get(alias).commandAliasEnable) { try { final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); bukkitCommandMap.setAccessible(true); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java index 5473bb2..4680701 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java @@ -5,6 +5,7 @@ import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.objects.GuiObject; import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -23,7 +24,7 @@ public class RegisterCommand extends Command { if (sender instanceof Player) { Player player = (Player) sender; - GuiObject gui = Main.guiHashMap.get(alias); + GuiObject gui = Cache.guiHashMap.get(alias); if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, alias, true); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigSelect.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigSelect.java index 7638363..00d9ff5 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigSelect.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigSelect.java @@ -18,7 +18,7 @@ public class ConfigSelect { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); if (yamlConfiguration.contains("ConfigVersion")) { - if (yamlConfiguration.getInt("ConfigVersion") < (Integer) Config.configVersion.value && new File(Main.getPath(), "config.yml").exists()) { + if (yamlConfiguration.getInt("ConfigVersion") < (Integer) ConfigValues.configVersion.value && new File(Main.getPath(), "config.yml").exists()) { T2Csend.console(Util.getPrefix() + " §4----------------------"); T2Csend.console(Util.getPrefix() + " "); T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!"); @@ -37,8 +37,8 @@ public class ConfigSelect { } } - yamlConfiguration.set(Config.configVersion.path, Config.configVersion.value); - for (Config value : Config.values()) { + yamlConfiguration.set(ConfigValues.configVersion.path, ConfigValues.configVersion.value); + for (ConfigValues value : ConfigValues.values()) { T2Cconfig.set(value.path, value.value, yamlConfiguration); value.value = T2Cconfig.selectObject(Util.getPrefix(), value.path, yamlConfiguration); } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/Config.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigValues.java similarity index 98% rename from CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/Config.java rename to CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigValues.java index 0ca1a68..f35e506 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/Config.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigValues.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -public enum Config { +public enum ConfigValues { configVersion("configVersion", 6), debug("plugins.debug", false), @@ -115,7 +115,7 @@ public enum Config { public final String path; public Object value; - Config(String path, Object defaultValue) { + ConfigValues(String path, Object defaultValue) { this.path = path; this.value = defaultValue; } @@ -128,7 +128,7 @@ public enum Config { check(soundPlayerNotFoundInput,getPlayerNotFound()); } - private static void check(Config object, Sound defaultSound){ + private static void check(ConfigValues object, Sound defaultSound){ try { Sound sound = Sound.valueOf(String.valueOf(object.value)); if (sound != null) { diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV5.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV5.java index 2e88a70..2e4395e 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV5.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV5.java @@ -1,7 +1,7 @@ package net.t2code.commandguiv2.Spigot.config.configConverter; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.functions.CreateFunctions; import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum; @@ -78,7 +78,7 @@ public class ConfigConverterV5 { File config = new File(Main.getPath(), "GUIs/" + configOld.getName().replace(".yml", "") + ".yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - yamlConfiguration.set(Config.configVersion.path, 5); + yamlConfiguration.set(ConfigValues.configVersion.path, 5); Boolean enable = yamlConfigurationOld.getBoolean("GUI.Enable"); Integer lines = yamlConfigurationOld.getInt("GUI.Lines"); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV6.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV6.java index c6bbd4f..b1c3574 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV6.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/configConverter/ConfigConverterV6.java @@ -1,7 +1,7 @@ package net.t2code.commandguiv2.Spigot.config.configConverter; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; @@ -32,102 +32,102 @@ public class ConfigConverterV6 { configOld = new File(Main.getPath(), "configV5.yml"); yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld); - set(Config.debug, "Plugin.Debug"); + set(ConfigValues.debug, "Plugin.Debug"); - set(Config.updateCheckOnJoin, "Plugin.updateCheck.onJoin"); - set(Config.updateCheckSeePreReleaseUpdates, "Plugin.updateCheck.seePreReleaseUpdates"); - set(Config.updateCheckTimeInterval, "Plugin.updateCheck.timeInterval"); - set(Config.helpAlias, "Plugin.HelpAlias"); - set(Config.adminSubCommand, "Plugin.AdminSubCommand"); - set(Config.language, "Plugin.language"); - set(Config.currency, "Plugin.Currency"); - set(Config.defaultGUI, "Plugin.DefaultGUI"); + set(ConfigValues.updateCheckOnJoin, "Plugin.updateCheck.onJoin"); + set(ConfigValues.updateCheckSeePreReleaseUpdates, "Plugin.updateCheck.seePreReleaseUpdates"); + set(ConfigValues.updateCheckTimeInterval, "Plugin.updateCheck.timeInterval"); + set(ConfigValues.helpAlias, "Plugin.HelpAlias"); + set(ConfigValues.adminSubCommand, "Plugin.AdminSubCommand"); + set(ConfigValues.language, "Plugin.language"); + set(ConfigValues.currency, "Plugin.Currency"); + set(ConfigValues.defaultGUI, "Plugin.DefaultGUI"); - set(Config.storage, "Storage.Type"); - set(Config.mysqlIp, "Storage.MySQL.IP"); - set(Config.mysqlPort, "Storage.MySQL.Port"); - set(Config.mysqlDatabase, "Storage.MySQL.Database"); - set(Config.mysqlUser, "Storage.MySQL.User"); - set(Config.mysqlPassword, "Storage.MySQL.Password"); - set(Config.mysqlSSL, "Storage.MySQL.SSL"); + set(ConfigValues.storage, "Storage.Type"); + set(ConfigValues.mysqlIp, "Storage.MySQL.IP"); + set(ConfigValues.mysqlPort, "Storage.MySQL.Port"); + set(ConfigValues.mysqlDatabase, "Storage.MySQL.Database"); + set(ConfigValues.mysqlUser, "Storage.MySQL.User"); + set(ConfigValues.mysqlPassword, "Storage.MySQL.Password"); + set(ConfigValues.mysqlSSL, "Storage.MySQL.SSL"); - set(Config.useItemEnable, "UseItem.Enable"); - set(Config.useItemAllowToggle, "UseItem.AllowToggle"); - set(Config.useItemAllowSetSlot, "UseItem.AllowSetSlot"); - set(Config.useItemBlockMoveAndDrop, "UseItem.BlockMoveAndDrop"); - set(Config.useItemOpenGUI, "UseItem.OpenGUI"); - set(Config.useItemPermission, "UseItem.Permission.NeededToUse"); - set(Config.useItemKeepAtCommandClear, "UseItem.KeepAtCommandClear"); + set(ConfigValues.useItemEnable, "UseItem.Enable"); + set(ConfigValues.useItemAllowToggle, "UseItem.AllowToggle"); + set(ConfigValues.useItemAllowSetSlot, "UseItem.AllowSetSlot"); + set(ConfigValues.useItemBlockMoveAndDrop, "UseItem.BlockMoveAndDrop"); + set(ConfigValues.useItemOpenGUI, "UseItem.OpenGUI"); + set(ConfigValues.useItemPermission, "UseItem.Permission.NeededToUse"); + set(ConfigValues.useItemKeepAtCommandClear, "UseItem.KeepAtCommandClear"); - set(Config.useItemInventorySlotFreeSlot, "UseItem.InventorySlot.FreeSlot"); - set(Config.useItemInventorySlot, "UseItem.InventorySlot.Slot"); - set(Config.useItemInventorySlotEnforce, "UseItem.InventorySlot.SlotEnforce"); - set(Config.useItemMaterial, "UseItem.Item.Material"); + set(ConfigValues.useItemInventorySlotFreeSlot, "UseItem.InventorySlot.FreeSlot"); + set(ConfigValues.useItemInventorySlot, "UseItem.InventorySlot.Slot"); + set(ConfigValues.useItemInventorySlotEnforce, "UseItem.InventorySlot.SlotEnforce"); + set(ConfigValues.useItemMaterial, "UseItem.Item.Material"); - set(Config.useItemPlayerHeadEnable, "UseItem.Item.PlayerHead.Enable"); - set(Config.useItemBase64Enable, "UseItem.Item.PlayerHead.Base64.Enable"); - set(Config.useItemBase64value, "UseItem.Item.PlayerHead.Base64.Base64Value"); - set(Config.useItemPlayerWhoHasOpenedTheGUI, "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI"); - set(Config.useItemPlayerName, "UseItem.Item.PlayerHead.PlayerName"); - set(Config.useItemName, "UseItem.Item.Name"); - set(Config.useItemLore, "UseItem.Item.Lore"); - set(Config.useItemGiveOnEveryJoin, "UseItem.Join.GiveOnEveryJoin"); - set(Config.useItemGiveOnlyOnFirstJoin, "UseItem.Join.GiveOnlyOnFirstJoin"); - set(Config.cursorToGUIItemOnLogin, "UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable"); - set(Config.cursorToGUIItemOnlyOnFirstLogin, "UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin"); - set(Config.useItemServerChange, "UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange"); + set(ConfigValues.useItemPlayerHeadEnable, "UseItem.Item.PlayerHead.Enable"); + set(ConfigValues.useItemBase64Enable, "UseItem.Item.PlayerHead.Base64.Enable"); + set(ConfigValues.useItemBase64value, "UseItem.Item.PlayerHead.Base64.Base64Value"); + set(ConfigValues.useItemPlayerWhoHasOpenedTheGUI, "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI"); + set(ConfigValues.useItemPlayerName, "UseItem.Item.PlayerHead.PlayerName"); + set(ConfigValues.useItemName, "UseItem.Item.Name"); + set(ConfigValues.useItemLore, "UseItem.Item.Lore"); + set(ConfigValues.useItemGiveOnEveryJoin, "UseItem.Join.GiveOnEveryJoin"); + set(ConfigValues.useItemGiveOnlyOnFirstJoin, "UseItem.Join.GiveOnlyOnFirstJoin"); + set(ConfigValues.cursorToGUIItemOnLogin, "UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable"); + set(ConfigValues.cursorToGUIItemOnlyOnFirstLogin, "UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin"); + set(ConfigValues.useItemServerChange, "UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange"); - set(Config.toggleItemOnOrYesBase64, "Toggle.Items.OnOrYes.Item.Base64.Enable"); - set(Config.toggleItemOnOrYesBase64Value, "Toggle.Items.OnOrYes.Item.Base64.Base64Value"); - set(Config.toggleItemOnOrYesMaterial, "Toggle.Items.OnOrYes.Item.Material"); + set(ConfigValues.toggleItemOnOrYesBase64, "Toggle.Items.OnOrYes.Item.Base64.Enable"); + set(ConfigValues.toggleItemOnOrYesBase64Value, "Toggle.Items.OnOrYes.Item.Base64.Base64Value"); + set(ConfigValues.toggleItemOnOrYesMaterial, "Toggle.Items.OnOrYes.Item.Material"); - set(Config.toggleItemOffOrNoBase64, "Toggle.Items.OffOrNo.Item.Base64.Enable"); - set(Config.toggleItemOffOrNoBase64Value, "Toggle.Items.OffOrNo.Item.Base64.Base64Value"); - set(Config.toggleItemOffOrNoMaterial, "Toggle.Items.OffOrNo.Item.Material"); + set(ConfigValues.toggleItemOffOrNoBase64, "Toggle.Items.OffOrNo.Item.Base64.Enable"); + set(ConfigValues.toggleItemOffOrNoBase64Value, "Toggle.Items.OffOrNo.Item.Base64.Base64Value"); + set(ConfigValues.toggleItemOffOrNoMaterial, "Toggle.Items.OffOrNo.Item.Material"); - set(Config.togglePermTrue, "Toggle.Permission.Commands.True"); - set(Config.togglePermFalse, "Toggle.Permission.Commands.False"); + set(ConfigValues.togglePermTrue, "Toggle.Permission.Commands.True"); + set(ConfigValues.togglePermFalse, "Toggle.Permission.Commands.False"); - set(Config.placeholderTrue, "Placeholder.True"); - set(Config.placeholderFalse, "Placeholder.False"); + set(ConfigValues.placeholderTrue, "Placeholder.True"); + set(ConfigValues.placeholderFalse, "Placeholder.False"); - set(Config.soundEnable, "Sound.Enable"); - set(Config.soundOpenInventoryEnable, "Sound.OpenInventory.Enable"); - set(Config.soundOpenInventoryInput, "Sound.OpenInventory.Sound"); - set(Config.soundClickEnable, "Sound.Click.Enable"); - set(Config.soundClickInput, "Sound.Click.Sound"); - set(Config.soundNoMoneyEnable, "Sound.NoMoney.Enable"); - set(Config.soundNoMoneyInput, "Sound.NoMoney.Sound"); + set(ConfigValues.soundEnable, "Sound.Enable"); + set(ConfigValues.soundOpenInventoryEnable, "Sound.OpenInventory.Enable"); + set(ConfigValues.soundOpenInventoryInput, "Sound.OpenInventory.Sound"); + set(ConfigValues.soundClickEnable, "Sound.Click.Enable"); + set(ConfigValues.soundClickInput, "Sound.Click.Sound"); + set(ConfigValues.soundNoMoneyEnable, "Sound.NoMoney.Enable"); + set(ConfigValues.soundNoMoneyInput, "Sound.NoMoney.Sound"); - set(Config.soundNoInventorySpaceEnable, "Sound.NoInventorySpace.Enable"); - set(Config.soundNoInventorySpaceInput, "Sound.NoInventorySpace.Sound"); - set(Config.soundGiveEnable, "Sound.Give.Enable"); - set(Config.soundGiveInput, "Sound.Give.Sound"); - set(Config.soundPlayerNotFoundEnable, "Sound.PlayerNotFound.Enable"); - set(Config.soundPlayerNotFoundInput, "Sound.PlayerNotFound.Sound"); + set(ConfigValues.soundNoInventorySpaceEnable, "Sound.NoInventorySpace.Enable"); + set(ConfigValues.soundNoInventorySpaceInput, "Sound.NoInventorySpace.Sound"); + set(ConfigValues.soundGiveEnable, "Sound.Give.Enable"); + set(ConfigValues.soundGiveInput, "Sound.Give.Sound"); + set(ConfigValues.soundPlayerNotFoundEnable, "Sound.PlayerNotFound.Enable"); + set(ConfigValues.soundPlayerNotFoundInput, "Sound.PlayerNotFound.Sound"); - set(Config.useItemGameModeChangeEnable, "Advanced.UseItem.GameMode.Change.Enable"); - set(Config.useItemGameModeChangeDelayInTicks, "Advanced.UseItem.GameMode.Change.DelayInTicks"); - set(Config.useItemGameModeProtection, "Advanced.UseItem.GameMode.Protection.Enable"); - set(Config.useItemGameModeRemoveItemWhenItIsDisabled, "Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled"); - set(Config.useItemGameModeMode, "Advanced.UseItem.GameMode.Protection.Mode"); + set(ConfigValues.useItemGameModeChangeEnable, "Advanced.UseItem.GameMode.Change.Enable"); + set(ConfigValues.useItemGameModeChangeDelayInTicks, "Advanced.UseItem.GameMode.Change.DelayInTicks"); + set(ConfigValues.useItemGameModeProtection, "Advanced.UseItem.GameMode.Protection.Enable"); + set(ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled, "Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled"); + set(ConfigValues.useItemGameModeMode, "Advanced.UseItem.GameMode.Protection.Mode"); - set(Config.useItemGameModeList, "Advanced.UseItem.GameMode.Protection.List"); + set(ConfigValues.useItemGameModeList, "Advanced.UseItem.GameMode.Protection.List"); - set(Config.useItemWorldChangeEnable, "Advanced.UseItem.World.Change.Enable"); - set(Config.useItemWorldChangeDelayInTicks, "Advanced.UseItem.World.Change.DelayInTicks"); - set(Config.useItemWorldProtection, "Advanced.UseItem.World.Protection.Enable"); - set(Config.useItemWorldRemoveItemWhenItIsDisabled, "Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled"); - set(Config.useItemWorldMode, "Advanced.UseItem.World.Protection.Mode"); - set(Config.useItemWorldList, "Advanced.UseItem.World.Protection.List"); + set(ConfigValues.useItemWorldChangeEnable, "Advanced.UseItem.World.Change.Enable"); + set(ConfigValues.useItemWorldChangeDelayInTicks, "Advanced.UseItem.World.Change.DelayInTicks"); + set(ConfigValues.useItemWorldProtection, "Advanced.UseItem.World.Protection.Enable"); + set(ConfigValues.useItemWorldRemoveItemWhenItIsDisabled, "Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled"); + set(ConfigValues.useItemWorldMode, "Advanced.UseItem.World.Protection.Mode"); + set(ConfigValues.useItemWorldList, "Advanced.UseItem.World.Protection.List"); - set(Config.disableInfoBySneak, "Advanced.UseItem.DisableInfoBySneak"); + set(ConfigValues.disableInfoBySneak, "Advanced.UseItem.DisableInfoBySneak"); - set(Config.useItemItemBlockBlacklist, "Advanced.UseItem.ItemBlockBlacklist"); + set(ConfigValues.useItemItemBlockBlacklist, "Advanced.UseItem.ItemBlockBlacklist"); } - private void set(Config obj, String path) { + private void set(ConfigValues obj, String path) { if (!yamlConfigurationOld.contains(path)) return; obj.value = yamlConfigurationOld.get(path); } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/functions/SelectFunctions.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/functions/SelectFunctions.java index fd5d54b..79d9285 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/functions/SelectFunctions.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/functions/SelectFunctions.java @@ -6,6 +6,7 @@ import net.t2code.commandguiv2.Spigot.enums.EcoEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum; import net.t2code.commandguiv2.Spigot.objects.FunctionObject; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.configuration.file.YamlConfiguration; @@ -15,7 +16,7 @@ import java.util.List; public class SelectFunctions { public static void onSelectFunction() { - Main.functionHashMap.clear(); + Cache.functionHashMap.clear(); File f = new File(Main.getPath() + "/Functions/"); File[] fileArray = f.listFiles(); @@ -127,7 +128,7 @@ public class SelectFunctions { configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, configListValueRight, pluginReloadEnable, pluginReloadCommand, functionVotePoints, functionVotePointsMode, functionVotePointsAmount, functionItem, functionItemMode, functionItemItem); - Main.functionHashMap.put(key, function); + Cache.functionHashMap.put(key, function); try { yamlConfiguration.save(config); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/gui/SelectGui.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/gui/SelectGui.java index acb5034..b236b21 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/gui/SelectGui.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/gui/SelectGui.java @@ -5,6 +5,7 @@ import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI; import net.t2code.commandguiv2.Spigot.objects.FunctionObject; import net.t2code.commandguiv2.Spigot.objects.GuiObject; import net.t2code.commandguiv2.Spigot.objects.SlotObject; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; import org.bukkit.configuration.file.YamlConfiguration; @@ -15,8 +16,8 @@ import java.util.ArrayList; public class SelectGui { public static void onSelectGui() { - Main.guiHashMap.clear(); - Main.allAliases.clear(); + Cache.guiHashMap.clear(); + Cache.allAliases.clear(); File f = new File(Main.getPath() + "/GUIs/"); File[] fileArray = f.listFiles(); @@ -26,7 +27,7 @@ public class SelectGui { String sub = config.getName().substring(config.getName().length() - 4); if (sub.equals(".yml")) { String key = config.getName().replace(".yml", ""); - Main.allAliases.add(key); + Cache.allAliases.add(key); YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config); Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable"); @@ -53,7 +54,7 @@ public class SelectGui { Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1; Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable"); String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function"); - FunctionObject functionCheck = Main.functionHashMap.get(function); + FunctionObject functionCheck = Cache.functionHashMap.get(function); if (functionCheck == null) { T2Csend.error(Main.getPlugin(), "The Function " + function + " in the GUI " + key + " does not exist!"); } @@ -71,7 +72,7 @@ public class SelectGui { GuiObject gui = new GuiObject(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, key, commandAliasEnable, commandPermission, slots); - Main.guiHashMap.put(key, gui); + Cache.guiHashMap.put(key, gui); CmdExecuter_GUI.arg1.put(config.getName() .replace(".yml", ""), "commandgui.gui." + key); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/languages/SelectMessages.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/languages/SelectMessages.java index ec70c07..976fabb 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/languages/SelectMessages.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/languages/SelectMessages.java @@ -1,7 +1,7 @@ package net.t2code.commandguiv2.Spigot.config.languages; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Util; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; @@ -87,17 +87,17 @@ public class SelectMessages { File msg; - msg = new File(Main.getPath(), "languages/" + Config.language.value + "_messages.yml"); + msg = new File(Main.getPath(), "languages/" + ConfigValues.language.value + "_messages.yml"); if (!msg.isFile()) { T2Csend.console(Prefix); T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - T2Csend.console(Prefix + " §4The selected §c" + Config.language.value + " §4language file was not found."); + T2Csend.console(Prefix + " §4The selected §c" + ConfigValues.language.value + " §4language file was not found."); T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!"); T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(Prefix); msg = new File(Main.getPath(), "languages/" + "english_messages.yml"); selectMSG = "english"; - } else selectMSG = String.valueOf(Config.language.value); + } else selectMSG = String.valueOf(ConfigValues.language.value); YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg); VaultNotSetUp = select("Plugin.VaultNotSetUp", yamlConfiguration_msg); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemSelect.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemSelect.java new file mode 100644 index 0000000..c565f4f --- /dev/null +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemSelect.java @@ -0,0 +1,74 @@ +package net.t2code.commandguiv2.Spigot.config.useItems; + +import net.t2code.commandguiv2.Spigot.Main; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; +import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5; +import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV6; +import net.t2code.commandguiv2.Spigot.enums.EcoEnum; +import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; +import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum; +import net.t2code.commandguiv2.Spigot.objects.FunctionObject; +import net.t2code.commandguiv2.Spigot.objects.UseItemObject; +import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; +import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; +import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +public class UseItemSelect { + + public UseItemSelect(){ + create(); + onSelectFunction(); + } + + private void create(){ + File config = new File(Main.getPath(), "/UseItems/default.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + for (UseItemValues value : UseItemValues.values()) { + T2Cconfig.set(value.path, value.value, yamlConfiguration); + } + + try { + yamlConfiguration.save(config); + } catch ( + IOException e) { + e.printStackTrace(); + } + } + private void onSelectFunction() { + Cache.useItemHash.clear(); + File f = new File(Main.getPath() + "/UseItems/"); + File[] fileArray = f.listFiles(); + + for (File config : fileArray) { + if (config.getName().equals("useItemDeclaration.yml")) continue; + String sub = config.getName().substring(config.getName().length() - 4); + if (sub.equals(".yml")) { + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + String key = config.getName().replace(".yml", ""); + + + + + + + UseItemObject useItem = new UseItemObject(key); + Cache.useItemHash.put(key, useItem); + + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemValues.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemValues.java new file mode 100644 index 0000000..7ae823c --- /dev/null +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/useItems/UseItemValues.java @@ -0,0 +1,69 @@ +package net.t2code.commandguiv2.Spigot.config.useItems; + +import net.t2code.commandguiv2.Spigot.Main; +import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; +import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum; +import net.t2code.commandguiv2.Util; +import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public enum UseItemValues { + + enable("useItem.enable",true), + openGUI("useItem.openGUI","default"), + allowToggle("useItem.allowToggle",true), + allowSetSlot("useItem.allowSetSlot",true), + blockMoveAndDrop("useItem.blockMoveAndDrop",true), + permissionBecomeNeeded("useItem.permission.become.needed",true), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null), + xxxx("useItem.enable",null); + + + + + + + + public final String path; + public Object value; + + UseItemValues(String path, Object defaultValue) { + this.path = path; + this.value = defaultValue; + } +} diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/MySQL.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/MySQL.java index 3186050..dca82c3 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/MySQL.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/MySQL.java @@ -3,7 +3,7 @@ package net.t2code.commandguiv2.Spigot.database; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Util; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; @@ -24,11 +24,11 @@ public class MySQL { ZoneId timeZone = now.getTimeZone().toZoneId(); T2Csend.debug(Main.getPlugin(), "Server TimeZone is : " + timeZone); try { - config.setJdbcUrl("jdbc:mysql://" + Config.mysqlIp.value + ":" + Config.mysqlPort.value + "/" + Config.mysqlDatabase.value + config.setJdbcUrl("jdbc:mysql://" + ConfigValues.mysqlIp.value + ":" + ConfigValues.mysqlPort.value + "/" + ConfigValues.mysqlDatabase.value + "?useJDBCCompliantTimezoneShift=true&allowMultiQueries=true&useLegacyDatetimeCode=false&autoReconnect=true&serverTimezone=" + timeZone - + "&useSSL=" + Config.mysqlSSL.value); - config.setUsername(String.valueOf(Config.mysqlUser.value)); - config.setPassword(String.valueOf(Config.mysqlPassword.value)); + + "&useSSL=" + ConfigValues.mysqlSSL.value); + config.setUsername(String.valueOf(ConfigValues.mysqlUser.value)); + config.setPassword(String.valueOf(ConfigValues.mysqlPassword.value)); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); @@ -39,7 +39,7 @@ public class MySQL { T2Csend.error(Main.getPlugin(), ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms"); } - if ((Boolean) Config.debug.value || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) { + if ((Boolean) ConfigValues.debug.value || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) { try { T2Csend.error(Main.getPlugin(), "MySQL DEBUG:"); Connection con = ds.getConnection(); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/SelectDatabase.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/SelectDatabase.java index a424aa1..2f5cd95 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/SelectDatabase.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/database/SelectDatabase.java @@ -39,7 +39,7 @@ public class SelectDatabase { } } - public static void setSlot(Player player, Integer slot) { + public static void setSlot(Player player, String useItemKey, Integer slot) { switch (Storage) { case MYSQL: try { @@ -84,7 +84,7 @@ public class SelectDatabase { } } - public static void setItemStatus(Player player, boolean status) { + public static void setItemStatus(Player player, String useItemKey, boolean status) { int i; if (status) { i = 1; @@ -111,7 +111,7 @@ public class SelectDatabase { } } - public static Boolean selectItemStatus(Player player) { + public static Boolean selectItemStatus(Player player,String useItemKey) { switch (Storage) { case MYSQL: String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); @@ -131,7 +131,7 @@ public class SelectDatabase { } } - public static Integer selectSlot(Player player) { + public static Integer selectSlot(Player player,String useItemKey) { switch (Storage) { case MYSQL: String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GUIListener.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GUIListener.java index 4201bbd..73d640d 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GUIListener.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GUIListener.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.function.gui; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.function.listener.ServerChange; import net.t2code.commandguiv2.Spigot.function.useItem.Events; import net.t2code.commandguiv2.Spigot.objects.FunctionObject; @@ -14,6 +14,7 @@ import net.t2code.commandguiv2.Spigot.system.Placeholder; import net.t2code.commandguiv2.Spigot.sound.PlaySound; import net.t2code.commandguiv2.Spigot.enums.SoundEnum; import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; @@ -45,7 +46,7 @@ public class GUIListener implements Listener { Player player = (Player) e.getWhoClicked(); if (e.getInventory() == null) return; if (e.getCurrentItem() == null) return; - for (GuiObject gui : Main.guiHashMap.values()) { + for (GuiObject gui : Cache.guiHashMap.values()) { if (player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, GUICode + gui.guiName)) || (Main.PaPi && player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, player, GUICode + gui.guiName)))) { e.setCancelled(true); @@ -61,7 +62,7 @@ public class GUIListener implements Listener { private static void execute(InventoryClickEvent e, SlotObject slot, Player player, GuiObject gui) { if (e.getSlot() != slot.slot) return; - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); if (slot.permission && !player.hasPermission(slot.permissionToSee)) return; if (slot.permission && !player.hasPermission(slot.permissionToUse)) { if (function.noPermMessageEnable) { @@ -153,11 +154,11 @@ public class GUIListener implements Listener { for (String msg : slot.message) { if (Main.PaPi) { if (slot.cost_Enable) { - T2Csend.player(player, T2Creplace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + Config.currency.value)); + T2Csend.player(player, T2Creplace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + ConfigValues.currency.value)); } else T2Csend.player(player, T2Creplace.replace(prefix, player, Placeholder.replace(msg, player))); } else { if (slot.cost_Enable) { - T2Csend.player(player, T2Creplace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + Config.currency.value)); + T2Csend.player(player, T2Creplace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + ConfigValues.currency.value)); } else T2Csend.player(player, T2Creplace.replace(prefix, Placeholder.replace(msg, player))); } } @@ -247,7 +248,7 @@ public class GUIListener implements Listener { private static void togglePerm(FunctionObject function, GuiObject gui, Player player) { if (player.hasPermission(function.togglePermissionPerm)) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(Config.togglePermFalse.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(ConfigValues.togglePermFalse.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); new BukkitRunnable() { @Override public void run() { @@ -256,7 +257,7 @@ public class GUIListener implements Listener { } }.runTaskLater(plugin, 4L); } else - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(Config.togglePermTrue.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(ConfigValues.togglePermTrue.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); new BukkitRunnable() { @Override public void run() { @@ -361,7 +362,7 @@ public class GUIListener implements Listener { PlaySound.play(player, SoundEnum.NoMoney); } else { T2Csend.player(player, SelectMessages.Buy_msg.replace("[itemname]", T2Creplace.replace(prefix, function.name)) - .replace("[price]", function.price + " " + Config.currency.value)); + .replace("[price]", function.price + " " + ConfigValues.currency.value)); execute(function, slot, player, e, gui); } break; diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GuiBuilder.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GuiBuilder.java index 6a8370c..a180c9a 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GuiBuilder.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/GuiBuilder.java @@ -3,12 +3,13 @@ package net.t2code.commandguiv2.Spigot.function.gui; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.objects.GuiObject; import net.t2code.commandguiv2.Spigot.objects.FunctionObject; import net.t2code.commandguiv2.Spigot.objects.SlotObject; import net.t2code.commandguiv2.Spigot.system.Placeholder; import net.t2code.commandguiv2.Util; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; @@ -27,7 +28,7 @@ public class GuiBuilder { private static String prefix = Util.getPrefix(); protected static void item(SlotObject slot, Player player, Inventory inventory) { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); ItemStack item; if (Main.legacy && function.item.toUpperCase().contains(",")) { String[] split = function.item.toUpperCase().split(","); @@ -45,7 +46,7 @@ public class GuiBuilder { } protected static void item(String material, SlotObject slot, Player player, Inventory inventory) { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); ItemStack item; if (Main.legacy && material.contains(",")) { String[] split = material.split(","); @@ -64,22 +65,22 @@ public class GuiBuilder { private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, SlotObject slot) { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); if (Main.PaPi) { itemMeta.setDisplayName(T2Creplace.replace(prefix, player, Placeholder.replace(function.name, player))); if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) { - itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.noPermLore, player), function.price + " " + Config.currency.value)); - } else itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.lore, player), function.price + " " + Config.currency.value)); + itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.noPermLore, player), function.price + " " + ConfigValues.currency.value)); + } else itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.lore, player), function.price + " " + ConfigValues.currency.value)); } else { itemMeta.setDisplayName(T2Creplace.replace(prefix, Placeholder.replace(function.name, player))); if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) { - itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.noPermLore, player), function.price + " " + Config.currency.value)); - } else itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.lore, player), function.price + " " + Config.currency.value)); + itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.noPermLore, player), function.price + " " + ConfigValues.currency.value)); + } else itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.lore, player), function.price + " " + ConfigValues.currency.value)); } } protected static void base64(String base64Value, SlotObject slot, Player player, Inventory inventory) { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); ItemStack item = T2CitemVersion.getHeadIS(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); setBase64(itemMeta, base64Value); @@ -107,12 +108,12 @@ public class GuiBuilder { } protected static void base64(SlotObject slot, Player player, Inventory inventory) { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); base64(function.base64Value, slot, player, inventory); } protected static void playerHead(SlotObject slot, Player player, Inventory inventory, String skullName) { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); ItemStack item = T2CitemVersion.getHeadIS(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); setDisplayNameAndLore(itemMeta, player, slot); diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/OpenGUI.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/OpenGUI.java index 19f762f..eddaa58 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/OpenGUI.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/gui/OpenGUI.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.function.gui; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.system.Permissions; import net.t2code.commandguiv2.Spigot.function.useItem.Events; import net.t2code.commandguiv2.Spigot.Main; @@ -12,6 +12,7 @@ import net.t2code.commandguiv2.Spigot.sound.PlaySound; import net.t2code.commandguiv2.Spigot.enums.SoundEnum; import net.t2code.commandguiv2.Util; import io.github.solyze.plugmangui.inventories.PluginListGUI; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.luckyBox.api.LuckyBoxAPI; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; @@ -29,7 +30,7 @@ public class OpenGUI { private static String prefix = Util.getPrefix(); public static void openGUI(Player player, String guiString, Boolean sound) { - GuiObject gui = Main.guiHashMap.get(guiString); + GuiObject gui = Cache.guiHashMap.get(guiString); Long long_ = Long.valueOf(System.currentTimeMillis()); switch (guiString) { //case "plugin.PlotSquaredGUI": @@ -78,7 +79,7 @@ public class OpenGUI { } for (SlotObject slot : gui.slots) { try { - FunctionObject function = Main.functionHashMap.get(slot.function); + FunctionObject function = Cache.functionHashMap.get(slot.function); if (function == null) { T2Csend.error(Main.getPlugin(), "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!"); continue; @@ -136,14 +137,14 @@ public class OpenGUI { } private static void toggleOn(FunctionObject function, SlotObject slot, Player player, Inventory inventory) { - if ((Boolean) Config.toggleItemOnOrYesBase64.value) { - GuiBuilder.base64(String.valueOf( Config.toggleItemOnOrYesBase64Value.value), slot, player, inventory); - } else GuiBuilder.item(String.valueOf(Config.toggleItemOnOrYesMaterial.value), slot, player, inventory); + if ((Boolean) ConfigValues.toggleItemOnOrYesBase64.value) { + GuiBuilder.base64(String.valueOf( ConfigValues.toggleItemOnOrYesBase64Value.value), slot, player, inventory); + } else GuiBuilder.item(String.valueOf(ConfigValues.toggleItemOnOrYesMaterial.value), slot, player, inventory); } private static void toggleOff(FunctionObject function, SlotObject slot, Player player, Inventory inventory) { - if ((Boolean) Config.toggleItemOffOrNoBase64.value) { - GuiBuilder.base64(String.valueOf( Config.toggleItemOffOrNoBase64Value.value), slot, player, inventory); - } else GuiBuilder.item(String.valueOf(Config.toggleItemOffOrNoMaterial.value), slot, player, inventory); + if ((Boolean) ConfigValues.toggleItemOffOrNoBase64.value) { + GuiBuilder.base64(String.valueOf( ConfigValues.toggleItemOffOrNoBase64Value.value), slot, player, inventory); + } else GuiBuilder.item(String.valueOf(ConfigValues.toggleItemOffOrNoMaterial.value), slot, player, inventory); } } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/Events.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/Events.java index c4ce998..2ee4900 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/Events.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/Events.java @@ -2,7 +2,7 @@ package net.t2code.commandguiv2.Spigot.function.useItem; import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.cmdManagement.Commands; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI; import net.t2code.commandguiv2.Spigot.database.SelectDatabase; @@ -40,7 +40,7 @@ public class Events implements Listener { useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer())); Integer i = SelectDatabase.selectSlot(e.getPlayer()); if (i == null) { - useItemSlotHashMap.put(e.getPlayer().getName(), (Integer) Config.useItemInventorySlot.value); + useItemSlotHashMap.put(e.getPlayer().getName(), (Integer) ConfigValues.useItemInventorySlot.value); } else useItemSlotHashMap.put(e.getPlayer().getName(), i); if (CGuiAPI.JoinDisable) { @@ -73,7 +73,7 @@ public class Events implements Listener { while (var3.hasNext()) { ItemStack items = (ItemStack) var3.next(); if (items != null && items.hasItemMeta() && items.getItemMeta().hasDisplayName() - && items.getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && items.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.getDrops().remove(items); } } @@ -83,7 +83,7 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onRespawn(PlayerRespawnEvent e) { Player player = e.getPlayer(); - if ((Boolean) Config.useItemEnable.value) { + if ((Boolean) ConfigValues.useItemEnable.value) { ItemChange.itemChange(player, false); //if (!Config.getUseItem_AllowToggle || Select_Database.selectItemStatus(player)) { // if (Config.getUseItem_GiveOnlyOnFirstJoin) { @@ -110,7 +110,7 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onGameModeChange(PlayerGameModeChangeEvent e) { Player player = e.getPlayer(); - if (!(Boolean) Config.useItemGameModeChangeEnable.value) { + if (!(Boolean) ConfigValues.useItemGameModeChangeEnable.value) { return; } new BukkitRunnable() { @@ -118,13 +118,13 @@ public class Events implements Listener { public void run() { ItemChange.itemChange(player, false); } - }.runTaskLater(Main.getPlugin(), (Integer) Config.useItemGameModeChangeDelayInTicks.value * 1L); + }.runTaskLater(Main.getPlugin(), (Integer) ConfigValues.useItemGameModeChangeDelayInTicks.value * 1L); } @EventHandler public void onWorldChange(PlayerChangedWorldEvent e) { Player player = e.getPlayer(); - if (!(Boolean) Config.useItemWorldChangeEnable.value) { + if (!(Boolean) ConfigValues.useItemWorldChangeEnable.value) { return; } new BukkitRunnable() { @@ -132,30 +132,30 @@ public class Events implements Listener { public void run() { ItemChange.itemChange(player, false); } - }.runTaskLater(Main.getPlugin(), (Integer) Config.useItemWorldChangeDelayInTicks.value * 1L); + }.runTaskLater(Main.getPlugin(), (Integer) ConfigValues.useItemWorldChangeDelayInTicks.value * 1L); } @EventHandler(priority = EventPriority.HIGHEST) public void onInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); if (!p.isSneaking()) { - for (String material : (ArrayList) Config.useItemItemBlockBlacklist.value) { + for (String material : (ArrayList) ConfigValues.useItemItemBlockBlacklist.value) { if (e.getClickedBlock() != null) { if (e.getClickedBlock().getType() == Material.valueOf(material)) return; } } } - if ((Boolean) Config.useItemEnable.value) { - if ((Boolean) Config.useItemPlayerHeadEnable.value) { + if ((Boolean) ConfigValues.useItemEnable.value) { + if ((Boolean) ConfigValues.useItemPlayerHeadEnable.value) { if (e.getItem() != null && p.getItemInHand().getType() == T2CitemVersion.getHead()) { - if (e.getItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + if (e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { openGUI(e, p); } } } else { - if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(String.valueOf(Config.useItemMaterial.value))) { - if (e.getItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(String.valueOf(ConfigValues.useItemMaterial.value))) { + if (e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { openGUI(e, p); } } @@ -166,7 +166,7 @@ public class Events implements Listener { private static void openGUI(PlayerInteractEvent e, Player player) { e.setCancelled(true); - if ((!(Boolean) Config.disableInfoBySneak.value) && player.isSneaking()) { + if ((!(Boolean) ConfigValues.disableInfoBySneak.value) && player.isSneaking()) { Commands.info(player); return; } @@ -177,45 +177,45 @@ public class Events implements Listener { if (UseItem.protection(player, true)) return; - if ((Boolean) Config.useItemGameModeProtection.value) { - if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) { + if ((Boolean) ConfigValues.useItemGameModeProtection.value) { + if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) { e.setCancelled(true); T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); return; } - if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) { + if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) { e.setCancelled(true); T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); return; } } - if ((Boolean) Config.useItemWorldProtection.value) { - if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) { + if ((Boolean) ConfigValues.useItemWorldProtection.value) { + if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) { e.setCancelled(true); T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); return; } - if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) { + if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) { e.setCancelled(true); T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); return; } } - if (!(Boolean) Config.useItemPermission.value || player.hasPermission("commandgui.useitem")) { - OpenGUI.openGUI(player, String.valueOf(Config.useItemOpenGUI.value), true); + if (!(Boolean) ConfigValues.useItemPermission.value || player.hasPermission("commandgui.useitem")) { + OpenGUI.openGUI(player, String.valueOf(ConfigValues.useItemOpenGUI.value), true); } else { T2Csend.player(player, SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") - .replace("[gui]", String.valueOf(Config.useItemOpenGUI.value))); + .replace("[gui]", String.valueOf(ConfigValues.useItemOpenGUI.value))); } } @EventHandler(priority = EventPriority.HIGHEST) public void onItemMoveEvent(InventoryMoveItemEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName() - && e.getItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } } @@ -223,19 +223,19 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onItemMove(InventoryDragEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getWhoClicked() instanceof Player) { Player p = (Player) e.getWhoClicked(); if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName() - && e.getCursor().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getCursor().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { p.closeInventory(); e.setCancelled(true); ItemChange.itemChange(p, false); } if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName() - && e.getOldCursor().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getOldCursor().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { p.closeInventory(); e.setCancelled(true); ItemChange.itemChange(p, false); @@ -245,14 +245,14 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemMove(InventoryClickEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName() - && e.getCursor().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getCursor().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } if (e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName() - && e.getCurrentItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getCurrentItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } @@ -260,12 +260,12 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onItemMove(InventoryPickupItemEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getItem() != null && e.getItem().getItemStack() != null) { ItemStack item = e.getItem().getItemStack(); if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() - && item.getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && item.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } } @@ -273,21 +273,21 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onPlace(BlockPlaceEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName() - && e.getItemInHand().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getItemInHand().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } } @EventHandler(priority = EventPriority.HIGHEST) public void onDrop(PlayerDropItemEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) { ItemStack item = e.getItemDrop().getItemStack(); if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() - && item.getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && item.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } } @@ -299,7 +299,7 @@ public class Events implements Listener { @EventHandler public void onClearServer(ServerCommandEvent event) { - if ((Boolean) Config.useItemKeepAtCommandClear.value) { + if ((Boolean) ConfigValues.useItemKeepAtCommandClear.value) { if (event.getCommand().contains("clear " + event.getCommand().replace("/", "").replace("clear ", ""))) { new BukkitRunnable() { @Override @@ -323,7 +323,7 @@ public class Events implements Listener { @EventHandler public void onClearPlayer(PlayerCommandPreprocessEvent event) { - if ((Boolean) Config.useItemKeepAtCommandClear.value) { + if ((Boolean) ConfigValues.useItemKeepAtCommandClear.value) { if (event.getMessage().toLowerCase().contains("clear")) { new BukkitRunnable() { @Override diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/EventsFrom110.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/EventsFrom110.java index eafe215..9c91ae8 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/EventsFrom110.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/EventsFrom110.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.function.useItem; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -11,27 +11,27 @@ public class EventsFrom110 implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onHandSwap(PlayerSwapHandItemsEvent e) { - if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName() - && e.getMainHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getMainHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { } if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName() - && e.getOffHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getOffHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { e.setCancelled(true); } } @EventHandler(priority = EventPriority.HIGHEST) public void onItemMove(PlayerSwapHandItemsEvent e) { - if (!(Boolean)Config.useItemBlockMoveAndDrop.value || !(Boolean)Config.useItemEnable.value) return; + if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return; Player p = e.getPlayer(); if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName() - && e.getOffHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getOffHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { p.closeInventory(); e.setCancelled(true); } if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName() - && e.getMainHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + && e.getMainHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { p.closeInventory(); e.setCancelled(true); } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/ItemChange.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/ItemChange.java index a39adcd..dd25de5 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/ItemChange.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/ItemChange.java @@ -1,33 +1,33 @@ package net.t2code.commandguiv2.Spigot.function.useItem; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; public class ItemChange { public static void itemChange(Player player, Boolean setCursor) { T2Csend.debug(Main.getPlugin(), "Join: " + player.getName()); Integer slot; - if ((Boolean) Config.useItemInventorySlotEnforce.value) { - slot =(Integer) Config.useItemInventorySlot.value; + if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) { + slot = (Integer) ConfigValues.useItemInventorySlot.value; } else { slot = Events.useItemSlotHashMap.get(player.getName()); } T2Csend.debug(Main.getPlugin(), "Slot " + slot + " for player: " + player.getName()); - if (!(Boolean)Config.useItemEnable.value) { + if (!(Boolean) ConfigValues.useItemEnable.value) { return; } UseItem.removeItem(player); if (UseItem.protection(player, false)) return; - if ((Boolean)Config.useItemGiveOnlyOnFirstJoin.value) { + if ((Boolean) ConfigValues.useItemGiveOnlyOnFirstJoin.value) { T2Csend.debug(Main.getPlugin(), "OnlyOnFirstJoin: " + player.getName()); - if (!(Boolean)Config.useItemAllowToggle.value || Events.useItemHashMap.get(player.getName())) { + if (!(Boolean) ConfigValues.useItemAllowToggle.value || Events.useItemHashMap.get(player.getName())) { if (!player.hasPlayedBefore()) { - new BukkitRunnable() { + Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() { //todo testen @Override public void run() { UseItem.giveUseItem(player); @@ -35,8 +35,8 @@ public class ItemChange { setCursor(player, slot); } } - }.runTaskLater(Main.getPlugin(), 1L * 1); - if ((Boolean)Config.cursorToGUIItemOnlyOnFirstLogin.value ||(Boolean) Config.cursorToGUIItemOnLogin.value) { + },1L); + if ((Boolean) ConfigValues.cursorToGUIItemOnlyOnFirstLogin.value || (Boolean) ConfigValues.cursorToGUIItemOnLogin.value) { player.getInventory().setHeldItemSlot(slot - 1); } } @@ -44,23 +44,24 @@ public class ItemChange { T2Csend.debug(Main.getPlugin(), "GiveOnlyOnFirstJoin: " + player.getName()); return; } - if (!(Boolean)Config.useItemGiveOnEveryJoin.value) { + if (!(Boolean) ConfigValues.useItemGiveOnEveryJoin.value) { T2Csend.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName()); return; } - new BukkitRunnable() { + + Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() { //todo testen @Override public void run() { Boolean pln = Events.useItemHashMap.get(player.getName()); if (pln == null) return; - if (!(Boolean)Config.useItemAllowToggle.value || pln) { - if ((Boolean)Config.useItemInventorySlotEnforce.value || player.getInventory().getItem(slot - 1) == null) { + if (!(Boolean) ConfigValues.useItemAllowToggle.value || pln) { + if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value || player.getInventory().getItem(slot - 1) == null) { T2Csend.debug(Main.getPlugin(), "Give: " + player.getName()); UseItem.giveUseItem(player); if (setCursor) { setCursor(player, slot); } - } else if ((Boolean)Config.useItemInventorySlotFreeSlot.value) { + } else if ((Boolean) ConfigValues.useItemInventorySlotFreeSlot.value) { boolean empty = false; for (int i = 0; i < 9; i++) { if (player.getInventory().getItem(i) == null) { @@ -71,20 +72,20 @@ public class ItemChange { if (empty) { UseItem.addUseItem(player); } - }else T2Csend.debug(Main.getPlugin(), "give skip [1]: " + player.getName()); + } else T2Csend.debug(Main.getPlugin(), "give skip [1]: " + player.getName()); } else T2Csend.debug(Main.getPlugin(), "give skip [2]: " + player.getName()); } - }.runTaskLater(Main.getPlugin(), 1L * 1); + }, 1L); } private static void setCursor(Player player, int slot) { T2Csend.debug(Main.getPlugin(), "setCursor 1 Player: " + player.getName()); - if (!(Boolean)Config.cursorToGUIItemOnLogin.value) { + if (!(Boolean) ConfigValues.cursorToGUIItemOnLogin.value) { return; } T2Csend.debug(Main.getPlugin(), "setCursor 2 Player: " + player.getName()); - if ((Boolean)Config.cursorToGUIItemOnlyOnFirstLogin.value) { + if ((Boolean) ConfigValues.cursorToGUIItemOnlyOnFirstLogin.value) { if (!player.hasPlayedBefore()) { player.getInventory().setHeldItemSlot(slot - 1); T2Csend.debug(Main.getPlugin(), "setCursor 3 Player: " + player.getName()); @@ -98,7 +99,7 @@ public class ItemChange { return; } T2Csend.debug(Main.getPlugin(), "setCursor 6 Player: " + player.getName()); - if ((Boolean)Config.useItemServerChange.value) { + if ((Boolean) ConfigValues.useItemServerChange.value) { player.getInventory().setHeldItemSlot(slot - 1); T2Csend.debug(Main.getPlugin(), "setCursor 7 Player: " + player.getName()); return; diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/UseItem.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/UseItem.java index c25beeb..6bffd63 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/UseItem.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/function/useItem/UseItem.java @@ -3,7 +3,7 @@ package net.t2code.commandguiv2.Spigot.function.useItem; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import net.t2code.commandguiv2.Spigot.Main; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Util; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; @@ -24,12 +24,12 @@ public class UseItem { public static void giveUseItem(Player player) { Integer slot; if (protection(player, false)) return; - if ((Boolean) Config.useItemInventorySlotEnforce.value) { - slot = (Integer) Config.useItemInventorySlot.value; + if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) { + slot = (Integer) ConfigValues.useItemInventorySlot.value; } else { slot = Events.useItemSlotHashMap.get(player.getName()); } - if ((Boolean) Config.useItemInventorySlotFreeSlot.value) { + if ((Boolean) ConfigValues.useItemInventorySlotFreeSlot.value) { player.getInventory().addItem(itemStack(player)); } else { T2Csend.debug(Main.getPlugin(), "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1))); @@ -39,27 +39,27 @@ public class UseItem { public static void addUseItem(Player player) { if (protection(player, false)) return; - if ((Boolean) Config.useItemInventorySlotFreeSlot.value) { + if ((Boolean) ConfigValues.useItemInventorySlotFreeSlot.value) { player.getInventory().addItem(itemStack(player)); } else player.getInventory().addItem(itemStack(player)); } private static ItemStack itemStack(Player player) { ItemStack item = null; - if ((Boolean) Config.useItemPlayerHeadEnable.value) { + if ((Boolean) ConfigValues.useItemPlayerHeadEnable.value) { if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) { T2Csend.player(player, Util.getPrefix() + "§c Playerheads for UseItem are only available from version §61.13§c!"); T2Csend.error(Main.getPlugin(), "Playerheads for UseItem are only available from version 1.13!"); } else { item = T2CitemVersion.getHeadIS(); SkullMeta playerheadmeta = (SkullMeta) item.getItemMeta(); - playerheadmeta.setDisplayName(String.valueOf(Config.useItemName.value)); - if ((Boolean) Config.useItemBase64Enable.value) { + playerheadmeta.setDisplayName(String.valueOf(ConfigValues.useItemName.value)); + if ((Boolean) ConfigValues.useItemBase64Enable.value) { if (Main.PaPi) { - playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList) Config.useItemLore.value)); - } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList) Config.useItemLore.value)); + playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList) ConfigValues.useItemLore.value)); + } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList) ConfigValues.useItemLore.value)); GameProfile profile = new GameProfile(UUID.randomUUID(), ""); - profile.getProperties().put("textures", new Property("textures", String.valueOf(Config.useItemBase64value.value))); + profile.getProperties().put("textures", new Property("textures", String.valueOf(ConfigValues.useItemBase64value.value))); Field profileField = null; try { profileField = playerheadmeta.getClass().getDeclaredField("profile"); @@ -70,23 +70,23 @@ public class UseItem { } } else { String p; - if ((Boolean) Config.useItemPlayerWhoHasOpenedTheGUI.value) { + if ((Boolean) ConfigValues.useItemPlayerWhoHasOpenedTheGUI.value) { p = player.getName(); - } else p = String.valueOf(Config.useItemPlayerName.value); + } else p = String.valueOf(ConfigValues.useItemPlayerName.value); playerheadmeta.setOwner(p); if (Main.PaPi) { - playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList) Config.useItemLore.value)); - } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList) Config.useItemLore.value)); + playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList) ConfigValues.useItemLore.value)); + } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList) ConfigValues.useItemLore.value)); } item.setItemMeta(playerheadmeta); } } else { - item = new ItemStack(Material.valueOf(String.valueOf(Config.useItemMaterial.value))); + item = new ItemStack(Material.valueOf(String.valueOf(ConfigValues.useItemMaterial.value))); ItemMeta itemMeta = item.getItemMeta(); - itemMeta.setDisplayName(String.valueOf(Config.useItemName.value)); + itemMeta.setDisplayName(String.valueOf(ConfigValues.useItemName.value)); if (Main.PaPi) { - itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList) Config.useItemLore.value)); - } else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList) Config.useItemLore.value)); + itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList) ConfigValues.useItemLore.value)); + } else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList) ConfigValues.useItemLore.value)); item.setItemMeta(itemMeta); item.setAmount(1); } @@ -94,31 +94,31 @@ public class UseItem { } public static boolean protection(Player player, Boolean interact) { - if ((Boolean) Config.useItemGameModeProtection.value) { - if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) { + if ((Boolean) ConfigValues.useItemGameModeProtection.value) { + if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) { if (interact) { T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); - } else if (!(Boolean) Config.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player); + } else if (!(Boolean) ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player); return true; } - if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) { + if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) { if (interact) { T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); - } else if (!(Boolean) Config.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player); + } else if (!(Boolean) ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player); return true; } } - if ((Boolean) Config.useItemWorldProtection.value) { - if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) { + if ((Boolean) ConfigValues.useItemWorldProtection.value) { + if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) { if (interact) { T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); - } else if (!(Boolean) Config.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player); + } else if (!(Boolean) ConfigValues.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player); return true; } - if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) { + if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) { if (interact) { T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); - } else if (!(Boolean) Config.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player); + } else if (!(Boolean) ConfigValues.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player); return true; } } @@ -130,8 +130,8 @@ public class UseItem { for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { ItemStack itm = player.getInventory().getItem(iam); if (itm != null) { - if (itm.getType() == Material.valueOf(String.valueOf(Config.useItemMaterial.value)) || itm.getType() == T2CitemVersion.getHead()) { - if (itm.getItemMeta().getDisplayName().equals(Config.useItemName.value)) { + if (itm.getType() == Material.valueOf(String.valueOf(ConfigValues.useItemMaterial.value)) || itm.getType() == T2CitemVersion.getHead()) { + if (itm.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) { player.getInventory().remove(itm); player.updateInventory(); break; diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/PlayerObject.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/PlayerObject.java new file mode 100644 index 0000000..e4da16d --- /dev/null +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/PlayerObject.java @@ -0,0 +1,11 @@ +package net.t2code.commandguiv2.Spigot.objects.player; + +import java.util.ArrayList; + +public class PlayerObject { + public ArrayList useItems; + + public PlayerObject(ArrayList useItems) { + this.useItems = useItems; + } +} diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/UseItemPlayerObject.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/UseItemPlayerObject.java new file mode 100644 index 0000000..6f76587 --- /dev/null +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/objects/player/UseItemPlayerObject.java @@ -0,0 +1,13 @@ +package net.t2code.commandguiv2.Spigot.objects.player; + +public class UseItemPlayerObject { + public String key; + public Boolean enable; + public Integer slot; + + public UseItemPlayerObject(String key, Boolean enable, Integer slot) { + this.key = key; + this.enable = enable; + this.slot = slot; + } +} diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/sound/PlaySound.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/sound/PlaySound.java index 7879279..bccd015 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/sound/PlaySound.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/sound/PlaySound.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.sound; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.objects.FunctionObject; import net.t2code.commandguiv2.Spigot.objects.GuiObject; @@ -18,16 +18,16 @@ public class PlaySound { } public static void play(Player player, SoundEnum soundEnum, FunctionObject function, SlotObject slot, GuiObject gui) { - if (!(Boolean) Config.soundEnable.value) return; + if (!(Boolean) ConfigValues.soundEnable.value) return; switch (soundEnum) { case OpenInventory: - if (!(Boolean) Config.soundOpenInventoryEnable.value) return; - player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundOpenInventoryInput.value).toUpperCase().replace(".", "_")), 3, 1); + if (!(Boolean) ConfigValues.soundOpenInventoryEnable.value) return; + player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundOpenInventoryInput.value).toUpperCase().replace(".", "_")), 3, 1); break; case Click: - if (!(Boolean) Config.soundClickEnable.value) return; + if (!(Boolean) ConfigValues.soundClickEnable.value) return; if (!function.customSound_Enable) { - player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1); + player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1); return; } @@ -37,24 +37,24 @@ public class PlaySound { } catch (Exception e1) { T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) .replace("[sound]", "§6GUI: §e" + gui.key + " §6Function: §e" + function.key + "§r §6Slot: §e" + (slot.slot + 1) + " §6CustomSound: §9" + function.customSound_Sound)); - player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1); + player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1); } break; case NoMoney: - if (!(Boolean) Config.soundNoMoneyEnable.value) return; - player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundNoMoneyInput.value).toUpperCase().replace(".", "_")), 3, 1); + if (!(Boolean) ConfigValues.soundNoMoneyEnable.value) return; + player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundNoMoneyInput.value).toUpperCase().replace(".", "_")), 3, 1); break; case NoInventorySpace: - if (!(Boolean) Config.soundNoInventorySpaceEnable.value) return; - player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundNoInventorySpaceInput.value).toUpperCase().replace(".", "_")), 3, 1); + if (!(Boolean) ConfigValues.soundNoInventorySpaceEnable.value) return; + player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundNoInventorySpaceInput.value).toUpperCase().replace(".", "_")), 3, 1); break; case Give: - if (!(Boolean) Config.soundGiveEnable.value) return; - player.playSound(player.getLocation(),org.bukkit.Sound.valueOf(String.valueOf( Config.soundGiveInput.value).toUpperCase().replace(".", "_")), 3, 1); + if (!(Boolean) ConfigValues.soundGiveEnable.value) return; + player.playSound(player.getLocation(),org.bukkit.Sound.valueOf(String.valueOf( ConfigValues.soundGiveInput.value).toUpperCase().replace(".", "_")), 3, 1); break; case PlayerNotFound: - if (!(Boolean) Config.soundPlayerNotFoundEnable.value) return; - player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundPlayerNotFoundInput.value).toUpperCase().replace(".", "_")), 3, 1); + if (!(Boolean) ConfigValues.soundPlayerNotFoundEnable.value) return; + player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundPlayerNotFoundInput.value).toUpperCase().replace(".", "_")), 3, 1); break; } } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Load.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Load.java index ba5536e..5da784e 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Load.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Load.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.system; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect; import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5; import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions; @@ -129,12 +129,12 @@ public class Load { e.printStackTrace(); } try { - Config.sound(); + ConfigValues.sound(); } catch (Exception e) { e.printStackTrace(); } try { - CmdExecuter_GUI.arg1.put(String.valueOf(Config.adminSubCommand.value), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info); + CmdExecuter_GUI.arg1.put(String.valueOf(ConfigValues.adminSubCommand.value), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info); } catch (Exception e) { e.printStackTrace(); } @@ -155,7 +155,7 @@ public class Load { e.printStackTrace(); } - if ((Boolean) Config.helpAlias.value) { + if ((Boolean) ConfigValues.helpAlias.value) { Main.getPlugin().getCommand("commandguihelp").setExecutor(new CmdExecuter_Help()); T2Csend.debug(plugin, "CommandRegister: commandguihelp"); } @@ -180,7 +180,7 @@ public class Load { } T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord - , (Boolean) Config.updateCheckOnJoin.value, (Boolean) Config.updateCheckSeePreReleaseUpdates.value, (Integer) Config.updateCheckTimeInterval.value); + , (Boolean) ConfigValues.updateCheckOnJoin.value, (Boolean) ConfigValues.updateCheckSeePreReleaseUpdates.value, (Integer) ConfigValues.updateCheckTimeInterval.value); Metrics.Bstats(); Main.addonLoad(); T2Ctemplate.onLoadFooter(prefix, long_); @@ -188,9 +188,9 @@ public class Load { private static void loadStorage(String prefix) { try { - SelectDatabase.setStorage(StorageEnum.valueOf(String.valueOf(Config.storage.value))); + SelectDatabase.setStorage(StorageEnum.valueOf(String.valueOf(ConfigValues.storage.value))); } catch (Exception ignored) { - T2Csend.error(plugin, "The storage medium '" + Config.storage.value + "' is not supported!"); + T2Csend.error(plugin, "The storage medium '" + ConfigValues.storage.value + "' is not supported!"); T2Csend.error(plugin, "Storage medium " + StorageEnum.SQLITE + " is used."); SelectDatabase.setStorage(StorageEnum.SQLITE); } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Permissions.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Permissions.java index 4ee55b9..e0df48f 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Permissions.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Permissions.java @@ -3,6 +3,7 @@ package net.t2code.commandguiv2.Spigot.system; import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.objects.GuiObject; import net.t2code.commandguiv2.Spigot.objects.SlotObject; +import net.t2code.commandguiv2.cache.Cache; import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister; import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.Plugin; @@ -66,7 +67,7 @@ public class Permissions { T2Cregister.permissionDescription(admin, "All permissions from T2C-CommandGUI", plugin); - for (GuiObject gui : Main.guiHashMap.values()) { + for (GuiObject gui : Cache.guiHashMap.values()) { T2Cregister.permission(command + "." + gui.key, op, plugin); T2Cregister.permission(admin, op, command + "." + gui.key, true, plugin); for (SlotObject slot : gui.slots) { diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Placeholder.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Placeholder.java index 01fd919..3f2d372 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Placeholder.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/system/Placeholder.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.Spigot.system; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.function.useItem.Events; import org.bukkit.entity.Player; @@ -10,8 +10,8 @@ import java.util.List; public class Placeholder { public static String useitem(Player p) { if (Events.useItemHashMap.get(p.getName())) { - return Config.placeholderTrue.name(); - } else return Config.placeholderFalse.name(); + return ConfigValues.placeholderTrue.name(); + } else return ConfigValues.placeholderFalse.name(); } public static String useitem_boolean(Player p) { diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/api/CGuiAPI.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/api/CGuiAPI.java index b751e9f..5d76655 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/api/CGuiAPI.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/api/CGuiAPI.java @@ -1,6 +1,6 @@ package net.t2code.commandguiv2.api; -import net.t2code.commandguiv2.Spigot.config.config.Config; +import net.t2code.commandguiv2.Spigot.config.config.ConfigValues; import net.t2code.commandguiv2.Spigot.function.useItem.ItemChange; import net.t2code.commandguiv2.Spigot.function.useItem.Events; import net.t2code.commandguiv2.Spigot.Main; @@ -29,13 +29,13 @@ public class CGuiAPI { public static boolean hasUseItemInMainHand(Player player) { ItemStack item = player.getInventory().getItemInMainHand(); return item.hasItemMeta() && item.getItemMeta().hasDisplayName() - && item.getItemMeta().getDisplayName().equals(String.valueOf(Config.useItemName.value)); + && item.getItemMeta().getDisplayName().equals(String.valueOf(ConfigValues.useItemName.value)); } public static boolean hasUseItemInOffHand(Player player) { ItemStack item = player.getInventory().getItemInOffHand(); return item.hasItemMeta() && item.getItemMeta().hasDisplayName() - && item.getItemMeta().getDisplayName().equals(String.valueOf(Config.useItemName.value)); + && item.getItemMeta().getDisplayName().equals(String.valueOf(ConfigValues.useItemName.value)); } public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) { diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/cache/Cache.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/cache/Cache.java new file mode 100644 index 0000000..5fa531b --- /dev/null +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/cache/Cache.java @@ -0,0 +1,17 @@ +package net.t2code.commandguiv2.cache; + +import net.t2code.commandguiv2.Spigot.objects.FunctionObject; +import net.t2code.commandguiv2.Spigot.objects.GuiObject; +import net.t2code.commandguiv2.Spigot.objects.UseItemObject; +import net.t2code.commandguiv2.Spigot.objects.player.PlayerObject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; + +public class Cache { + public static HashMap guiHashMap = new HashMap<>(); + public static HashMap useItemHash = new HashMap<>(); + public static ArrayList allAliases = new ArrayList<>(); + public static HashMap functionHashMap = new HashMap<>(); +} diff --git a/CommandGUI V2/src/main/resources/UseItems/useItemDeclaration.yml b/CommandGUI V2/src/main/resources/UseItems/useItemDeclaration.yml index 4a33ef9..21af85b 100644 --- a/CommandGUI V2/src/main/resources/UseItems/useItemDeclaration.yml +++ b/CommandGUI V2/src/main/resources/UseItems/useItemDeclaration.yml @@ -1,201 +1,114 @@ useItem: - # Set here if the UseItem is to be used in use - enable: true - # Set here if players are allowed to enable or disable the UseItem with '/gui-item '. - # Permission 'commandgui.useitem.toggle' is additionally required - allowToggle: true - # Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item '. - # Permission 'commandgui.useitem.toggle' is additionally required - allowSetSlot: true - # Set here if the dropping of the UseItem should be blocked - blockMoveAndDrop: true - # Set here which GUI should open the UseItem + # enable: Set here if the UseItem is to be used in use + enable: false + + # openGUI: Set here which GUI should open the UseItem openGUI: default + + # allowToggle: Set here if players are allowed to enable or disable the UseItem with '/gui-item '. + allowToggle: true + + # allowSetSlot: Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item slot '. + allowSetSlot: true + + # blockMoveAndDrop: Set here if the dropping of the UseItem should be blocked + blockMoveAndDrop: true + permission: - # Set here if the permission 'commandgui.useitem' is required to use the UseItem - neededToUse: true - # Set here if the UseItem should stay in the inventory with the '/clear' command + become: + # Here you define if and which permission is needed to get the UseItem (for Join etc.). + needed: true + permission: 'commandgui.useitem.[useitemname].use' + # Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP] + default: TRUE + use: + # Here you define if and which permission is needed to use the UseItem + needed: true + permission: 'commandgui.useitem.[useitemname].use' + # Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP] + default: TRUE + toggle: + # Here you define if and which permission is needed to use the command '/gui-item ' for this UseItem + needed: true + permission: 'commandgui.useitem.[useitemname].toggle' + # Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP] + default: OP + setSlot: + # Here you define if and which permission is needed to use the command '/gui-item slot ' for this UseItem + needed: true + permission: 'commandgui.useitem.[useitemname].setslot' + # Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP] + default: OP + + # keepAtCommandClear: Set here if the UseItem should stay in the inventory with the '/clear' command keepAtCommandClear: true + inventorySlot: - # Set here on which slot the UseItem should be located by default + # slot: slot: Set here on which slot the UseItem should be located by default slot: 1 - # Set here if the slot should be forced even if another item is on this slot (also the set slot of the player). - # NOTE: The item that was on this slot before will be deleted. + # slotEnforce: Set here if the slot should be forced even if another item is on this slot (also the set slot of the player). + # NOTE: The item that was on this slot before will be deleted. slotEnforce: false - # Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied. + # freeSlot: Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied. freeSlot: false + # Set here the item that should be used as UseItem item: - # Set here which material should be used as UseItem + # material: Set here which material should be used as UseItem material: paper playerHead: - # Set here if a PlayerHead should be used as UseItem + # enable: This specifies whether a PlayerHead is to be used as a UseItem. If this is set to true, the 'material' option is ignored. enable: false base64: - # Set here if a Base64 PlayerHead should be used as UseItem + # enable: Set here if a Base64 PlayerHead should be used as UseItem enable: false - # Here you can set the Base64 Value. - # You can find the Base64 Value for example on https://minecraft-heads.com. + # base64Value: Here you can set the Base64 Value. + # You can find the Base64 Value for example on https://minecraft-heads.com. base64Value: '' - # Here you can set whether the player head should be used as a UseItem by the player + # playerWhoHasOpenedTheGUI: Here you can set whether the player head should be used as a UseItem by the player playerWhoHasOpenedTheGUI: false - # Here you can set a player name whose head should be used as UseItem + # playerName: Here you can set a player name whose head should be used as UseItem playerName: '' - # Set the DisplayName of the UseItem here + # name: Set the DisplayName of the UseItem here name: '&6GUI UseItem' - # Set the lore of the UseItem here + # lore: Set the lore of the UseItem here lore: - 'Lore line 1' - 'Lore line 2' + join: - # Set here if the UseItem should be given at every server join + # giveOnEveryJoin: Set here if the UseItem should be given at every server join giveOnEveryJoin: true - # Set here if the UseItem should only be given to the server at the first join of the player. + # giveOnlyOnFirstJoin: Set here if the UseItem should only be given to the server at the first join of the player. giveOnlyOnFirstJoin: false + quit: + # removeOnQuit: Set here if the UseItem should be removed from the inventory when leaving the server removeOnQuit: false + protection: gameMode: + # enable: Set here in which gamemode the UseItem may be used enable: false + # removeItemWhenItIsDisabled: Set here if the UseItem should be removed if you are in a not allowed Gamemode removeItemWhenItIsDisabled: false + # mode: Set here if a 'blacklist' or 'whitelist' should be used mode: blacklist + # list: Set the GameMode list here list: - CREATIVE - - Spectator + - SPECTATOR + world: + # enable: Set here in which world the UseItem may be used enable: false + # removeItemWhenItIsDisabled: Here you specify whether the UseItem should be removed if you are in a world that is not permitted removeItemWhenItIsDisabled: false + # mode: Set here if a 'blacklist' or 'whitelist' should be used mode: blacklist + # list: Set the worlds here list: - World1 - World2 -useItemSettings: - cursor: - toGUIItem: - useItem: default - onLogin: - # Here you define whether the UseItem should be selected when joining the server. - enable: true - spigot: - # Set here if the UseItem should only be selected at the first join - onOnlyFirstLogin: true - bungee: - # Set here if the UseItem should be selected even if you change the server of the bungee network. - # The option BungeeCord must be activated for this! - onServerChange: false - gameMode: - change: - enable: true - delayInTicks: 1 - world: - change: - enable: true - delayInTicks: 1 - disablePluginInfoBySneak: false - itemBlockBlacklist: - - CHEST - - CRAFTING_TABLE - - FURNACE - - OAK_FENCE - - SPRUCE_FENCE - - BIRCH_FENCE - - JUNGLE_FENCE - - ACACIA_FENCE - - DARK_OAK_FENCE - - MANGROVE_FENCE - - CRIMSON_FENCE - - WARPED_FENCE - - NETHER_BRICK_FENCE - - ENDER_CHEST - - BEACON - - ANVIL - - CHIPPED_ANVIL - - DAMAGED_ANVIL - - REPEATER - - COMPARATOR - - HOPPER - - DISPENSER - - DROPPER - - LEVER - - DAYLIGHT_DETECTOR - - TRAPPED_CHEST - - NOTE_BLOCK - - STONE_BUTTON - - POLISHED_BLACKSTONE_BUTTON - - OAK_BUTTON - - SPRUCE_BUTTON - - BIRCH_BUTTON - - JUNGLE_BUTTON - - ACACIA_BUTTON - - DARK_OAK_BUTTON - - MANGROVE_BUTTON - - CRIMSON_BUTTON - - WARPED_BUTTON - - IRON_DOOR - - OAK_DOOR - - SPRUCE_DOOR - - BIRCH_DOOR - - JUNGLE_DOOR - - ACACIA_DOOR - - DARK_OAK_DOOR - - MANGROVE_DOOR - - CRIMSON_DOOR - - WARPED_DOOR - - IRON_TRAPDOOR - - IRON_TRAPDOOR - - OAK_TRAPDOOR - - OAK_TRAPDOOR - - SPRUCE_TRAPDOOR - - SPRUCE_TRAPDOOR - - BIRCH_TRAPDOOR - - BIRCH_TRAPDOOR - - JUNGLE_TRAPDOOR - - JUNGLE_TRAPDOOR - - ACACIA_TRAPDOOR - - ACACIA_TRAPDOOR - - DARK_OAK_TRAPDOOR - - DARK_OAK_TRAPDOOR - - MANGROVE_TRAPDOOR - - MANGROVE_TRAPDOOR - - CRIMSON_TRAPDOOR - - CRIMSON_TRAPDOOR - - WARPED_TRAPDOOR - - WARPED_TRAPDOOR - - OAK_FENCE_GATE - - SPRUCE_FENCE_GATE - - BIRCH_FENCE_GATE - - JUNGLE_FENCE_GATE - - ACACIA_FENCE_GATE - - DARK_OAK_FENCE_GATE - - MANGROVE_FENCE_GATE - - CRIMSON_FENCE_GATE - - WARPED_FENCE_GATE - - CHEST_MINECART - - FURNACE_MINECART - - HOPPER_MINECART - - OAK_CHEST_BOAT - - SPRUCE_CHEST_BOAT - - BIRCH_CHEST_BOAT - - JUNGLE_CHEST_BOAT - - ACACIA_CHEST_BOAT - - DARK_OAK_CHEST_BOAT - - MANGROVE_CHEST_BOAT - - LEATHER_CHESTPLATE - - CHAINMAIL_CHESTPLATE - - IRON_CHESTPLATE - - DIAMOND_CHESTPLATE - - GOLDEN_CHESTPLATE - - NETHERITE_CHESTPLATE - - BREWING_STAND - - LOOM - - COMPOSTER - - BARREL - - SMOKER - - BLAST_FURNACE - - BLAST_FURNACE - - CARTOGRAPHY_TABLE - - FLETCHING_TABLE - - GRINDSTONE - - SMITHING_TABLE - - STONECUTTER \ No newline at end of file +#/useitem on/off/slot [slotnumber] diff --git a/CommandGUI V2/src/main/resources/configDeclaration.yml b/CommandGUI V2/src/main/resources/configDeclaration.yml index dad7f2a..4e3ffd1 100644 --- a/CommandGUI V2/src/main/resources/configDeclaration.yml +++ b/CommandGUI V2/src/main/resources/configDeclaration.yml @@ -33,133 +33,66 @@ storage: password: password ssl: false -useItem: - # Set here if the UseItem is to be used in use - enable: true - # Set here if players are allowed to enable or disable the UseItem with '/gui-item '. - # Permission 'commandgui.useitem.toggle' is additionally required - allowToggle: true - # Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item '. - # Permission 'commandgui.useitem.toggle' is additionally required - allowSetSlot: true - # Set here if the dropping of the UseItem should be blocked - blockMoveAndDrop: true - # Set here which GUI should open the UseItem - openGUI: default - permission: - # Set here if the permission 'commandgui.useitem' is required to use the UseItem - neededToUse: true - # Set here if the UseItem should stay in the inventory with the '/clear' command - keepAtCommandClear: true - inventorySlot: - # Set here on which slot the UseItem should be located by default - slot: 1 - # Set here if the slot should be forced even if another item is on this slot (also the set slot of the player). - # NOTE: The item that was on this slot before will be deleted. - slotEnforce: false - # Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied. - freeSlot: false - # Set here the item that should be used as UseItem - item: - # Set here which material should be used as UseItem - Material: paper - PlayerHead: - # Set here if a PlayerHead should be used as UseItem - Enable: false - Base64: - # Set here if a Base64 PlayerHead should be used as UseItem - Enable: false - # Here you can set the Base64 Value. - # You can find the Base64 Value for example on https://minecraft-heads.com. - Base64Value: '' - # Here you can set whether the player head should be used as a UseItem by the player - PlayerWhoHasOpenedTheGUI: false - # Here you can set a player name whose head should be used as UseItem - Playername: '' - # Set the DisplayName of the UseItem here - Name: '&6GUI UseItem' - # Set the lore of the UseItem here - Lore: - - 'Lore line 1' - - 'Lore line 2' - Join: - # Set here if the UseItem should be given at every server join - GiveOnEveryJoin: true - # Set here if the UseItem should only be given to the server at the first join of the player. - GiveOnlyOnFirstJoin: false - Cursor: - ToGUIItem: - OnLogin: - # Here you define whether the UseItem should be selected when joining the server. - Enable: true - Spigot: - # Set here if the UseItem should only be selected at the first join - OnOnlyFirstLogin: true - Bungee: - # Set here if the UseItem should be selected even if you change the server of the bungee network. - # The option BungeeCord must be activated for this! - OnServerChange: false - -Toggle: +toggle: # Set the items to be used with the Toggle function here - Items: + items: # Set here the item that should be used if you have the permission or the UseItem is active. - OnOrYes: - Item: - Base64: + onOrYes: + item: + base64: # Set here if a Base64 head should be used - Enable: false + enable: false # Here you can set the Base64 Value. # You can find the Base64 Value for example on https://minecraft-heads.com. - Base64Value: '' + base64Value: '' # Set the material to be used here - Material: GREEN_WOOL + material: GREEN_WOOL # Set here the item to be used if you have the permission or the UseItem is disabled - OffOrNo: - Item: - Base64: + offOrNo: + item: + base64: # Set here if a Base64 head should be used - Enable: false + enable: false # Here you can set the Base64 Value. # You can find the Base64 Value for example on https://minecraft-heads.com. - Base64Value: '' + base64Value: '' # Set the material to be used here - Material: RED_WOOL - Permission: + material: RED_WOOL + permission: # Set here the commands to be used for Toggle.Permission - Commands: - 'True': luckperms user [player] permission set [perm] true - 'False': luckperms user [player] permission set [perm] false + commands: + 'true': luckperms user [player] permission set [perm] true + 'false': luckperms user [player] permission set [perm] false # Set the design of the placeholders here -Placeholder: +placeholder: # Placeholder for true / enabled - 'True': '&2true' + 'true': '&2true' # Placeholder for false / disabled - 'False': '&4false' + 'false': '&4false' -Sound: +sound: # Here you can disable all sounds - Enable: true + enable: true # Set here At which action which sound should be played or none at all - OpenInventory: - Enable: true - Sound: BLOCK_CHEST_OPEN - Click: - Enable: true - Sound: BLOCK_NOTE_BLOCK_HAT - NoMoney: - Enable: true - Sound: BLOCK_NOTE_BLOCK_HARP - NoInventorySpace: - Enable: true - Sound: BLOCK_NOTE_BLOCK_HARP - Give: - Enable: true - Sound: ENTITY_PLAYER_LEVELUP - PlayerNotFound: - Enable: true - Sound: BLOCK_NOTE_BLOCK_HARP + openInventory: + enable: true + sound: BLOCK_CHEST_OPEN + click: + enable: true + sound: BLOCK_NOTE_BLOCK_HAT + noMoney: + enable: true + sound: BLOCK_NOTE_BLOCK_HARP + noInventorySpace: + enable: true + sound: BLOCK_NOTE_BLOCK_HARP + give: + enable: true + sound: ENTITY_PLAYER_LEVELUP + playerNotFound: + enable: true + sound: BLOCK_NOTE_BLOCK_HARP useItemSettings: cursor: @@ -176,20 +109,20 @@ useItemSettings: # Set here if the UseItem should be selected even if you change the server of the bungee network. # The option BungeeCord must be activated for this! onServerChange: false - GameMode: - Change: + gameMode: + change: # Set here if the UseItem should be reset when the GameMode is changed. - Enable: true + enable: true # Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second). - DelayInTicks: 1 - World: - Change: + delayInTicks: 1 + world: + change: # This specifies whether the UseItem should be reset when the world is changed. - Enable: true + enable: true # Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second). - DelayInTicks: 1 + delayInTicks: 1 # Set here for which blocks the UseItem is blocked and the function of the block you are looking at should be used. - ItemBlockBlacklist: + itemBlockBlacklist: - CHEST - CRAFTING_TABLE - FURNACE