From 7afbdd695c392a0fccc046c24f911d4ed469a039 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 6 Jan 2022 02:20:59 +0100 Subject: [PATCH 1/5] 2.5.18_DEV --- CommandGUI V2/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index b46da70..0a5e4d4 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.5.17 + 2.5.18_DEV jar CommandGUI @@ -81,7 +81,7 @@ net.t2code T2CodeLib - 9.0 + 8 net.t2code.minecraft.1_18.r1 From 8377667f5511080fdb225a0deb684cbcccff753b Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 6 Jan 2022 02:21:27 +0100 Subject: [PATCH 2/5] code changes --- .../src/main/Planned changes/default.yml | 86 ------- .../Spigot/Listener/GUI_Listener.java | 4 +- .../Spigot/Listener/ItemChange.java | 3 +- .../Spigot/Listener/PluginEvent.java | 2 +- .../Listener/UseItem_Listener/Events.java | 45 ++-- .../UseItem_Listener/Events_from1_10.java | 2 +- .../cmdManagement/CmdExecuter_Admin.java | 4 +- .../Spigot/cmdManagement/CmdExecuter_GUI.java | 4 +- .../cmdManagement/CmdExecuter_GUIItem.java | 4 +- .../Spigot/cmdManagement/Commands.java | 8 +- .../Spigot/cmdManagement/Help.java | 4 +- .../register/RegisterCommand.java | 4 +- .../{system => }/config/DefaultGUICreate.java | 2 +- .../Spigot/config/config/ConfigCreate.java | 152 ++++++++++++ .../config/config/SelectConfig.java | 41 ++-- .../config/languages/LanguagesCreate.java | 2 +- .../{system => }/config/languages/MSG.java | 2 +- .../config/languages/SelectMessages.java | 4 +- .../commandguiv2/Spigot/gui/OpenGUI.java | 4 +- .../Spigot/system/Give_UseItem.java | 2 +- .../commandguiv2/Spigot/system/Load.java | 11 +- .../commandguiv2/Spigot/system/Metrics.java | 2 +- .../system/config/config/ConfigCreate.java | 223 ------------------ .../system/database/Select_Database.java | 2 +- .../de/jatitv/commandguiv2/api/CGuiAPI.java | 7 +- 25 files changed, 241 insertions(+), 383 deletions(-) delete mode 100644 CommandGUI V2/src/main/Planned changes/default.yml rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{system => }/config/DefaultGUICreate.java (99%) create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{system => }/config/config/SelectConfig.java (90%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{system => }/config/languages/LanguagesCreate.java (99%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{system => }/config/languages/MSG.java (99%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{system => }/config/languages/SelectMessages.java (97%) delete mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/ConfigCreate.java diff --git a/CommandGUI V2/src/main/Planned changes/default.yml b/CommandGUI V2/src/main/Planned changes/default.yml deleted file mode 100644 index d3bb11d..0000000 --- a/CommandGUI V2/src/main/Planned changes/default.yml +++ /dev/null @@ -1,86 +0,0 @@ -GUI: - Enable: true - Lines: 1 - Name: '&5default &9GUI' - FillItem: - Enable: true - Item: BLACK_STAINED_GLASS_PANE -Command: - Alias: true - Permission: - Required: true -Slots: - Example: - Slot: 5 - Enable: true - Item: - Empty: false - Amount: 1 - PlayerHead: - Enable: true - Base64: - Enable: true - Base64Value: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19 - PlayerWhoHasOpenedTheGUI: false - PlayerName: '' - Material: '' - Name: '&3Support Discord' - Lore: - - '&8-----------------' - - '&bIf you need help setting up the plugin,' - - '&bfeel free to contact me on the Suport Discord.' - - '&8-----------------' - - '&eIf you find any errors or bugs,' - - '&eplease contact me so I can fix them.' - - '&8-----------------' - - '&5Discord: §7https://discord.gg/vRyXFFterJ' - CustomSound: - Enable: false - NoSound: false - Sound: '' - Cost: - Enable: false - Price: 0.0 - Command: - Enable: false - BungeeCommand: false - CommandAsConsole: false - Command: - - '' - OpenGUI: - Enable: false - GUI: '' - Message: - Enable: true - Message: - - '&6You can find more information on Discord: &ehttps://discord.gg/vRyXFFterJ' - Permission: - Required: false - ServerChange: - Enable: false - Server: '' - SetConfig: - Enable: false - File: - Path: '' - Option: - Path: '' - Premat: String - Value: - LeftClick: - ChatInput: false - String: '' - Boolean: false - Integer: 0 - Double: 0.0 - List: [] - RightClick: - ChatInput: false - String: '' - Boolean: false - Integer: 0 - Double: 0.0 - List: [] - PluginReload: - Enable: false - Command: '' \ No newline at end of file diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java index 91a4076..25c9d63 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java @@ -2,10 +2,10 @@ package de.jatitv.commandguiv2.Spigot.Listener; import de.jatitv.commandguiv2.Spigot.Objekte.Slot; import de.jatitv.commandguiv2.Spigot.system.Bungee_Sender_Reciver; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.Objekte.Object; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java index d832a36..69dfef8 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java @@ -2,10 +2,9 @@ package de.jatitv.commandguiv2.Spigot.Listener; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.system.Give_UseItem; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; import net.t2code.lib.Spigot.Lib.items.ItemVersion; -import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java index 6366dca..1929c14 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java @@ -3,7 +3,7 @@ package de.jatitv.commandguiv2.Spigot.Listener; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java index b30e689..c6d4b5e 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java @@ -3,13 +3,12 @@ package de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener; import de.jatitv.commandguiv2.Spigot.Listener.ItemChange; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.api.CGuiAPI; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; -import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -103,26 +102,34 @@ public class Events implements Listener { new BukkitRunnable() { @Override public void run() { - if (SelectConfig.UseItemGameModeChangeDisableInSpectator) { - if (player.getGameMode() != GameMode.SPECTATOR) { - ItemChange.itemChange(player); + if (SelectConfig.UseItemGameModeChangeEnable) { + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { + removeItem(player); return; } - for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { - ItemStack itm = player.getInventory().getItem(iam); - if (itm != null) { - if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) { - if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { - player.getInventory().remove(itm); - player.updateInventory(); - break; - } - } - } + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { + removeItem(player); + return; } - } else ItemChange.itemChange(player); + ItemChange.itemChange(player); + } } - }.runTaskLater(Main.plugin, 1L); + }.runTaskLater(Main.plugin, SelectConfig.UseItemGameModeChangeDelayInTicks * 1L); + } + + private static void removeItem(Player player) { + for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { + ItemStack itm = player.getInventory().getItem(iam); + if (itm != null) { + if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) { + if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { + player.getInventory().remove(itm); + player.updateInventory(); + break; + } + } + } + } } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events_from1_10.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events_from1_10.java index 47f0e80..313609d 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events_from1_10.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events_from1_10.java @@ -1,6 +1,6 @@ package de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_Admin.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_Admin.java index 4462f64..da237c2 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_Admin.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_Admin.java @@ -1,8 +1,8 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; import de.jatitv.commandguiv2.Spigot.system.Debug; -import de.jatitv.commandguiv2.Spigot.system.config.DefaultGUICreate; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Util; import org.bukkit.Bukkit; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java index ec8228f..71115ee 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java @@ -2,8 +2,8 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.system.Debug; -import de.jatitv.commandguiv2.Spigot.system.config.DefaultGUICreate; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.commands.Tab; import org.bukkit.Bukkit; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java index 0cd6054..f94abd8 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUIItem.java @@ -1,7 +1,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.command.Command; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Commands.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Commands.java index 0a4a57e..1933b53 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Commands.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Commands.java @@ -6,10 +6,10 @@ import de.jatitv.commandguiv2.Spigot.Objekte.Object; import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.system.Give_UseItem; -import de.jatitv.commandguiv2.Spigot.system.config.config.ConfigCreate; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; -import de.jatitv.commandguiv2.Spigot.system.config.languages.LanguagesCreate; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Help.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Help.java index 05353ad..2748c9c 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Help.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/Help.java @@ -1,9 +1,9 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Objekte.Object; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.replace.Replace; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java index 5e1f00a..55fedd5 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/RegisterCommand.java @@ -4,8 +4,8 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Objekte.Object; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/DefaultGUICreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java similarity index 99% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/DefaultGUICreate.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java index ebd9cc7..5ae684f 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/DefaultGUICreate.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java @@ -1,4 +1,4 @@ -package de.jatitv.commandguiv2.Spigot.system.config; +package de.jatitv.commandguiv2.Spigot.config; import de.jatitv.commandguiv2.Spigot.Main; import net.t2code.lib.Spigot.Lib.messages.send; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java new file mode 100644 index 0000000..3be236d --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java @@ -0,0 +1,152 @@ +package de.jatitv.commandguiv2.Spigot.config.config; + +import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Util; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; +import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; + + +public class ConfigCreate { + + public static Integer ConfigVersion = 3; + + public static void configCreate() { + Long long_ = Long.valueOf(System.currentTimeMillis()); + if (new File(Main.getPath(), "config.yml").exists()) { + if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated..."); + } else send.console(Main.prefix + " §4config.yml are created..."); + + File config = new File(Main.getPath(), "config.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + if (yamlConfiguration.getInt("ConfigVersion") < ConfigVersion) { + send.console(Util.getPrefix() +" §4----------------------"); + send.console(Util.getPrefix() +" "); + send.console(Util.getPrefix() +" §6New features have been added to CommandGUI. The Config is adapted!"); + send.console(Util.getPrefix() +" "); + send.console(Util.getPrefix() +" §4----------------------"); + } + + yamlConfiguration.set("ConfigVersion", ConfigVersion); + + Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration); + Config.set("Plugin.Debug", false, yamlConfiguration); + Config.set("Plugin.HelpAlias", true, yamlConfiguration); + Config.set("Plugin.language", "english", yamlConfiguration); + Config.set("Plugin.Currency", "$", yamlConfiguration); + Config.set("Plugin.DefaultGUI", "default", yamlConfiguration); + + Config.set("Storage.Type", "YML", yamlConfiguration); + Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration); + Config.set("Storage.MySQL.Port", 3306, yamlConfiguration); + Config.set("Storage.MySQL.Database", "database", yamlConfiguration); + Config.set("Storage.MySQL.User", "root", yamlConfiguration); + Config.set("Storage.MySQL.Password", "password", yamlConfiguration); + Config.set("Storage.MySQL.SSL", false, yamlConfiguration); + + Config.set("BungeeCord.Enable", false, yamlConfiguration); + Config.set("BungeeCord.ThisServer", "server", yamlConfiguration); + + Config.set("UseItem.Enable", true, yamlConfiguration); + Config.set("UseItem.AllowToggle", true, yamlConfiguration); + Config.set("UseItem.AllowSetSlot", true, yamlConfiguration); + Config.set("UseItem.BlockMoveAndDrop", true, yamlConfiguration); + Config.set("UseItem.OpenGUI", "default", yamlConfiguration); + Config.set("UseItem.Permission.NeededToUse", true, yamlConfiguration); + Config.set("UseItem.KeepAtCommandClear", true, yamlConfiguration); + + Config.set("UseItem.InventorySlot.Slot", 1, yamlConfiguration); + Config.set("UseItem.InventorySlot.SlotEnforce", false, yamlConfiguration); + Config.set("UseItem.InventorySlot.FreeSlot", false, yamlConfiguration); + + Config.set("UseItem.Item.Material", "paper", yamlConfiguration); + if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { + Config.set("UseItem.Item.PlayerHead.Enable", false, yamlConfiguration); + Config.set("UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration); + Config.set("UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration); + Config.set("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration); + Config.set("UseItem.Item.PlayerHead.Playername", "", yamlConfiguration); + } + Config.set("UseItem.Item.Name", "&bDefault &6GUI", yamlConfiguration); + Config.set("UseItem.Item.Lore", Arrays.asList("&eThis is an example GUI"), yamlConfiguration); + Config.set("UseItem.Join.GiveOnEveryJoin", true, yamlConfiguration); + Config.set("UseItem.Join.GiveOnlyOnFirstJoin", false, yamlConfiguration); + + //convert + if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")) { + Config.set("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration); + Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration); + } + if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")) { + Config.set("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin", yamlConfiguration); + Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin"), yamlConfiguration); + } + if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange")) { + Config.set("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange", yamlConfiguration); + Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange"), yamlConfiguration); + } + + Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", true, yamlConfiguration); + Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration); + Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration); + + Config.set("Advanced.UseItem.GameModeChange.Enable", true, yamlConfiguration); + Config.set("Advanced.UseItem.GameModeChange.DelayInTicks", 1, yamlConfiguration); + Config.set("Advanced.UseItem.GameModeChange.Protection.Enable", false, yamlConfiguration); + Config.set("Advanced.UseItem.GameModeChange.Protection.Mode", "blacklist", yamlConfiguration); + Config.set("Advanced.UseItem.GameModeChange.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration); + + Config.set("Sound.Enable", true, yamlConfiguration); + + Config.set("Sound.OpenInventory.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8) { + Config.set("Sound.OpenInventory.Sound", "CHEST_OPEN", yamlConfiguration); + } else Config.set("Sound.OpenInventory.Sound", "BLOCK_CHEST_OPEN", yamlConfiguration); + + Config.set("Sound.Click.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8) { + Config.set("Sound.Click.Sound", "NOTE_STICKS", yamlConfiguration); + } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + Config.set("Sound.Click.Sound", "BLOCK_NOTE_HAT", yamlConfiguration); + } else Config.set("Sound.Click.Sound", "BLOCK_NOTE_BLOCK_HAT", yamlConfiguration); + + Config.set("Sound.NoMoney.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8) { + Config.set("Sound.NoMoney.Sound", "NOTE_PIANO", yamlConfiguration); + } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + Config.set("Sound.NoMoney.Sound", "BLOCK_NOTE_HARP", yamlConfiguration); + } else Config.set("Sound.NoMoney.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration); + + Config.set("Sound.NoInventorySpace.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8) { + Config.set("Sound.NoInventorySpace.Sound", "NOTE_PIANO", yamlConfiguration); + } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + Config.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_HARP", yamlConfiguration); + } else Config.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration); + + Config.set("Sound.Give.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8) { + Config.set("Sound.Give.Sound", "LEVEL_UP", yamlConfiguration); + } else Config.set("Sound.Give.Sound", "ENTITY_PLAYER_LEVELUP", yamlConfiguration); + + Config.set("Sound.PlayerNotFound.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8) { + Config.set("Sound.PlayerNotFound.Sound", "NOTE_PIANO", yamlConfiguration); + } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration); + } else Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration); + + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + } +} diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/SelectConfig.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java similarity index 90% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/SelectConfig.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java index 48a5e44..564ca73 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/SelectConfig.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java @@ -1,7 +1,7 @@ -package de.jatitv.commandguiv2.Spigot.system.config.config; +package de.jatitv.commandguiv2.Spigot.config.config; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.MySQL; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; @@ -42,8 +42,14 @@ public class SelectConfig { public static Boolean UseItem_Permission; public static Boolean UseItem_KeepAtCommandClear; + + + public static Boolean UseItemGameModeChangeEnable; public static int UseItemGameModeChangeDelayInTicks; - public static Boolean UseItemGameModeChangeDisableInSpectator; + public static Boolean UseItemGameModeProtection; + public static String UseItemGameModeMode; + public static List UseItemGameModeList; + public static Boolean UseItem_InventorySlot_FreeSlot; public static Integer UseItem_InventorySlot; @@ -55,7 +61,9 @@ public class SelectConfig { public static Boolean UseItem_PlayerWhoHasOpenedTheGUI; public static String UseItem_PlayerName; public static String UseItem_Name; - public static List UseItem_Lore; + public static List UseItem_Lore; + + public static Boolean Sound_Enable = true; @@ -130,15 +138,19 @@ public class SelectConfig { UseItem_PlayerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI"); UseItem_PlayerName = yamlConfiguration.getString("UseItem.Item.PlayerHead.PlayerName"); UseItem_Name = Replace.replace(Util.getPrefix(),yamlConfiguration.getString("UseItem.Item.Name")); - UseItem_Lore = yamlConfiguration.getList("UseItem.Item.Lore"); + UseItem_Lore = yamlConfiguration.getStringList("UseItem.Item.Lore"); UseItem_GiveOnEveryJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnEveryJoin"); UseItem_GiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnlyOnFirstJoin"); Cursor_ToGUIItem_OnLogin = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable"); Cursor_ToGUIItem_OnlyOnFirstLogin = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin"); UseItem_ServerChange = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange"); + UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.Enable"); UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameModeChange.DelayInTicks"); - UseItemGameModeChangeDisableInSpectator = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.DisableInSpectator"); + UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.Protection.Enable"); + UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameModeChange.Protection.Mode"); + UseItemGameModeList = yamlConfiguration.getStringList("Advanced.UseItem.GameModeChange.Protection.List"); + Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable"); Sound_OpenInventory_Enable = yamlConfiguration.getBoolean("Sound.OpenInventory.Enable"); @@ -157,30 +169,31 @@ public class SelectConfig { } + public static void sound(String Prefix) { String soundOpenInventory; if (MCVersion.minecraft1_8) { - soundOpenInventory = ConfigCreate.Sound_OpenInventory_1_8; + soundOpenInventory = "CHEST_OPEN"; } else { - soundOpenInventory = ConfigCreate.Sound_OpenInventory_ab_1_9; + soundOpenInventory = "BLOCK_CHEST_OPEN"; } String soundClick; if (MCVersion.minecraft1_8) { - soundClick = ConfigCreate.Sound_Click_1_8; + soundClick = "NOTE_STICKS"; } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - soundClick = ConfigCreate.Sound_Click_1_9_bis_1_12; + soundClick = "BLOCK_NOTE_HAT"; } else { - soundClick = ConfigCreate.Sound_Click_ab_1_13; + soundClick = "BLOCK_NOTE_BLOCK_HAT"; } String soundNoMoney; if (MCVersion.minecraft1_8) { - soundNoMoney = ConfigCreate.Sound_NoMoney_1_8; + soundNoMoney = "NOTE_PIANO"; } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - soundNoMoney = ConfigCreate.Sound_NoMoney_1_9_bis_1_12; + soundNoMoney = "BLOCK_NOTE_HARP"; } else { - soundNoMoney = ConfigCreate.Sound_NoMoney_ab_1_13; + soundNoMoney = "BLOCK_NOTE_BLOCK_HARP"; } String soundNoInventorySpace; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/LanguagesCreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/LanguagesCreate.java similarity index 99% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/LanguagesCreate.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/LanguagesCreate.java index 54754c7..78edf84 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/LanguagesCreate.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/LanguagesCreate.java @@ -1,4 +1,4 @@ -package de.jatitv.commandguiv2.Spigot.system.config.languages; +package de.jatitv.commandguiv2.Spigot.config.languages; import de.jatitv.commandguiv2.Spigot.Main; import net.t2code.lib.Spigot.Lib.messages.send; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/MSG.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/MSG.java similarity index 99% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/MSG.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/MSG.java index 6670f5f..37fd49b 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/MSG.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/MSG.java @@ -9,7 +9,7 @@ // \_____\_____|\____/|_____| // ----------------------------- -package de.jatitv.commandguiv2.Spigot.system.config.languages; +package de.jatitv.commandguiv2.Spigot.config.languages; public class MSG { diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/SelectMessages.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/SelectMessages.java similarity index 97% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/SelectMessages.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/SelectMessages.java index 5d36050..11e38aa 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/languages/SelectMessages.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/languages/SelectMessages.java @@ -1,7 +1,7 @@ -package de.jatitv.commandguiv2.Spigot.system.config.languages; +package de.jatitv.commandguiv2.Spigot.config.languages; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.replace.Replace; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java index 58ea9ad..e55334f 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java @@ -5,9 +5,9 @@ import com.mojang.authlib.properties.Property; import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Objekte.Slot; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.Objekte.Object; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import io.github.solyze.plugmangui.inventories.PluginListGUI; import net.t2code.lib.Spigot.Lib.items.ItemVersion; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Give_UseItem.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Give_UseItem.java index cdb0213..9987e70 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Give_UseItem.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Give_UseItem.java @@ -3,7 +3,7 @@ package de.jatitv.commandguiv2.Spigot.system; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Load.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Load.java index de9e984..2a1ccf8 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Load.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Load.java @@ -2,21 +2,20 @@ package de.jatitv.commandguiv2.Spigot.system; import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events_from1_10; -import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Admin; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help; import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister; -import de.jatitv.commandguiv2.Spigot.system.config.DefaultGUICreate; -import de.jatitv.commandguiv2.Spigot.system.config.languages.LanguagesCreate; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.MySQL; import de.jatitv.commandguiv2.Spigot.Listener.PluginEvent; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Objekte.Obj_Select; -import de.jatitv.commandguiv2.Spigot.system.config.config.ConfigCreate; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Metrics.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Metrics.java index c37a758..f6f62c3 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Metrics.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Metrics.java @@ -4,7 +4,7 @@ package de.jatitv.commandguiv2.Spigot.system; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/ConfigCreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/ConfigCreate.java deleted file mode 100644 index 9961b14..0000000 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/config/config/ConfigCreate.java +++ /dev/null @@ -1,223 +0,0 @@ -package de.jatitv.commandguiv2.Spigot.system.config.config; - -import de.jatitv.commandguiv2.Spigot.Main; -import net.t2code.lib.Spigot.Lib.messages.send; -import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; -import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - - -public class ConfigCreate { - - public static Integer ConfigVersion = 2; - - private static Boolean UpdateCheckOnJoin = true; - private static Boolean Debug = false; - private static Boolean HelpAlias = true; - private static String language = "english"; - private static String Currency = "$"; - private static String DefaultGUI = "default"; - - - private static String Storage = "YML"; - private static String ip = "localhost"; - private static Integer port = 3306; - private static String database = "database"; - private static String user = "root"; - private static String password = "password"; - private static Boolean SSL = false; - - private static Boolean Bungee = false; - private static String thisServer = "server"; - - - private static Boolean UseItem_Enable = true; - private static Boolean UseItem_AllowToggle = true; - private static Boolean UseItem_AllowSetSlot = true; - private static Boolean UseItem_BlockMoveAndDrop = true; - private static String UseItem_OpenGUI = "default"; - private static Boolean UseItem_Permission = true; - private static Boolean UseItem_KeepAtCommandClear = true; - - private static Integer UseItem_InventorySlot = 1; - private static Boolean UseItem_InventorySlotEnforce = false; - private static Boolean UseItem_InventorySlot_FreeSlot = false; - private static String UseItem_Material = "paper"; - private static Boolean UseItem_PlayerHead_Enable = false; - private static Boolean base64_Enable = false; - private static String base64value= ""; - private static Boolean UseItem_PlayerWhoHasOpenedTheGUI = false; - private static String UseItem_PlayerName = ""; - private static String UseItem_Name = "&bDefault &6GUI"; - private static List UseItem_Lore = Arrays.asList("&eThis is an example GUI"); - private static Boolean UseItem_GiveOnEveryJoin = true; - private static Boolean UseItem_GiveOnlyOnFirstJoin = false; - private static Boolean Cursor_ToGUIItem_OnLogin = true; - private static Boolean Cursor_ToGUIItem_OnlyOnFirstLogin = true; - private static Boolean Cursor_ServerChange_EXPERIMENTELL = false; - - private static int UseItemGameModeChangeDelayInTicks = 1; - private static boolean UseItemGameModeChangeDisableInSpectator = true; - - private static Boolean Sound_Enable = true; - - private static Boolean Sound_OpenInventory_Enable = true; - public static String Sound_OpenInventory_1_8 = "CHEST_OPEN"; - public static String Sound_OpenInventory_ab_1_9 = "BLOCK_CHEST_OPEN"; - - private static Boolean Sound_Click_Enable = true; - public static String Sound_Click_1_8 = "NOTE_STICKS"; - public static String Sound_Click_1_9_bis_1_12 = "BLOCK_NOTE_HAT"; - public static String Sound_Click_ab_1_13 = "BLOCK_NOTE_BLOCK_HAT"; - - private static Boolean Sound_NoMoney_Enable = true; - public static String Sound_NoMoney_1_8 = "NOTE_PIANO"; - public static String Sound_NoMoney_1_9_bis_1_12 = "BLOCK_NOTE_HARP"; - public static String Sound_NoMoney_ab_1_13 = "BLOCK_NOTE_BLOCK_HARP"; - - private static Boolean Sound_NoInventorySpace_Enable = true; - public static String Sound_NoInventorySpace_1_8 = "NOTE_PIANO"; - public static String Sound_NoInventorySpace_1_9_bis_1_12 = "BLOCK_NOTE_HARP"; - public static String Sound_NoInventorySpace_ab_1_13 = "BLOCK_NOTE_BLOCK_HARP"; - - private static Boolean Sound_Give_Enable = true; - public static String Sound_Give_1_8 = "LEVEL_UP"; - public static String Sound_Give_ab_1_9 = "ENTITY_PLAYER_LEVELUP"; - - private static Boolean Sound_PlayerNotFound_Enable = true; - public static String Sound_PlayerNotFound_1_8 = "NOTE_PIANO"; - public static String Sound_PlayerNotFound_1_9_bis_1_12 = "BLOCK_NOTE_HARP"; - public static String Sound_PlayerNotFound_ab_1_13 = "BLOCK_NOTE_BLOCK_HARP"; - - - public static void configCreate() { - Long long_ = Long.valueOf(System.currentTimeMillis()); - if (new File(Main.getPath(), "config.yml").exists()){ - if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated..."); - } else send.console(Main.prefix + " §4config.yml are created..."); - - - File config = new File(Main.getPath(), "config.yml"); - YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - - yamlConfiguration.set("ConfigVersion", ConfigVersion); - - Config.set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration); - Config.set("Plugin.Debug", Debug, yamlConfiguration); - Config.set("Plugin.HelpAlias", HelpAlias, yamlConfiguration); - Config.set("Plugin.language", language, yamlConfiguration); - Config.set("Plugin.Currency", Currency, yamlConfiguration); - Config.set("Plugin.DefaultGUI", DefaultGUI, yamlConfiguration); - - Config.set("Storage.Type", Storage, yamlConfiguration); - Config.set("Storage.MySQL.IP", ip, yamlConfiguration); - Config.set("Storage.MySQL.Port", port, yamlConfiguration); - Config.set("Storage.MySQL.Database", database, yamlConfiguration); - Config.set("Storage.MySQL.User", user, yamlConfiguration); - Config.set("Storage.MySQL.Password", password, yamlConfiguration); - Config.set("Storage.MySQL.SSL", SSL, yamlConfiguration); - - Config.set("BungeeCord.Enable", Bungee, yamlConfiguration); - Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration); - - Config.set("UseItem.Enable", UseItem_Enable, yamlConfiguration); - Config.set("UseItem.AllowToggle", UseItem_AllowToggle, yamlConfiguration); - Config.set("UseItem.AllowSetSlot", UseItem_AllowSetSlot, yamlConfiguration); - Config.set("UseItem.BlockMoveAndDrop", UseItem_BlockMoveAndDrop, yamlConfiguration); - Config.set("UseItem.OpenGUI", UseItem_OpenGUI, yamlConfiguration); - Config.set("UseItem.Permission.NeededToUse", UseItem_Permission, yamlConfiguration); - Config.set("UseItem.KeepAtCommandClear", UseItem_KeepAtCommandClear, yamlConfiguration); - - Config.set("UseItem.InventorySlot.Slot", UseItem_InventorySlot, yamlConfiguration); - Config.set("UseItem.InventorySlot.SlotEnforce", UseItem_InventorySlotEnforce, yamlConfiguration); - Config.set("UseItem.InventorySlot.FreeSlot", UseItem_InventorySlot_FreeSlot, yamlConfiguration); - - Config.set("UseItem.Item.Material", UseItem_Material, yamlConfiguration); - if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { - Config.set("UseItem.Item.PlayerHead.Enable", UseItem_PlayerHead_Enable, yamlConfiguration); - Config.set("UseItem.Item.PlayerHead.Base64.Enable", base64_Enable, yamlConfiguration); - Config.set("UseItem.Item.PlayerHead.Base64.Base64Value", base64value, yamlConfiguration); - Config.set("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", UseItem_PlayerWhoHasOpenedTheGUI, yamlConfiguration); - Config.set("UseItem.Item.PlayerHead.Playername", UseItem_PlayerName, yamlConfiguration); - } - Config.set("UseItem.Item.Name", UseItem_Name, yamlConfiguration); - Config.set("UseItem.Item.Lore", UseItem_Lore, yamlConfiguration); - Config.set("UseItem.Join.GiveOnEveryJoin", UseItem_GiveOnEveryJoin, yamlConfiguration); - Config.set("UseItem.Join.GiveOnlyOnFirstJoin", UseItem_GiveOnlyOnFirstJoin, yamlConfiguration); - - //convert - if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")){ - Config.set("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration); - Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration); - } - if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")){ - Config.set("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin", yamlConfiguration); - Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin"), yamlConfiguration); - } - if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange")){ - Config.set("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange", yamlConfiguration); - Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange"), yamlConfiguration); - } - - Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", Cursor_ToGUIItem_OnLogin, yamlConfiguration); - Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", Cursor_ToGUIItem_OnlyOnFirstLogin, yamlConfiguration); - Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", Cursor_ServerChange_EXPERIMENTELL, yamlConfiguration); - - Config.set("Advanced.UseItem.GameModeChange.DelayInTicks", UseItemGameModeChangeDelayInTicks, yamlConfiguration); - Config.set("Advanced.UseItem.GameModeChange.DisableInSpectator", UseItemGameModeChangeDisableInSpectator, yamlConfiguration); - - Config.set("Sound.Enable", Sound_Enable, yamlConfiguration); - - Config.set("Sound.OpenInventory.Enable", Sound_OpenInventory_Enable, yamlConfiguration); - if (MCVersion.minecraft1_8) { - Config.set("Sound.OpenInventory.Sound", Sound_OpenInventory_1_8, yamlConfiguration); - } else Config.set("Sound.OpenInventory.Sound", Sound_OpenInventory_ab_1_9, yamlConfiguration); - - Config.set("Sound.Click.Enable", Sound_Click_Enable, yamlConfiguration); - if (MCVersion.minecraft1_8) { - Config.set("Sound.Click.Sound", Sound_Click_1_8, yamlConfiguration); - } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - Config.set("Sound.Click.Sound", Sound_Click_1_9_bis_1_12, yamlConfiguration); - } else Config.set("Sound.Click.Sound", Sound_Click_ab_1_13, yamlConfiguration); - - Config.set("Sound.NoMoney.Enable", Sound_NoMoney_Enable, yamlConfiguration); - if (MCVersion.minecraft1_8) { - Config.set("Sound.NoMoney.Sound", Sound_NoMoney_1_8, yamlConfiguration); - } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - Config.set("Sound.NoMoney.Sound", Sound_NoMoney_1_9_bis_1_12, yamlConfiguration); - } else Config.set("Sound.NoMoney.Sound", Sound_NoMoney_ab_1_13, yamlConfiguration); - - Config.set("Sound.NoInventorySpace.Enable", Sound_NoInventorySpace_Enable, yamlConfiguration); - if (MCVersion.minecraft1_8) { - Config.set("Sound.NoInventorySpace.Sound", Sound_NoInventorySpace_1_8, yamlConfiguration); - } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - Config.set("Sound.NoInventorySpace.Sound", Sound_NoInventorySpace_1_9_bis_1_12, yamlConfiguration); - } else Config.set("Sound.NoInventorySpace.Sound", Sound_NoInventorySpace_ab_1_13, yamlConfiguration); - - Config.set("Sound.Give.Enable", Sound_Give_Enable, yamlConfiguration); - if (MCVersion.minecraft1_8) { - Config.set("Sound.Give.Sound", Sound_Give_1_8, yamlConfiguration); - } else Config.set("Sound.Give.Sound", Sound_Give_ab_1_9, yamlConfiguration); - - Config.set("Sound.PlayerNotFound.Enable", Sound_PlayerNotFound_Enable, yamlConfiguration); - if (MCVersion.minecraft1_8) { - Config.set("Sound.PlayerNotFound.Sound", Sound_PlayerNotFound_1_8, yamlConfiguration); - } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - Config.set("Sound.PlayerNotFound.Sound", Sound_PlayerNotFound_1_9_bis_1_12, yamlConfiguration); - } else Config.set("Sound.PlayerNotFound.Sound", Sound_PlayerNotFound_ab_1_13, yamlConfiguration); - - try { - yamlConfiguration.save(config); - } catch (IOException e) { - e.printStackTrace(); - } - - send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); - - } -} diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/Select_Database.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/Select_Database.java index 43b3d35..25e890a 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/Select_Database.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/Select_Database.java @@ -1,6 +1,6 @@ package de.jatitv.commandguiv2.Spigot.system.database; -import de.jatitv.commandguiv2.Spigot.system.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import org.bukkit.entity.Player; public class Select_Database { diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java index 3c01ad3..d711e87 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java @@ -1,15 +1,12 @@ package de.jatitv.commandguiv2.api; import de.jatitv.commandguiv2.Spigot.Listener.ItemChange; -import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events_from1_10; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands; import de.jatitv.commandguiv2.Spigot.cmdManagement.Help; -import de.jatitv.commandguiv2.Spigot.system.config.DefaultGUICreate; -import de.jatitv.commandguiv2.Spigot.system.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; -import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; -import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; From 75ab60bbaa57c923284e93eea8e8c3a9dd0955d8 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 6 Jan 2022 03:04:56 +0100 Subject: [PATCH 3/5] Changes - If the option Join.Cursor.ToGUIItem.OnLogin was set to true the cursor was set to the UseItem even if the GameMode was changed, this was fixed. - Protection was completed --- .../de/jatitv/commandguiv2/Bungee/BMain.java | 2 - .../Spigot/Listener/ItemChange.java | 124 +++++++++++------- .../Spigot/Listener/PluginEvent.java | 2 +- .../Listener/UseItem_Listener/Events.java | 37 ++---- .../Spigot/config/config/ConfigCreate.java | 10 +- .../Spigot/config/config/SelectConfig.java | 16 ++- .../de/jatitv/commandguiv2/api/CGuiAPI.java | 5 +- 7 files changed, 104 insertions(+), 92 deletions(-) diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Bungee/BMain.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Bungee/BMain.java index bdae350..a61693d 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Bungee/BMain.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Bungee/BMain.java @@ -5,7 +5,6 @@ import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Plugin; import net.t2code.lib.Bungee.Lib.messages.Bsend; -import java.util.Objects; import java.util.logging.Level; public final class BMain extends Plugin { @@ -86,7 +85,6 @@ public final class BMain extends Plugin { } public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { - if (ProxyServer.getInstance().getPluginManager().getPlugin(pl) == null) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); ProxyServer.getInstance().getConsole().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " + diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java index 69dfef8..5ad4cec 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ItemChange.java @@ -11,9 +11,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; public class ItemChange { - public static void itemChange(Player player) { + public static void itemChange(Player player, Boolean setCursor) { Integer slot; - if (SelectConfig.UseItem_InventorySlotEnforce){ + if (SelectConfig.UseItem_InventorySlotEnforce) { slot = SelectConfig.UseItem_InventorySlot; } else { if (Select_Database.selectSlot(player) == null) { @@ -26,6 +26,16 @@ public class ItemChange { if (!SelectConfig.UseItem_Enable) { return; } + if (SelectConfig.UseItemGameModeProtection) { + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { + removeItem(player); + return; + } + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { + removeItem(player); + return; + } + } if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) { if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { if (!player.hasPlayedBefore()) { @@ -42,58 +52,74 @@ public class ItemChange { } return; } - if (SelectConfig.UseItem_GiveOnEveryJoin) { - new BukkitRunnable() { - @Override - public void run() { - for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { - ItemStack itm = player.getInventory().getItem(iam); - if (itm != null) { - if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) { - if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { - player.getInventory().remove(itm); - player.updateInventory(); - break; - } + if (!SelectConfig.UseItem_GiveOnEveryJoin) { + return; + } + new BukkitRunnable() { + @Override + public void run() { + removeItem(player); + if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { + if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) { + Give_UseItem.onGive(player); + if (setCursor) { + setCursor(player, slot); + } + } else if (SelectConfig.UseItem_InventorySlot_FreeSlot) { + boolean empty = false; + for (int i = 0; i < 9; i++) { + if (player.getInventory().getItem(i) == null) { + empty = true; + break; } } - } - if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { - if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) { - Give_UseItem.onGive(player); - if (SelectConfig.Cursor_ToGUIItem_OnLogin) { - if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) { - if (!player.hasPlayedBefore()) { - player.getInventory().setHeldItemSlot(slot - 1); - } - } else { - if (SelectConfig.Bungee) { - if (SelectConfig.UseItem_ServerChange) { - player.getInventory().setHeldItemSlot(slot - 1); - } else { - if (Main.bungeejoinplayers.contains(player.getName())) { - player.getInventory().setHeldItemSlot(slot - 1); - Main.bungeejoinplayers.remove(player.getName()); - } - } - } else player.getInventory().setHeldItemSlot(slot - 1); - } - } - } else if (SelectConfig.UseItem_InventorySlot_FreeSlot) { - boolean empty = false; - for (int i = 0; i < 9; i++) { - if (player.getInventory().getItem(i) == null) { - empty = true; - break; - } - } - if (empty) { - Give_UseItem.onGiveADD(player); - } + if (empty) { + Give_UseItem.onGiveADD(player); } } } - }.runTaskLater(Main.plugin, 1L * 1); + } + }.runTaskLater(Main.plugin, 1L * 1); + + } + + private static void setCursor(Player player, int slot) { + if (!SelectConfig.Cursor_ToGUIItem_OnLogin) { + return; + } + if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) { + if (!player.hasPlayedBefore()) { + player.getInventory().setHeldItemSlot(slot - 1); + } + return; + } + if (!SelectConfig.Bungee) { + player.getInventory().setHeldItemSlot(slot - 1); + return; + } + if (SelectConfig.UseItem_ServerChange) { + player.getInventory().setHeldItemSlot(slot - 1); + return; + } + if (Main.bungeejoinplayers.contains(player.getName())) { + player.getInventory().setHeldItemSlot(slot - 1); + Main.bungeejoinplayers.remove(player.getName()); } } + + private static void removeItem(Player player) { + for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { + ItemStack itm = player.getInventory().getItem(iam); + if (itm != null) { + if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) { + if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { + player.getInventory().remove(itm); + player.updateInventory(); + break; + } + } + } + } + + } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java index 1929c14..ee662f0 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/PluginEvent.java @@ -74,6 +74,6 @@ public class PluginEvent implements Listener { } private static void clearGive(Player player) { - ItemChange.itemChange(player); + ItemChange.itemChange(player, false); } } \ No newline at end of file diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java index c6d4b5e..dd9dd69 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events.java @@ -36,7 +36,7 @@ public class Events implements Listener { new BukkitRunnable() { @Override public void run() { - ItemChange.itemChange(e.getPlayer()); + ItemChange.itemChange(e.getPlayer(), true); } }.runTaskLater(Main.plugin, 20L * 1); } @@ -73,7 +73,7 @@ public class Events implements Listener { public void onRespawn(PlayerRespawnEvent e) { Player player = e.getPlayer(); if (SelectConfig.UseItem_Enable) { - ItemChange.itemChange(player); + ItemChange.itemChange(player, false); //if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { // if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) { // if (!player.hasPlayedBefore()) { @@ -99,38 +99,17 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onGameModeChange(PlayerGameModeChangeEvent e) { Player player = e.getPlayer(); + if (!SelectConfig.UseItemGameModeChangeEnable) { + return; + } new BukkitRunnable() { @Override public void run() { - if (SelectConfig.UseItemGameModeChangeEnable) { - if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { - removeItem(player); - return; - } - if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { - removeItem(player); - return; - } - ItemChange.itemChange(player); - } + ItemChange.itemChange(player, false); } }.runTaskLater(Main.plugin, SelectConfig.UseItemGameModeChangeDelayInTicks * 1L); } - private static void removeItem(Player player) { - for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { - ItemStack itm = player.getInventory().getItem(iam); - if (itm != null) { - if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) { - if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { - player.getInventory().remove(itm); - player.updateInventory(); - break; - } - } - } - } - } @EventHandler(priority = EventPriority.HIGHEST) public void onInteract(PlayerInteractEvent e) { @@ -204,14 +183,14 @@ public class Events implements Listener { && e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { p.closeInventory(); e.setCancelled(true); - ItemChange.itemChange(p); + ItemChange.itemChange(p, false); } if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName() && e.getOldCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { p.closeInventory(); e.setCancelled(true); - ItemChange.itemChange(p); + ItemChange.itemChange(p, false); } } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java index 3be236d..800525c 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java @@ -96,11 +96,11 @@ public class ConfigCreate { Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration); Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration); - Config.set("Advanced.UseItem.GameModeChange.Enable", true, yamlConfiguration); - Config.set("Advanced.UseItem.GameModeChange.DelayInTicks", 1, yamlConfiguration); - Config.set("Advanced.UseItem.GameModeChange.Protection.Enable", false, yamlConfiguration); - Config.set("Advanced.UseItem.GameModeChange.Protection.Mode", "blacklist", yamlConfiguration); - Config.set("Advanced.UseItem.GameModeChange.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration); + Config.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration); + Config.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration); + Config.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration); + Config.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration); + Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration); Config.set("Sound.Enable", true, yamlConfiguration); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java index 564ca73..6d60f67 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/SelectConfig.java @@ -11,6 +11,7 @@ import org.bukkit.Sound; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; +import java.util.ArrayList; import java.util.List; public class SelectConfig { @@ -145,11 +146,16 @@ public class SelectConfig { Cursor_ToGUIItem_OnlyOnFirstLogin = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin"); UseItem_ServerChange = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange"); - UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.Enable"); - UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameModeChange.DelayInTicks"); - UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.Protection.Enable"); - UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameModeChange.Protection.Mode"); - UseItemGameModeList = yamlConfiguration.getStringList("Advanced.UseItem.GameModeChange.Protection.List"); + UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Change.Enable"); + UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameMode.Change.DelayInTicks"); + UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable"); + UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode"); + List gml = new ArrayList<>(); + for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")){ + gml.add(gm.toUpperCase()); + } + UseItemGameModeList = gml; + Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable"); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java index d711e87..6bbb9c5 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java @@ -14,7 +14,10 @@ public class CGuiAPI { public static Boolean JoinDisable = false; public static void onItemChange(Player player) { - ItemChange.itemChange(player); + ItemChange.itemChange(player, false); + } + public static void onItemChange(Player player, Boolean setCursor) { + ItemChange.itemChange(player, setCursor); } public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) { From 47c2329ff9d075414889c9fc47a8caeeef538bb7 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 6 Jan 2022 18:28:27 +0100 Subject: [PATCH 4/5] Update pom.xml --- CommandGUI V2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 0a5e4d4..1e0d9ac 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.5.18_DEV + 2.5.18_Snapshot_1 jar CommandGUI From 908e1379431685b166e9aa3d2415fb9d2ff038d3 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 6 Jan 2022 19:18:09 +0100 Subject: [PATCH 5/5] Update pom.xml --- CommandGUI V2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 1e0d9ac..e0ad4a4 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.5.18_Snapshot_1 + 2.5.18 jar CommandGUI