From c17733fe3f2d55a7b3a2d1a2b9316dee792552e3 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Sat, 16 Apr 2022 14:32:22 +0200 Subject: [PATCH 01/16] insert --- CommandGUI V2/pom.xml | 106 +--- .../Spigot/Listener/ConfigChat.java | 2 +- .../Spigot/Listener/GUI_Listener.java | 489 +++++++++++++++--- .../Spigot/Listener/ItemChange.java | 12 +- .../Spigot/Listener/PluginEvent.java | 8 +- .../Listener/UseItem_Listener/Events.java | 40 +- .../de/jatitv/commandguiv2/Spigot/Main.java | 3 +- .../Spigot/Objekte/Obj_Select.java | 12 +- .../commandguiv2/Spigot/Objekte/Slot.java | 274 +++++----- .../cmdManagement/CmdExecuter_Admin.java | 151 ------ ...cuter_GUI.java => CmdExecuter_GUITab.java} | 2 +- .../Spigot/cmdManagement/Commands.java | 13 +- .../cmdManagement/register/AliasRegister.java | 105 +--- .../Spigot/config/DefaultGUICreate.java | 244 +++++---- .../Spigot/config/config/ConfigCreate.java | 26 +- .../Spigot/config/config/SelectConfig.java | 37 +- .../commandguiv2/Spigot/gui/GuiBuilder.java | 120 +++++ .../commandguiv2/Spigot/gui/OpenGUI.java | 141 ++--- .../Spigot/system/Give_UseItem.java | 5 +- .../commandguiv2/Spigot/system/Load.java | 25 +- .../Spigot/system/Placeholder.java | 56 ++ .../Spigot/system/RegisterPermissions.java | 4 +- .../Spigot/system/database/MySQL.java | 3 +- .../system/database/Select_Database.java | 3 + .../de/jatitv/commandguiv2/api/CGuiAPI.java | 5 +- .../src/main/resources/META-INF/MANIFEST.MF | 1 - 26 files changed, 1100 insertions(+), 787 deletions(-) delete mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_Admin.java rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/{CmdExecuter_GUI.java => CmdExecuter_GUITab.java} (98%) create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Placeholder.java diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 5ba3556..76ea62d 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,10 +6,13 @@ net.t2code CommandGUI_V2 - 2.6.2_Snapshot-2 +<<<<<<< Updated upstream + 2.6.1 +======= + 2.6.10_Snapshot-1 +>>>>>>> Stashed changes jar - CommandGUI @@ -66,6 +69,10 @@ T2Code https://repo.t2code.net/repository/T2Code/ + + placeholderapi + http://repo.extendedclip.com/content/repositories/placeholderapi/ + @@ -83,98 +90,23 @@ net.t2code T2CodeLib - 11.4 + 10.3 net.t2code LuckyBox-API 4.2.2 - - net.t2code.minecraft.1_18.r2 - spigot - 1.18r2 - - - net.t2code.minecraft.1_18.r1 - spigot - 1.18r1 - - - net.t2code.minecraft.1_17.r1 - spigot - 1.17r1 - - - net.t2code.minecraft.1_16.r3 - spigot - 1.16r3 - net.t2code.minecraft.1_16.r2 spigot 1.16r2 - - net.t2code.minecraft.1_16.r1 - spigot - 1.16r1 - - - net.t2code.minecraft.1_15.r1 - spigot - 1.15r1 - - - net.t2code.minecraft.1_14.r1 - spigot - 1.14r1 - - - net.t2code.minecraft.1_13.r2 - spigot - 1.13r2 - - - net.t2code.minecraft.1_13.r1 - spigot - 1.13r1 - - - net.t2code.minecraft.1_12.r1 - spigot - 1.12r1 - - - net.t2code.minecraft.1_11.r1 - spigot - 1.11r1 - net.t2code.minecraft.1_10.r1 spigot 1.10r1 - - net.t2code.minecraft.1_9.r2 - spigot - 1.9r2 - - - net.t2code.minecraft.1_9.r1 - spigot - 1.9r1 - - - net.t2code.minecraft.1_8.r3 - spigot - 1.8r3 - - - net.t2code.minecraft.1_8.r2 - spigot - 1.8r2 - net.t2code.minecraft.1_8.r1 spigot @@ -183,7 +115,23 @@ com.zaxxer HikariCP - 3.4.5 + 4.0.3 + + + me.clip + placeholderapi + 2.11.1 + provided + + + org.slf4j + slf4j-jdk14 + 1.7.10 + + + org.slf4j + slf4j-api + 1.7.22 diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java index 1c7e936..a02403a 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java @@ -22,7 +22,7 @@ public class ConfigChat implements Listener { } else { for (Object gui : Main.guiHashMap.values()) { for (Slot slot : gui.GUI_Slots) { - if (slot.ConfigOptionPath.equals(EditChat.get(player))) { + if (slot.configOptionPath.equals(EditChat.get(player))) { } 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 0a95d66..91d81d6 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 @@ -1,6 +1,8 @@ package de.jatitv.commandguiv2.Spigot.Listener; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Objekte.Slot; +import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands; import de.jatitv.commandguiv2.Spigot.system.Bungee_Sender_Reciver; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.Objekte.Object; @@ -22,7 +24,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; @@ -37,6 +38,111 @@ public class GUI_Listener implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent e) { Player player = (Player) e.getWhoClicked(); +<<<<<<< Updated upstream + if (e.getInventory() != null && e.getCurrentItem() != null) { + for (Object gui : Main.guiHashMap.values()) { + if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name)) + || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) { + e.setCancelled(true); + for (Slot slot : gui.GUI_Slots) { + /* if (!slot.ItemsRemovable) { + e.setCancelled(true); + } + */ + + if (e.getSlot() == slot.Slot) { + if (!slot.Perm + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)) + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use") + || player.hasPermission("commandgui.admin")) { + if (slot.Enable) { + if (e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.Name))) { + if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) { + if (slot.Cost_Enable) { + if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) { + if (Vault.buy(prefix, player, slot.Price)) { + player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name)) + .replace("[price]", slot.Price + " " + SelectConfig.Currency)); + if (slot.Command_Enable) { + + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + new BukkitRunnable() { + @Override + public void run() { + if (slot.Command_BungeeCommand && SelectConfig.Bungee) { + for (String cmd : slot.Command) { + Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole); + } + } else { + if (slot.CommandAsConsole) { + for (String cmd : slot.Command) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName())); + } + } else { + for (String cmd : slot.Command) { + player.chat("/" + cmd.replace("[player]", player.getName())); + } + } + } + } + }.runTaskLater(plugin, 2L); + } + if (slot.OpenGUI_Enable) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + + } + }.runTaskLater(plugin, 1L); + new BukkitRunnable() { + @Override + public void run() { + OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI); + } + }.runTaskLater(plugin, 2L); + } + if (slot.Message_Enable) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + for (String msg : slot.Message) { + if (Main.PaPi) { + player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.Price + " " + SelectConfig.Currency)); + } else + player.sendMessage(Replace.replacePrice(prefix, msg, slot.Price + " " + SelectConfig.Currency)); + } + } + if (slot.ServerChange) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer)); + new BukkitRunnable() { + @Override + public void run() { + ServerChange.send(player, slot.ServerChangeServer); + } + }.runTaskLater(Main.plugin, 20L); + } + if (slot.SetConfigEnable) { + File config = new File(slot.ConfigFilePath); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); +======= JavaPlugin plugin = Main.plugin; if (e.getInventory() == null) return; if (e.getCurrentItem() == null) return; @@ -45,17 +151,17 @@ public class GUI_Listener implements Listener { || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) { e.setCancelled(true); for (Slot slot : gui.GUI_Slots) { - if (e.getSlot() != slot.Slot) continue; - if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) { - if (!slot.Perm - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)) - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use") + if (e.getSlot() != slot.slot) continue; + if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() || e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() || e.getCurrentItem().getType() == Material.valueOf(slot.item.toUpperCase().replace(".", "_"))) { + if (!slot.perm + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1)) + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1) + ".use") || player.hasPermission("commandgui.admin")) { - if (!slot.Enable) continue; - if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.Name))) continue; - if (slot.Cost_Enable) { - if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) { - if (!Vault.buy(prefix, player, slot.Price)) { + if (!slot.enable) continue; + if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.name))) continue; + if (slot.cost_Enable) { + if (slot.command_Enable || slot.message_Enable || slot.openGUI_Enable || slot.serverChange) { + if (!Vault.buy(prefix, player, slot.price)) { new BukkitRunnable() { @Override public void run() { @@ -66,14 +172,14 @@ public class GUI_Listener implements Listener { if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1); } else { - player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name)) - .replace("[price]", slot.Price + " " + SelectConfig.Currency)); + player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.name)) + .replace("[price]", slot.price + " " + SelectConfig.Currency)); execute(slot, player, e, gui); } } } else execute(slot, player, e, gui); - } else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name)) - .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))); + } else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.name)) + .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1))); } } } @@ -81,11 +187,13 @@ public class GUI_Listener implements Listener { } private static void execute(Slot slot, Player player, InventoryClickEvent e, Object gui) { - if (slot.Command_Enable) command(slot, player); - if (slot.OpenGUI_Enable) openGUI(slot, player); - if (slot.Message_Enable) message(slot, player); - if (slot.ServerChange) serverChange(slot, player); - if (slot.SetConfigEnable) setConfig(slot, player, e); + if (slot.togglePermission) togglePerm(slot, player); + if (slot.toggleUseItem) toggleUseItem(player); + if (slot.command_Enable) command(slot, player); + if (slot.openGUI_Enable) openGUI(slot, player); + if (slot.message_Enable) message(slot, player); + if (slot.serverChange) serverChange(slot, player); + if (slot.setConfigEnable) setConfig(slot, player, e); if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(slot, player, gui); } @@ -99,18 +207,18 @@ public class GUI_Listener implements Listener { new BukkitRunnable() { @Override public void run() { - if (slot.Command_BungeeCommand) { + if (slot.command_BungeeCommand) { if (SelectConfig.Bungee) { - for (String cmd : slot.Command) { - Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole); + for (String cmd : slot.command) { + Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.commandAsConsole); } } else { send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config."); send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config."); } } else { - for (String cmd : slot.Command) { - if (slot.CommandAsConsole) { + for (String cmd : slot.command) { + if (slot.commandAsConsole) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName())); } else player.chat("/" + cmd.replace("[player]", player.getName())); } @@ -129,7 +237,7 @@ public class GUI_Listener implements Listener { new BukkitRunnable() { @Override public void run() { - OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI); + OpenGUI.openGUI(player, Main.guiHashMap.get(slot.openGUI), slot.openGUI); } }.runTaskLater(plugin, 2L); } @@ -141,14 +249,14 @@ public class GUI_Listener implements Listener { player.closeInventory(); } }.runTaskLater(plugin, 1L); - for (String msg : slot.Message) { + for (String msg : slot.message) { if (Main.PaPi) { - if (slot.Cost_Enable) { - player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.Price + " " + SelectConfig.Currency)); + if (slot.cost_Enable) { + player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.price + " " + SelectConfig.Currency)); } else player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix))); } else { - if (slot.Cost_Enable) { - player.sendMessage(Replace.replacePrice(prefix, msg, slot.Price + " " + SelectConfig.Currency)); + if (slot.cost_Enable) { + player.sendMessage(Replace.replacePrice(prefix, msg, slot.price + " " + SelectConfig.Currency)); } else player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix))); } } @@ -161,18 +269,19 @@ public class GUI_Listener implements Listener { player.closeInventory(); } }.runTaskLater(plugin, 1L); - send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer)); + send.player(player, SelectMessages.onServerChange.replace("[server]", slot.serverChangeServer)); new BukkitRunnable() { @Override public void run() { - ServerChange.send(player, slot.ServerChangeServer); + ServerChange.send(player, slot.serverChangeServer); } }.runTaskLater(Main.plugin, 20L); } private static void setConfig(Slot slot, Player player, InventoryClickEvent e) { - File config = new File(slot.ConfigFilePath); + File config = new File(slot.configFilePath); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); +>>>>>>> Stashed changes /*if (slot.ConfigChatInput){ ConfigChat.EditChat.put(player, slot.ConfigOptionPath); player.sendMessage(DefaultValue.SettingsGUIchatSet.replace("[setting]", "Shop Name Chest small")); @@ -180,32 +289,276 @@ public class GUI_Listener implements Listener { } else { */ +<<<<<<< Updated upstream + if (e.getClick() == ClickType.LEFT) { + if (slot.ConfigOptionPremat.equals("String")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft); + } else if (slot.ConfigOptionPremat.equals("Boolean")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft); + } else if (slot.ConfigOptionPremat.equals("Integer")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft); + } else if (slot.ConfigOptionPremat.equals("Double")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft); + } else if (slot.ConfigOptionPremat.equals("List")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft); + } else { + player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo + } + } + if (e.getClick() == ClickType.RIGHT) { + if (slot.ConfigOptionPremat.equals("String")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight); + } else if (slot.ConfigOptionPremat.equals("Boolean")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight); + } else if (slot.ConfigOptionPremat.equals("Integer")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight); + } else if (slot.ConfigOptionPremat.equals("Double")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight); + } else if (slot.ConfigOptionPremat.equals("List")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight); + } else { + player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo + } + } + try { + yamlConfiguration.save(config); + } catch (IOException tac) { + tac.printStackTrace(); + } + if (slot.PluginReloadEnable) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand); + } + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + } + + if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) { + if (slot.CustomSound_Enable) { + if (!slot.CustomSound_NoSound) { + try { + player.playSound(player.getLocation(), Sound.valueOf(slot.CustomSound_Sound.toUpperCase().replace(".", "_")), 3, 1); + + } catch (Exception e1) { + send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) + .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound)); + player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); + } + } + } else + player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); + } + + } else { + + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + player.sendMessage(SelectMessages.No_money); + if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) { + player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1); + } + } + } + } else { + if (slot.Command_Enable) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + new BukkitRunnable() { + @Override + public void run() { + if (slot.Command_BungeeCommand) { + if (SelectConfig.Bungee) { + for (String cmd : slot.Command) { + Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole); + } + } else { + send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config."); + } + + } else { + if (slot.CommandAsConsole) { + for (String cmd : slot.Command) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName())); + } + } else { + for (String cmd : slot.Command) { + player.chat("/" + cmd); + } + } + } + } + }.runTaskLater(plugin, 2L); + } + if (slot.OpenGUI_Enable) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + new BukkitRunnable() { + @Override + public void run() { + + OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI); + } + }.runTaskLater(plugin, 2L); + } + if (slot.Message_Enable) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + + for (String msg : slot.Message) { + if (Main.PaPi) { + player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix))); + } else + player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix))); + } + } + if (slot.ServerChange) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + + send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer)); + + + new BukkitRunnable() { + @Override + public void run() { + ServerChange.send(player, slot.ServerChangeServer); + } + }.runTaskLater(Main.plugin, 20L); + } + if (slot.SetConfigEnable) { + File config = new File(slot.ConfigFilePath); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + /*if (slot.ConfigChatInput){ + ConfigChat.EditChat.put(player, slot.ConfigOptionPath); + player.sendMessage(DefaultValue.SettingsGUIchatSet.replace("[setting]", "Shop Name Chest small")); + player.sendMessage(DefaultValue.SettingsGUIchatCancel); + } else + { + */ + if (e.isLeftClick()) { + if (slot.ConfigOptionPremat.equals("String")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft); + } else if (slot.ConfigOptionPremat.equals("Boolean")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft); + } else if (slot.ConfigOptionPremat.equals("Integer")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft); + } else if (slot.ConfigOptionPremat.equals("Double")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft); + } else if (slot.ConfigOptionPremat.equals("List")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft); + } else { + player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo + } + } + if (e.isRightClick()) { + if (slot.ConfigOptionPremat.equals("String")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight); + } else if (slot.ConfigOptionPremat.equals("Boolean")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight); + } else if (slot.ConfigOptionPremat.equals("Integer")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight); + } else if (slot.ConfigOptionPremat.equals("Double")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight); + } else if (slot.ConfigOptionPremat.equals("List")) { + yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight); + } else { + player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo + } + } + try { + yamlConfiguration.save(config); + } catch (IOException tac) { + tac.printStackTrace(); + } + if (slot.PluginReloadEnable) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand); + } + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + } + if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) { + if (slot.CustomSound_Enable) { + if (!slot.CustomSound_NoSound) { + try { + player.playSound(player.getLocation(), Sound.valueOf(slot.CustomSound_Sound.toUpperCase().replace(".", "_")), 3, 1); + + } catch (Exception e1) { + send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) + .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound)); + player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); + } + } + } else + player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); + } + } + } + } + } + } else { + player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name)) + .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))); + } + } + } +======= if (e.getClick() == ClickType.LEFT) { - if (slot.ConfigOptionPremat.equals("String")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft); - } else if (slot.ConfigOptionPremat.equals("Boolean")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft); - } else if (slot.ConfigOptionPremat.equals("Integer")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft); - } else if (slot.ConfigOptionPremat.equals("Double")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft); - } else if (slot.ConfigOptionPremat.equals("List")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft); + if (slot.configOptionPremat.equals("String")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configStringValueLeft); + } else if (slot.configOptionPremat.equals("Boolean")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configBooleanValueLeft); + } else if (slot.configOptionPremat.equals("Integer")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configIntegerValueLeft); + } else if (slot.configOptionPremat.equals("Double")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configDoubleValueLeft); + } else if (slot.configOptionPremat.equals("List")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueLeft); } else { player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo } } if (e.getClick() == ClickType.RIGHT) { - if (slot.ConfigOptionPremat.equals("String")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight); - } else if (slot.ConfigOptionPremat.equals("Boolean")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight); - } else if (slot.ConfigOptionPremat.equals("Integer")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight); - } else if (slot.ConfigOptionPremat.equals("Double")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight); - } else if (slot.ConfigOptionPremat.equals("List")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight); + if (slot.configOptionPremat.equals("String")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configStringValueRight); + } else if (slot.configOptionPremat.equals("Boolean")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configBooleanValueRight); + } else if (slot.configOptionPremat.equals("Integer")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configIntegerValueRight); + } else if (slot.configOptionPremat.equals("Double")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configDoubleValueRight); + } else if (slot.configOptionPremat.equals("List")) { + yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueRight); } else { player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo } @@ -215,8 +568,8 @@ public class GUI_Listener implements Listener { } catch (IOException tac) { tac.printStackTrace(); } - if (slot.PluginReloadEnable) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand); + if (slot.pluginReloadEnable) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.pluginReloadCommand); } new BukkitRunnable() { @Override @@ -227,18 +580,32 @@ public class GUI_Listener implements Listener { } private static void sound(Slot slot, Player player, Object gui) { - if (slot.CustomSound_Enable) { - if (!slot.CustomSound_NoSound) { + if (slot.customSound_Enable) { + if (!slot.customSound_NoSound) { try { - player.playSound(player.getLocation(), Sound.valueOf(slot.CustomSound_Sound.toUpperCase().replace(".", "_")), 3, 1); + player.playSound(player.getLocation(), Sound.valueOf(slot.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1); } catch (Exception e1) { send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) - .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound)); + .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + slot.customSound_Sound)); player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); +>>>>>>> Stashed changes } } - } else player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); + } + } + + private static void togglePerm(Slot slot, Player player) { + if (player.hasPermission(slot.togglePermissionPerm)) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm)); + } else + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm)); + } + + private static void toggleUseItem(Player player) { + if (Events.useItemHashMap.get(player)) { + Commands.itemOff(player); + } else Commands.itemOn(player); } } 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 4e2f9b8..9f7f751 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 @@ -1,5 +1,6 @@ package de.jatitv.commandguiv2.Spigot.Listener; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.system.Give_UseItem; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; @@ -17,12 +18,13 @@ public class ItemChange { if (SelectConfig.UseItem_InventorySlotEnforce) { slot = SelectConfig.UseItem_InventorySlot; } else { - if (Select_Database.selectSlot(player) == null) { + if (Events.useItemSlotHashMap.get(player) == null) { slot = SelectConfig.UseItem_InventorySlot; } else { - slot = Select_Database.selectSlot(player); + slot = Events.useItemSlotHashMap.get(player); } } + if (!SelectConfig.UseItem_Enable) { return; } @@ -51,7 +53,7 @@ public class ItemChange { } } if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) { - if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { + if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) { if (!player.hasPlayedBefore()) { new BukkitRunnable() { @Override @@ -78,7 +80,7 @@ public class ItemChange { @Override public void run() { removeItem(player); - if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { + if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) { if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) { send.debug(Main.plugin,"Give: " +player.getName()); Give_UseItem.onGive(player); @@ -100,6 +102,7 @@ public class ItemChange { } } }.runTaskLater(Main.plugin, 1L * 1); + } private static void setCursor(Player player, int slot) { @@ -151,5 +154,6 @@ public class ItemChange { } } } + } } 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 f3e7a78..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 @@ -23,9 +23,10 @@ public class PluginEvent implements Listener { public void onJoinEvent(PlayerLoginEvent event) { Player player = event.getPlayer(); Select_Database.nameCheck(player); - UpdateAPI.join(Main.plugin, prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord()); + UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord()); } + @EventHandler public void onClearServer(ServerCommandEvent event) { if (SelectConfig.UseItem_KeepAtCommandClear) { @@ -35,11 +36,11 @@ public class PluginEvent implements Listener { public void run() { try { Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", "")); - if (player == null) { + if (player == null){ return; } clearGive(player); - } catch (Exception ex) { + } catch (Exception ex){ ex.printStackTrace(); return; } @@ -49,6 +50,7 @@ public class PluginEvent implements Listener { } } + @EventHandler public void onClearPlayer(PlayerCommandPreprocessEvent event) { if (SelectConfig.UseItem_KeepAtCommandClear) { 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 ac00ae0..4981627 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 @@ -2,15 +2,18 @@ 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.Objekte.Object; 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.Spigot.system.database.Select_Database; import de.jatitv.commandguiv2.api.CGuiAPI; import net.t2code.lib.Bungee.Lib.messages.Bsend; import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; +import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -27,12 +30,21 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; public class Events implements Listener { + public static HashMap useItemHashMap = new HashMap<>(); + public static HashMap useItemSlotHashMap = new HashMap<>(); @EventHandler public void onJoin(PlayerJoinEvent e) { + if (Select_Database.selectItemStatus(e.getPlayer())){ + useItemHashMap.put(e.getPlayer(), true); + } else useItemHashMap.put(e.getPlayer(), false); + + useItemSlotHashMap.put(e.getPlayer(),Select_Database.selectSlot(e.getPlayer())); + if (CGuiAPI.JoinDisable) { send.debug(Main.plugin,"JoinDisable"); return; @@ -48,6 +60,11 @@ public class Events implements Listener { } } + @EventHandler + public void onJoin(PlayerQuitEvent e) { + useItemHashMap.remove(e.getPlayer()); + } + @EventHandler(priority = EventPriority.HIGHEST) public void onDeathDrop(PlayerDeathEvent e) { Player player = e.getEntity().getPlayer(); @@ -80,6 +97,25 @@ public class Events implements Listener { Player player = e.getPlayer(); if (SelectConfig.UseItem_Enable) { ItemChange.itemChange(player, false); + //if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) { + // if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) { + // if (!player.hasPlayedBefore()) { + // new BukkitRunnable() { + // @Override + // public void run() { + // Give_UseItem.onGive(player); + // } + // }.runTaskLater(Main.plugin, 20L * 1); + // } + // } else { + // new BukkitRunnable() { + // @Override + // public void run() { + // Give_UseItem.onGive(player); + // } + // }.runTaskLater(Main.plugin, 20L * 1); + // } + //} } } @@ -111,6 +147,7 @@ public class Events implements Listener { }.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L); } + @EventHandler(priority = EventPriority.HIGHEST) public void onInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); @@ -186,6 +223,7 @@ public class Events implements Listener { } } + @EventHandler(priority = EventPriority.HIGHEST) public void onItemMove(InventoryDragEvent e) { if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; @@ -258,7 +296,7 @@ public class Events implements Listener { } private static boolean legacy() { - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15) { + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15|| NMSVersion.v1_16_R1) { return true; } else return false; } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java index 741f0a7..040854a 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java @@ -69,8 +69,7 @@ public final class Main extends JavaPlugin { if (PluginCheck.plotSquaredGUI()) { PlotSquaredGUI = true; addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI")); - } - if (PluginCheck.luckyBox()) { + }if (PluginCheck.luckyBox()) { LuckyBox = true; addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox")); } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java index 74cb8d9..43d20c3 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java @@ -1,8 +1,7 @@ package de.jatitv.commandguiv2.Spigot.Objekte; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI; -import net.t2code.lib.Spigot.Lib.messages.send; +import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import org.bukkit.configuration.file.YamlConfiguration; @@ -55,7 +54,7 @@ public class Obj_Select { yamlConfiguration_gui.getString("Slots." + key + ".Item.PlayerHead.PlayerName"), yamlConfiguration_gui.getString("Slots." + key + ".Item.Material"), yamlConfiguration_gui.getString("Slots." + key + ".Item.Name"), - yamlConfiguration_gui.getList("Slots." + key + ".Item.Lore"), + yamlConfiguration_gui.getStringList("Slots." + key + ".Item.Lore"), yamlConfiguration_gui.getBoolean("Slots." + key + ".CustomSound.Enable"), yamlConfiguration_gui.getBoolean("Slots." + key + ".CustomSound.NoSound"), yamlConfiguration_gui.getString("Slots." + key + ".CustomSound.Sound"), @@ -69,6 +68,9 @@ public class Obj_Select { yamlConfiguration_gui.getString("Slots." + key + ".ServerChange.Server"), yamlConfiguration_gui.getBoolean("Slots." + key + ".OpenGUI.Enable"), yamlConfiguration_gui.getString("Slots." + key + ".OpenGUI.GUI"), + yamlConfiguration_gui.getBoolean("Slots." + key + ".Toggle.Permission.Enable"), + yamlConfiguration_gui.getString("Slots." + key + ".Toggle.Permission.Permission"), + yamlConfiguration_gui.getBoolean("Slots." + key + ".Toggle.UseItem.Enable"), yamlConfiguration_gui.getBoolean("Slots." + key + ".Message.Enable"), yamlConfiguration_gui.getStringList("Slots." + key + ".Message.Message"), yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required"), @@ -93,12 +95,13 @@ public class Obj_Select { yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable"), yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.PluginReload.Command")); slots.add(slot); + } Object objekt = new Object(GUI_Enable, GUI_Lines, GUI_Name, GUI_FillItem_Enable, GUI_FillItem_Item, config_gui.getName().replace(".yml", ""), Command_Alias_Enable, Command_Permission, slots); Main.guiHashMap.put(config_gui.getName().replace(".yml", ""), objekt); - CmdExecuter_GUI.arg1.put(config_gui.getName().replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", "")); + CmdExecuter_GUITab.arg1.put(config_gui.getName().replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", "")); try { yamlConfiguration_gui.save(config_gui); @@ -106,6 +109,7 @@ public class Obj_Select { e.printStackTrace(); } } + } } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java index ca3015c..5292513 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java @@ -4,155 +4,163 @@ import java.util.List; public class Slot { - public Integer Slot; - public Boolean Enable; + public Integer slot; + public Boolean enable; // public Boolean ItemsRemovable; - public Boolean Empty; - public Integer ItemAmount; - public Boolean PlayerHead_Enable; - public Boolean Base64_Enable; - public String Base64Value; - public Boolean PlayerWhoHasOpenedTheGUI; - public String PlayerName; - public String Item; - public String Name; - public List Lore; - public Boolean CustomSound_Enable; - public Boolean CustomSound_NoSound; - public String CustomSound_Sound; - public Boolean Cost_Enable; - public Double Price; - public Boolean Command_Enable; - public Boolean Command_BungeeCommand; - public Boolean CommandAsConsole; - public Boolean ServerChange; - public String ServerChangeServer; - public List Command; - public Boolean OpenGUI_Enable; - public String OpenGUI; - public Boolean Message_Enable; - public List Message; - public Boolean Perm; - public Boolean SetConfigEnable; - public String ConfigFilePath; - public String ConfigOptionPath; - public String ConfigOptionPremat; + public Boolean empty; + public Integer itemAmount; + public Boolean playerHead_Enable; + public Boolean base64_Enable; + public String base64Value; + public Boolean playerWhoHasOpenedTheGUI; + public String playerName; + public String item; + public String name; + public List lore; + public Boolean customSound_Enable; + public Boolean customSound_NoSound; + public String customSound_Sound; + public Boolean cost_Enable; + public Double price; + public Boolean command_Enable; + public Boolean command_BungeeCommand; + public Boolean commandAsConsole; + public Boolean serverChange; + public String serverChangeServer; + public List command; + public Boolean openGUI_Enable; + public String openGUI; + public Boolean togglePermission; + public String togglePermissionPerm; + public Boolean toggleUseItem; + public Boolean message_Enable; + public List message; + public Boolean perm; + public Boolean setConfigEnable; + public String configFilePath; + public String configOptionPath; + public String configOptionPremat; // public Boolean ConfigChatInput; - public String ConfigStringValueLeft; - public Boolean ConfigBooleanValueLeft; - public Integer ConfigIntegerValueLeft; - public Double ConfigDoubleValueLeft; - public List ConfigListValueLeft; + public String configStringValueLeft; + public Boolean configBooleanValueLeft; + public Integer configIntegerValueLeft; + public Double configDoubleValueLeft; + public List configListValueLeft; - public String ConfigStringValueRight; - public Boolean ConfigBooleanValueRight; - public Integer ConfigIntegerValueRight; - public Double ConfigDoubleValueRight; - public List ConfigListValueRight; + public String configStringValueRight; + public Boolean configBooleanValueRight; + public Integer configIntegerValueRight; + public Double configDoubleValueRight; + public List configListValueRight; - public Boolean PluginReloadEnable; - public String PluginReloadCommand; + public Boolean pluginReloadEnable; + public String pluginReloadCommand; - public Slot(Integer Slot, - Boolean Enable, + public Slot(Integer slot, + Boolean enable, // Boolean ItemsRemovable, - Boolean Empty, - Integer ItemAmount, - Boolean PlayerHead_Enable, - Boolean Base64Value_Enable, - String Base64Value, - Boolean PlayerWhoHasOpenedTheGUI, - String PlayerName, - String Item, - String Name, - List Lore, - Boolean CustomSound_Enable, - Boolean CustomSound_NoSound, - String CustomSound_Sound, - Boolean Cost_Enable, - Double Price, - Boolean Command_Enable, - Boolean Command_BungeeCommand, - Boolean CommandAsConsole, - List Command, - Boolean ServerChange, - String ServerChangeServer, - Boolean OpenGUI_Enable, - String OpenGUI, - Boolean Message_Enable, - List Message, - Boolean Perm, - Boolean SetConfigEnable, - String ConfigFilePath, - String ConfigOptionPath, - String ConfigOptionPremat, - // Boolean ConfigChatInput, + Boolean empty, + Integer itemAmount, + Boolean playerHead_Enable, + Boolean base64Value_Enable, + String base64Value, + Boolean playerWhoHasOpenedTheGUI, + String playerName, + String item, + String name, + List lore, + Boolean customSound_Enable, + Boolean customSound_NoSound, + String customSound_Sound, + Boolean cost_Enable, + Double price, + Boolean command_Enable, + Boolean command_BungeeCommand, + Boolean commandAsConsole, + List command, + Boolean serverChange, + String serverChangeServer, + Boolean openGUI_Enable, + String openGUI, + Boolean togglePermission, + String togglePermissionPerm, + Boolean toggleUseItem, + Boolean message_Enable, + List message, + Boolean perm, + Boolean setConfigEnable, + String configFilePath, + String configOptionPath, + String configOptionPremat, - String ConfigStringValueLeft, - Boolean ConfigBooleanValueLeft, - Integer ConfigIntegerValueLeft, - Double ConfigDoubleValueLeft, - List ConfigListValueLeft, + String configStringValueLeft, + Boolean configBooleanValueLeft, + Integer configIntegerValueLeft, + Double configDoubleValueLeft, + List configListValueLeft, - String ConfigStringValueRight, - Boolean ConfigBooleanValueRight, - Integer ConfigIntegerValueRight, - Double ConfigDoubleValueRight, - List ConfigListValueRight, + String configStringValueRight, + Boolean configBooleanValueRight, + Integer configIntegerValueRight, + Double configDoubleValueRight, + List configListValueRight, - Boolean PluginReloadEnable, - String PluginReloadCommand) { - this.Slot = Slot; - this.Enable = Enable; + Boolean pluginReloadEnable, + String pluginReloadCommand) { + this.slot = slot; + this.enable = enable; // this.ItemsRemovable = ItemsRemovable; - this.Empty = Empty; - this.ItemAmount = ItemAmount; - this.PlayerHead_Enable = PlayerHead_Enable; - this.Base64_Enable = Base64Value_Enable; - this.Base64Value = Base64Value; - this.PlayerWhoHasOpenedTheGUI = PlayerWhoHasOpenedTheGUI; - this.PlayerName = PlayerName; - this.Item = Item; - this.Name = Name; - this.Lore = Lore; - this.CustomSound_Enable = CustomSound_Enable; - this.CustomSound_NoSound = CustomSound_NoSound; - this.CustomSound_Sound = CustomSound_Sound; - this.Cost_Enable = Cost_Enable; - this.Price = Price; - this.Command_Enable = Command_Enable; - this.Command_BungeeCommand = Command_BungeeCommand; - this.CommandAsConsole = CommandAsConsole; - this.Command = Command; - this.ServerChange = ServerChange; - this.ServerChangeServer = ServerChangeServer; - this.OpenGUI_Enable = OpenGUI_Enable; - this.OpenGUI = OpenGUI; - this.Message_Enable = Message_Enable; - this.Message = Message; - this.Perm = Perm; - this.SetConfigEnable = SetConfigEnable; - this.ConfigFilePath = ConfigFilePath; - this.ConfigOptionPath = ConfigOptionPath; - this.ConfigOptionPremat = ConfigOptionPremat; + this.empty = empty; + this.itemAmount = itemAmount; + this.playerHead_Enable = playerHead_Enable; + this.base64_Enable = base64Value_Enable; + this.base64Value = base64Value; + this.playerWhoHasOpenedTheGUI = playerWhoHasOpenedTheGUI; + this.playerName = playerName; + this.item = item; + this.name = name; + this.lore = lore; + this.customSound_Enable = customSound_Enable; + this.customSound_NoSound = customSound_NoSound; + this.customSound_Sound = customSound_Sound; + this.cost_Enable = cost_Enable; + this.price = price; + this.command_Enable = command_Enable; + this.command_BungeeCommand = command_BungeeCommand; + this.commandAsConsole = commandAsConsole; + this.command = command; + this.serverChange = serverChange; + this.serverChangeServer = serverChangeServer; + this.openGUI_Enable = openGUI_Enable; + this.openGUI = openGUI; + this.togglePermission = togglePermission; + this.togglePermissionPerm = togglePermissionPerm; + this.toggleUseItem = toggleUseItem; + this.message_Enable = message_Enable; + this.message = message; + this.perm = perm; + this.setConfigEnable = setConfigEnable; + this.configFilePath = configFilePath; + this.configOptionPath = configOptionPath; + this.configOptionPremat = configOptionPremat; // this.ConfigChatInput = ConfigChatInput; - this.ConfigStringValueLeft = ConfigStringValueLeft; - this.ConfigBooleanValueLeft = ConfigBooleanValueLeft; - this.ConfigIntegerValueLeft = ConfigIntegerValueLeft; - this.ConfigDoubleValueLeft = ConfigDoubleValueLeft; - this.ConfigListValueLeft = ConfigListValueLeft; + this.configStringValueLeft = configStringValueLeft; + this.configBooleanValueLeft = configBooleanValueLeft; + this.configIntegerValueLeft = configIntegerValueLeft; + this.configDoubleValueLeft = configDoubleValueLeft; + this.configListValueLeft = configListValueLeft; - this.ConfigStringValueRight = ConfigStringValueRight; - this.ConfigBooleanValueRight = ConfigBooleanValueRight; - this.ConfigIntegerValueRight = ConfigIntegerValueRight; - this.ConfigDoubleValueRight = ConfigDoubleValueRight; - this.ConfigListValueRight = ConfigListValueRight; + this.configStringValueRight = configStringValueRight; + this.configBooleanValueRight = configBooleanValueRight; + this.configIntegerValueRight = configIntegerValueRight; + this.configDoubleValueRight = configDoubleValueRight; + this.configListValueRight = configListValueRight; - this.PluginReloadEnable = PluginReloadEnable; - this.PluginReloadCommand = PluginReloadCommand; + this.pluginReloadEnable = pluginReloadEnable; + this.pluginReloadCommand = pluginReloadCommand; } } 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 deleted file mode 100644 index da237c2..0000000 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_Admin.java +++ /dev/null @@ -1,151 +0,0 @@ -package de.jatitv.commandguiv2.Spigot.cmdManagement; - -import de.jatitv.commandguiv2.Spigot.system.Debug; -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; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -public class CmdExecuter_Admin implements CommandExecutor, TabCompleter { - private static String prefix = Util.getPrefix(); - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - - if (args.length == 0) { - Help.sendHelp(sender, prefix); - } else { - switch (args[0].toLowerCase()) { - case "info": - if (sender.hasPermission("commandgui.command.info")) { - Commands.info(sender); - } else sender.sendMessage(SelectMessages.NoPermissionForCommand - .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.command.info")); - - break; - case "reload": - case "rl": - if (sender.hasPermission("commandgui.admin")) { - Commands.reload(sender); - } else sender.sendMessage(SelectMessages.NoPermissionForCommand - .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); - break; - case "createdefaultgui": - if (sender.hasPermission("commandgui.admin")) { - DefaultGUICreate.configCreate(); - sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "/GUIs/default.yml")); - } else sender.sendMessage(SelectMessages.NoPermissionForCommand - .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); - break; - case "debug": - if (sender.hasPermission("commandgui.admin")) { - Debug.onDebugFile(sender); - /*if (args.length == 2) { - if (args[1].equals("config")) { - Debug.debugmsg(); - } - if (args[1].equals("2")) { - send.debug("2"); - } - break; - - } else Debug.debugmsg(); - - */ - } else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); - break; - - case "give": - if (args.length == 2) { - if (sender.hasPermission("commandgui.giveitem.other")) { - Player target = Bukkit.getPlayer(args[1]); - Commands.give(sender, target); - } else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui give") - .replace("[perm]", "commandgui.command.give")); - } else Help.sendHelp(sender, prefix); - break; - case "help": - default: - Help.sendHelp(sender, prefix); - break; - - } - } - - return false; - } - - - //TabCompleter - private static HashMap arg1 = new HashMap() {{ - put("reload", "commandgui.admin"); - put("rl", "commandgui.admin"); - put("createdefaultgui", "commandgui.admin"); - put("give", "commandgui.giveitem.other"); - put("info", "commandgui.command.info"); - }}; - - @Override - public List onTabComplete(CommandSender sender, Command cmd, String s, String[] args) { - List list = new ArrayList<>(); - if (sender instanceof Player) { - Player p = (Player) sender; - if (args.length == 1) { - for (String command : arg1.keySet()) { - Boolean passend = true; - for (int i = 0; i < args[0].length(); i++) { - if (args[0].length() >= command.length()) { - passend = false; - } else { - if (args[0].charAt(i) != command.charAt(i)) { - passend = false; - } - } - } - if (hasPermission(p, arg1.get(command)) && passend) { - list.add(command); - } - } - } - - if (args.length == 2 && args[0].equalsIgnoreCase("give")) { - if (sender.hasPermission("commandgui.giveitem.other")) { - Iterator var6 = Bukkit.getOnlinePlayers().iterator(); - - while (var6.hasNext()) { - Player player1 = (Player) var6.next(); - list.add(player1.getName()); - } - } - return list; - } - } - return list; - } - - - public static boolean hasPermission(Player player, String permission) { - if (player.isOp()) { - return true; - } - String[] Permissions = permission.split(";"); - for (String perm : Permissions) { - if (player.hasPermission(perm)) { - return true; - } - } - return false; - } -} - 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_GUITab.java similarity index 98% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUI.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUITab.java index 71115ee..ff4a795 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_GUITab.java @@ -17,7 +17,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class CmdExecuter_GUI implements CommandExecutor, TabCompleter { +public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter { private static String prefix = Util.getPrefix(); @Override 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 2361156..f9ad4b2 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 @@ -1,5 +1,6 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; +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.Objekte.Object; @@ -59,8 +60,8 @@ public class Commands { send.console(Util.getPrefix() + " §6Plugin reload..."); send.console(Util.getPrefix() + "§8-------------------------------"); - CmdExecuter_GUI.arg1.clear(); - CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); + CmdExecuter_GUITab.arg1.clear(); + CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); ConfigCreate.configCreate(); SelectConfig.onSelect(); Main.plugin.reloadConfig(); @@ -70,11 +71,13 @@ public class Commands { Obj_Select.onSelect(); SelectMessages.onSelect(Util.getPrefix()); SelectConfig.sound(Util.getPrefix()); + try { AliasRegister.onRegister(); } catch (Exception e) { e.printStackTrace(); } + if (SelectConfig.Bungee) { Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee"); @@ -120,10 +123,10 @@ public class Commands { if (SelectConfig.UseItem_InventorySlotEnforce) { slot = SelectConfig.UseItem_InventorySlot; } else { - if (Select_Database.selectSlot(player) == null) { + if (Events.useItemSlotHashMap.get(player) == null) { slot = SelectConfig.UseItem_InventorySlot; } else { - slot = Select_Database.selectSlot(player); + slot = Events.useItemSlotHashMap.get(player); } } send.debug(Main.plugin, String.valueOf(slot)); @@ -203,7 +206,7 @@ public class Commands { } } Select_Database.setSlot(player, setSlot); - if (Select_Database.selectItemStatus(player)) { + if (Events.useItemHashMap.get(player)) { Give_UseItem.onGive(player); } send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString())); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java index 87e775d..03058fd 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java @@ -1,15 +1,14 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register; 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.NMSVersion; import org.bukkit.Bukkit; +import org.bukkit.command.CommandMap; import org.bukkit.plugin.Plugin; -import org.eclipse.sisu.space.ClassFinder; import java.io.File; +import java.lang.reflect.Field; public class AliasRegister { @@ -25,97 +24,17 @@ public class AliasRegister { for (String alias : Main.allAliases) { if (Main.guiHashMap.get(alias) != null) { if (Main.guiHashMap.get(alias).Command_Alias_Enable) { - String version; - if (NMSVersion.v1_8_R1) { - send.debug(plugin, "Alias register 1.8_R1"); - org.bukkit.craftbukkit.v1_8_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_8_R2) { - send.debug(plugin, "Alias register 1.8_R2"); - org.bukkit.craftbukkit.v1_8_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_8_R3) { - send.debug(plugin, "Alias register 1.8_R3"); - org.bukkit.craftbukkit.v1_8_R3.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R3.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_9_R1) { - send.debug(plugin, "Alias register 1.9_R1"); - org.bukkit.craftbukkit.v1_9_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_9_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_9_R2) { - send.debug(plugin, "Alias register 1.9_R2"); - org.bukkit.craftbukkit.v1_9_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_9_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_10_R1) { - send.debug(plugin, "Alias register 1.10_R1"); - org.bukkit.craftbukkit.v1_10_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_10_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_11_R1) { - send.debug(plugin, "Alias register 1.11_R1"); - org.bukkit.craftbukkit.v1_11_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_11_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_12_R1) { - send.debug(plugin, "Alias register 1.12_R1"); - org.bukkit.craftbukkit.v1_12_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_12_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_13_R1) { - send.debug(plugin, "Alias register 1.13_R1"); - org.bukkit.craftbukkit.v1_13_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_13_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_13_R2) { - send.debug(plugin, "Alias register 1.13_R2"); - org.bukkit.craftbukkit.v1_13_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_13_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_14_R1) { - send.debug(plugin, "Alias register 1.14_R1"); - org.bukkit.craftbukkit.v1_14_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_14_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_15_R1) { - send.debug(plugin, "Alias register 1.15_R1"); - org.bukkit.craftbukkit.v1_15_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_15_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_16_R1) { - send.debug(plugin, "Alias register 1.16_R1"); - org.bukkit.craftbukkit.v1_16_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_16_R2) { - send.debug(plugin, "Alias register 1.16_R2"); - org.bukkit.craftbukkit.v1_16_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_16_R3) { - send.debug(plugin, "Alias register 1.16_R3"); - org.bukkit.craftbukkit.v1_16_R3.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R3.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_17_R1) { - send.debug(plugin, "Alias register 1.17_R1"); - org.bukkit.craftbukkit.v1_17_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_17_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_18_R1) { - send.debug(plugin, "Alias register 1.18_R1"); - org.bukkit.craftbukkit.v1_18_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); - } - if (NMSVersion.v1_18_R2) { - send.debug(plugin, "Alias register 1.18_R2"); - org.bukkit.craftbukkit.v1_18_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); + try { + final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); + + bukkitCommandMap.setAccessible(true); + CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer()); + + commandMap.register(alias, new RegisterCommand(alias)); + } catch(Exception e) { + e.printStackTrace(); } + //Register.register(alias, plugin); } } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java index 5ae684f..c55b254 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java @@ -12,150 +12,144 @@ import java.util.List; public class DefaultGUICreate { - - private static Boolean GUI_Enable = true; - private static Integer GUI_Lines = 1; - private static String GUI_Name = "&5default &9GUI"; - private static Boolean GUI_FillItem_Enable = true; - private static Integer GUI_FillItem_Item_1_8 = 15; - private static String GUI_FillItem_Item = "BLACK_STAINED_GLASS_PANE"; - - private static Boolean Command_Alias = true; - private static Boolean Command_Permission = true; - - private static Integer slot = 5; - private static Boolean enable = true; - private static Boolean ItemEmty = false; - private static Integer ItemAmout = 1; - private static Boolean Playerhead_enable = true; - private static Boolean base64_Enable = true; - private static String base64value = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19"; - private static Boolean PlayerWhoHasOpenedTheGUI = false; - private static String PlayerName = ""; - private static String Item = ""; - private static String Itemname = "&3Support Discord"; - private static List ItemLore = Arrays.asList( - "&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: §7http://dc.t2code.net"); - private static Boolean CustomSound = false; - private static Boolean CustomSound_NoSound = false; - private static String CustomSound_Sound = ""; - private static Boolean Cost = false; - private static Double Cost_Price = 0.0; - private static Boolean Command = false; - private static Boolean BungeeCommand = false; - private static Boolean CommandAsConsole = false; - private static List Commands = Arrays.asList(); - private static Boolean Server_Change = false; - private static String Server_Change_Server = ""; - private static Boolean OpenGUI = false; - private static String OpenGUI_GUI = ""; - private static Boolean Message = true; - private static List Messages = Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"); - private static Boolean Permission = false; - - private static Boolean SetConfig_Enable = false; - private static String SetConfig_FilePath = ""; - private static String SetConfig_OptionPath = ""; - private static String SetConfig_OptionPremat = "String"; - - private static String SetConfig_ValueLeftString = ""; - private static Boolean SetConfig_ValueLeftBoolean = false; - private static Integer SetConfig_ValueLeftInteger = 0; - private static Double SetConfig_ValueLeftDouble = 0.0; - private static List SetConfig_ValueLeftList = Arrays.asList(); - - private static String SetConfig_ValueRightString = ""; - private static Boolean SetConfig_ValueRightBoolean = false; - private static Integer SetConfig_ValueRightInteger = 0; - private static Double SetConfig_ValueRightDouble = 0.0; - private static List SetConfig_ValueRightList = Arrays.asList(); - - private static Boolean SetConfig_PluginReloadEnable = false; - private static String SetConfig_PluginReloadCommand = ""; - - - public static void configCreate() { Long long_ = Long.valueOf(System.currentTimeMillis()); send.console(Main.prefix + " §4Default GUI file (GUIs/default.yml) is loaded..."); File config = new File(Main.getPath(), "GUIs/default.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - set("GUI.Enable", GUI_Enable, yamlConfiguration); - set("GUI.Lines", GUI_Lines, yamlConfiguration); - set("GUI.Name", GUI_Name, yamlConfiguration); - set("GUI.FillItem.Enable", GUI_FillItem_Enable, yamlConfiguration); + set("GUI.Enable", true, yamlConfiguration); + set("GUI.Lines", 1, yamlConfiguration); + set("GUI.Name", "&5default &9GUI", yamlConfiguration); + set("GUI.FillItem.Enable", true, yamlConfiguration); if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - set("GUI.FillItem.GlassPaneCollor", GUI_FillItem_Item_1_8, yamlConfiguration); - } else set("GUI.FillItem.Item", GUI_FillItem_Item, yamlConfiguration); + set("GUI.FillItem.GlassPaneCollor", 15, yamlConfiguration); + } else set("GUI.FillItem.Item", "BLACK_STAINED_GLASS_PANE", yamlConfiguration); - set("Command.Alias", Command_Alias, yamlConfiguration); - set("Command.Permission.Required", Command_Permission, yamlConfiguration); - set("Slots.Example.Slot", slot, yamlConfiguration); - set("Slots.Example.Enable", enable, yamlConfiguration); - set("Slots.Example.Item.Empty", ItemEmty, yamlConfiguration); - set("Slots.Example.Item.Amount", ItemAmout, yamlConfiguration); + set("Command.Alias", true, yamlConfiguration); + set("Command.Permission.Required", true, yamlConfiguration); + set("Slots.SupportDiscord.Slot", 4, yamlConfiguration); + set("Slots.SupportDiscord.Enable", true, yamlConfiguration); + set("Slots.SupportDiscord.Item.Empty", false, yamlConfiguration); + set("Slots.SupportDiscord.Item.Amount", 1, yamlConfiguration); if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { - set("Slots.Example.Item.PlayerHead.Enable", Playerhead_enable, yamlConfiguration); - set("Slots.Example.Item.PlayerHead.Base64.Enable", base64_Enable, yamlConfiguration); - set("Slots.Example.Item.PlayerHead.Base64.Base64Value", base64value, yamlConfiguration); - set("Slots.Example.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", PlayerWhoHasOpenedTheGUI, yamlConfiguration); - set("Slots.Example.Item.PlayerHead.PlayerName", PlayerName, yamlConfiguration); + set("Slots.SupportDiscord.Item.PlayerHead.Enable", true, yamlConfiguration); + set("Slots.SupportDiscord.Item.PlayerHead.Base64.Enable", true, yamlConfiguration); + set("Slots.SupportDiscord.Item.PlayerHead.Base64.Base64Value", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19", yamlConfiguration); + set("Slots.SupportDiscord.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration); + set("Slots.SupportDiscord.Item.PlayerHead.PlayerName", "", yamlConfiguration); } if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - set("Slots.Example.Item.Material", "TNT", yamlConfiguration); - } else set("Slots.Example.Item.Material", Item, yamlConfiguration); - set("Slots.Example.Item.Name", Itemname, yamlConfiguration); - set("Slots.Example.Item.Lore", ItemLore, yamlConfiguration); - set("Slots.Example.CustomSound.Enable", CustomSound, yamlConfiguration); - set("Slots.Example.CustomSound.NoSound", CustomSound_NoSound, yamlConfiguration); - set("Slots.Example.CustomSound.Sound", CustomSound_Sound, yamlConfiguration); - set("Slots.Example.Cost.Enable", Cost, yamlConfiguration); - set("Slots.Example.Cost.Price", Cost_Price, yamlConfiguration); - set("Slots.Example.Command.Enable", Command, yamlConfiguration); - set("Slots.Example.Command.BungeeCommand", BungeeCommand, yamlConfiguration); - set("Slots.Example.Command.CommandAsConsole", CommandAsConsole, yamlConfiguration); - set("Slots.Example.Command.Command", Commands, yamlConfiguration); - set("Slots.Example.ServerChange.Enable", Server_Change, yamlConfiguration); - set("Slots.Example.ServerChange.Server", Server_Change_Server, yamlConfiguration); - set("Slots.Example.OpenGUI.Enable", OpenGUI, yamlConfiguration); - set("Slots.Example.OpenGUI.GUI", OpenGUI_GUI, yamlConfiguration); - set("Slots.Example.Message.Enable", Message, yamlConfiguration); - set("Slots.Example.Message.Message", Messages, yamlConfiguration); - set("Slots.Example.Permission.Required", Permission, yamlConfiguration); + set("Slots.SupportDiscord.Item.Material", "TNT", yamlConfiguration); + } else set("Slots.SupportDiscord.Item.Material", "", yamlConfiguration); + set("Slots.SupportDiscord.Item.Name", "&3Support Discord", yamlConfiguration); + set("Slots.SupportDiscord.Item.Lore", Arrays.asList("&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: §7http://dc.t2code.net"), + yamlConfiguration); + set("Slots.SupportDiscord.CustomSound.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.CustomSound.NoSound", false, yamlConfiguration); + set("Slots.SupportDiscord.CustomSound.Sound", "", yamlConfiguration); + set("Slots.SupportDiscord.Cost.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.Cost.Price", 0.0, yamlConfiguration); + set("Slots.SupportDiscord.Command.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.Command.BungeeCommand", false, yamlConfiguration); + set("Slots.SupportDiscord.Command.CommandAsConsole", false, yamlConfiguration); + set("Slots.SupportDiscord.Command.Command", Arrays.asList(), yamlConfiguration); + set("Slots.SupportDiscord.ServerChange.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.ServerChange.Server", "", yamlConfiguration); + set("Slots.SupportDiscord.OpenGUI.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.OpenGUI.GUI", "", yamlConfiguration); - set("Slots.Example.SetConfig.Enable", SetConfig_Enable, yamlConfiguration); - set("Slots.Example.SetConfig.File.Path", SetConfig_FilePath, yamlConfiguration); - set("Slots.Example.SetConfig.Option.Path", SetConfig_OptionPath, yamlConfiguration); - set("Slots.Example.SetConfig.Option.Premat", SetConfig_OptionPremat, yamlConfiguration); - set("Slots.Example.SetConfig.Value.LeftClick.String", SetConfig_ValueLeftString, yamlConfiguration); - set("Slots.Example.SetConfig.Value.LeftClick.Boolean", SetConfig_ValueLeftBoolean, yamlConfiguration); - set("Slots.Example.SetConfig.Value.LeftClick.Integer", SetConfig_ValueLeftInteger, yamlConfiguration); - set("Slots.Example.SetConfig.Value.LeftClick.Double", SetConfig_ValueLeftDouble, yamlConfiguration); - set("Slots.Example.SetConfig.Value.LeftClick.List", SetConfig_ValueLeftList, yamlConfiguration); - set("Slots.Example.SetConfig.Value.RightClick.String", SetConfig_ValueRightString, yamlConfiguration); - set("Slots.Example.SetConfig.Value.RightClick.Boolean", SetConfig_ValueRightBoolean, yamlConfiguration); - set("Slots.Example.SetConfig.Value.RightClick.Integer", SetConfig_ValueRightInteger, yamlConfiguration); - set("Slots.Example.SetConfig.Value.RightClick.Double", SetConfig_ValueRightDouble, yamlConfiguration); - set("Slots.Example.SetConfig.Value.RightClick.List", SetConfig_ValueRightList, yamlConfiguration); - set("Slots.Example.SetConfig.PluginReload.Enable", SetConfig_PluginReloadEnable, yamlConfiguration); - set("Slots.Example.SetConfig.PluginReload.Command", SetConfig_PluginReloadCommand, yamlConfiguration); + set("Slots.SupportDiscord.Toggle.Permission.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.Toggle.Permission.Permission", "", yamlConfiguration); + + set("Slots.SupportDiscord.Toggle.UseItem.Enable", false, yamlConfiguration); + + set("Slots.SupportDiscord.Message.Enable", true, yamlConfiguration); + set("Slots.SupportDiscord.Message.Message", Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"), yamlConfiguration); + set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration); + + set("Slots.SupportDiscord.SetConfig.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.File.Path", "", yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Option.Path", "", yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Option.Premat", "String", yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.LeftClick.String", "", yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Boolean", false, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Integer", 0, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Double", 0.0, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.LeftClick.List", Arrays.asList(), yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.RightClick.String", "", yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.RightClick.Boolean", false, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.RightClick.Integer", 0, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.RightClick.Double", 0.0, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.Value.RightClick.List", Arrays.asList(), yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.PluginReload.Enable", false, yamlConfiguration); + set("Slots.SupportDiscord.SetConfig.PluginReload.Command", "", yamlConfiguration); + + set("Slots.UseItem.Slot", 6, yamlConfiguration); + set("Slots.UseItem.Enable", true, yamlConfiguration); + set("Slots.UseItem.Item.Empty", false, yamlConfiguration); + set("Slots.UseItem.Item.Amount", 1, yamlConfiguration); + if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { + set("Slots.UseItem.Item.PlayerHead.Enable", false, yamlConfiguration); + set("Slots.UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration); + set("Slots.UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration); + set("Slots.UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration); + set("Slots.UseItem.Item.PlayerHead.PlayerName", "", yamlConfiguration); + } + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + set("Slots.UseItem.Item.Material", "", yamlConfiguration); + } else set("Slots.UseItem.Item.Material", "", yamlConfiguration); + set("Slots.UseItem.Item.Name", "&6Toggle UseItem", yamlConfiguration); + set("Slots.UseItem.Item.Lore", Arrays.asList("&bYou currently have the UseItem set to: %commandgui_useitem%"), + yamlConfiguration); + set("Slots.UseItem.CustomSound.Enable", false, yamlConfiguration); + set("Slots.UseItem.CustomSound.NoSound", false, yamlConfiguration); + set("Slots.UseItem.CustomSound.Sound", "", yamlConfiguration); + set("Slots.UseItem.Cost.Enable", false, yamlConfiguration); + set("Slots.UseItem.Cost.Price", 0.0, yamlConfiguration); + set("Slots.UseItem.Command.Enable", false, yamlConfiguration); + set("Slots.UseItem.Command.BungeeCommand", false, yamlConfiguration); + set("Slots.UseItem.Command.CommandAsConsole", false, yamlConfiguration); + set("Slots.UseItem.Command.Command", Arrays.asList(), yamlConfiguration); + set("Slots.UseItem.ServerChange.Enable", false, yamlConfiguration); + set("Slots.UseItem.ServerChange.Server", "", yamlConfiguration); + set("Slots.UseItem.OpenGUI.Enable", false, yamlConfiguration); + set("Slots.UseItem.OpenGUI.GUI", "", yamlConfiguration); + + set("Slots.UseItem.Toggle.Permission.Enable", false, yamlConfiguration); + + set("Slots.UseItem.Toggle.Permission.Permission", "", yamlConfiguration); + + set("Slots.UseItem.Toggle.UseItem.Enable", true, yamlConfiguration); + + set("Slots.UseItem.Message.Enable", true, yamlConfiguration); + set("Slots.UseItem.Message.Message", Arrays.asList("&bYour UseItem was set to: %commandgui_useitem%&b."), yamlConfiguration); + set("Slots.UseItem.Permission.Required", false, yamlConfiguration); + + set("Slots.UseItem.SetConfig.Enable", false, yamlConfiguration); + set("Slots.UseItem.SetConfig.File.Path", "", yamlConfiguration); + set("Slots.UseItem.SetConfig.Option.Path", "", yamlConfiguration); + set("Slots.UseItem.SetConfig.Option.Premat", "String", yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.LeftClick.String", "", yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.LeftClick.Boolean", false, yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.LeftClick.Integer", 0, yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.LeftClick.Double", 0.0, yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.LeftClick.List", Arrays.asList(), yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.RightClick.String", "", yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.RightClick.Boolean", false, yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.RightClick.Integer", 0, yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.RightClick.Double", 0.0, yamlConfiguration); + set("Slots.UseItem.SetConfig.Value.RightClick.List", Arrays.asList(), yamlConfiguration); + set("Slots.UseItem.SetConfig.PluginReload.Enable", false, yamlConfiguration); + set("Slots.UseItem.SetConfig.PluginReload.Command", "", yamlConfiguration); try { yamlConfiguration.save(config); } catch (IOException e) { e.printStackTrace(); } - - send.console(Main.prefix + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } 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 7d8bf2e..6c19a96 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 @@ -2,6 +2,7 @@ package de.jatitv.commandguiv2.Spigot.config.config; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Util; +import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; @@ -26,11 +27,11 @@ public class ConfigCreate { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); if (yamlConfiguration.getInt("ConfigVersion") < ConfigVersion && new File(Main.getPath(), "config.yml").exists()) { - 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----------------------"); + 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); @@ -110,6 +111,21 @@ public class ConfigCreate { Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration); Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration); + + Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration); + Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration); + Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration); + + Config.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration); + Config.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration); + Config.set("Toggle.Items.OffOrNo.Item.Material", ItemVersion.getRedWool().getType().toString(), yamlConfiguration); + + Config.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration); + Config.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration); + + Config.set("Placeholder.True", "&2true", yamlConfiguration); + Config.set("Placeholder.False", "&4false", yamlConfiguration); + Config.set("Sound.Enable", true, yamlConfiguration); Config.set("Sound.OpenInventory.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 3e071aa..7e7afbe 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 @@ -7,6 +7,7 @@ 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.replace.Replace; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.configuration.file.YamlConfiguration; @@ -22,6 +23,7 @@ public class SelectConfig { public static Boolean HelpAlias; public static String language; public static String Currency; + public static List mainCommands; public static String Storage; @@ -69,6 +71,20 @@ public class SelectConfig { public static String UseItem_Name; public static List UseItem_Lore; + public static Boolean toggleItemOnOrYesBase64; + public static String toggleItemOnOrYesBase64Value; + public static String toggleItemOnOrYesMaterial; + + public static Boolean toggleItemOffOrNoBase64; + public static String toggleItemOffOrNoBase64Value; + public static String toggleItemOffOrNoMaterial; + + public static String togglePermTrue; + public static String togglePermFalse; + + public static String placeholderTrue; + public static String placeholderFalse; + public static Boolean Sound_Enable = true; public static Boolean Sound_OpenInventory_Enable = true; @@ -140,7 +156,7 @@ public class SelectConfig { UseItem_Base64value = yamlConfiguration.getString("UseItem.Item.PlayerHead.Base64.Base64Value"); 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_Name = Replace.replace(Util.getPrefix(), yamlConfiguration.getString("UseItem.Item.Name")); UseItem_Lore = yamlConfiguration.getStringList("UseItem.Item.Lore"); UseItem_GiveOnEveryJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnEveryJoin"); UseItem_GiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnlyOnFirstJoin"); @@ -154,7 +170,7 @@ public class SelectConfig { UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled"); UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode"); List gml = new ArrayList<>(); - for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")){ + for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")) { gml.add(gm.toUpperCase()); } UseItemGameModeList = gml; @@ -164,7 +180,22 @@ public class SelectConfig { UseItemWorldProtection = yamlConfiguration.getBoolean("Advanced.UseItem.World.Protection.Enable"); UseItemWorldRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled"); UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode"); - UseItemWorldList =yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List"); + UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List"); + + + toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable"); + toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value"); + toggleItemOnOrYesMaterial = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Material"); + + toggleItemOffOrNoBase64 = yamlConfiguration.getBoolean("Toggle.Items.OffOrNo.Item.Base64.Enable"); + toggleItemOffOrNoBase64Value = yamlConfiguration.getString("Toggle.Items.OffOrNo.Item.Base64.Base64Value"); + toggleItemOffOrNoMaterial = yamlConfiguration.getString("Toggle.Items.OffOrNo.Item.Material"); + + togglePermTrue = yamlConfiguration.getString("Toggle.Permission.Commands.True"); + togglePermFalse = yamlConfiguration.getString("Toggle.Permission.Commands.False"); + + placeholderTrue = yamlConfiguration.getString("Placeholder.True"); + placeholderFalse = yamlConfiguration.getString("Placeholder.False"); Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable"); Sound_OpenInventory_Enable = yamlConfiguration.getBoolean("Sound.OpenInventory.Enable"); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java new file mode 100644 index 0000000..634afe8 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java @@ -0,0 +1,120 @@ +package de.jatitv.commandguiv2.Spigot.gui; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Spigot.Objekte.Slot; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Util; +import net.t2code.lib.Spigot.Lib.items.ItemVersion; +import net.t2code.lib.Spigot.Lib.replace.Replace; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; + +import java.lang.reflect.Field; +import java.util.UUID; + +public class GuiBuilder { + + private static String prefix = Util.getPrefix(); + + protected static void item(Slot slot, Player player, Inventory inventory) { + ItemStack item = new ItemStack(Material.valueOf(slot.item.toUpperCase().replace(".", "_"))); + ItemMeta itemMeta = item.getItemMeta(); + setMeta(itemMeta, player, slot); + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + protected static void item(String material, Slot slot, Player player, Inventory inventory) { + ItemStack item = new ItemStack(Material.valueOf(material)); + ItemMeta itemMeta = item.getItemMeta(); + setMeta(itemMeta, player, slot); + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) { + ItemStack item = ItemVersion.getHeadIS(); + SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); + setMeta(itemMeta, player, slot); + GameProfile profile = new GameProfile(UUID.randomUUID(), ""); + profile.getProperties().put("textures", new Property("textures", base64Value)); + Field profileField = null; + try { + profileField = itemMeta.getClass().getDeclaredField("profile"); + profileField.setAccessible(true); + profileField.set(itemMeta, profile); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { + e.printStackTrace(); + } + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + protected static void base64(Slot slot, Player player, Inventory inventory) { + ItemStack item = ItemVersion.getHeadIS(); + SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); + setMeta(itemMeta, player, slot); + GameProfile profile = new GameProfile(UUID.randomUUID(), ""); + profile.getProperties().put("textures", new Property("textures", slot.base64Value)); + Field profileField = null; + try { + profileField = itemMeta.getClass().getDeclaredField("profile"); + profileField.setAccessible(true); + profileField.set(itemMeta, profile); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { + e.printStackTrace(); + } + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + protected static void playerHead(Slot slot, Player player, Inventory inventory) { + ItemStack item = ItemVersion.getHeadIS(); + SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); + setMeta(itemMeta, player, slot); + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + private static void setMeta(ItemMeta itemMeta, Player player, Slot slot) { + if (Main.PaPi) { + itemMeta.setDisplayName(Replace.replace(prefix, player, slot.name.replace("[player]", player.getName()))); + itemMeta.setLore(Replace.replacePrice(prefix, player, slot.lore, slot.price + " " + SelectConfig.Currency)); + } else { + itemMeta.setDisplayName(Replace.replace(prefix, slot.name.replace("[player]", player.getName()))); + itemMeta.setLore(Replace.replacePrice(prefix, slot.lore, slot.price + " " + SelectConfig.Currency)); + } + } + +} 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 24c2b44..90cb951 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 @@ -1,8 +1,7 @@ package de.jatitv.commandguiv2.Spigot.gui; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Objekte.Slot; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; @@ -10,7 +9,6 @@ import de.jatitv.commandguiv2.Spigot.Objekte.Object; 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; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.replace.Replace; @@ -22,12 +20,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.Plugin; -import java.lang.reflect.Field; -import java.util.UUID; - public class OpenGUI { private static Plugin plugin = Main.plugin; private static String prefix = Util.getPrefix(); @@ -90,102 +84,47 @@ public class OpenGUI { } } for (Slot slot : gui.GUI_Slots) { - if (!slot.Perm - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)) - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)+".see") + if (!slot.perm + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1)) + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1) + ".see") || player.hasPermission("commandgui.admin")) { - if (slot.Enable) { - if (slot.Empty) { + if (slot.enable) { + if (slot.empty) { ItemStack air = new ItemStack(Material.AIR); - inventory.setItem(slot.Slot, air); + inventory.setItem(slot.slot, air); } else { - if (slot.PlayerHead_Enable) { - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.Slot + 1) + " §7- " + Replace.replace(prefix, slot.Name)); - send.error(plugin, "Playerheads are only available from version 1.13!"); - send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.Slot + 1) + " §7- " + Replace.replace(prefix, slot.Name)); + if (slot.togglePermission) { + if (player.hasPermission(slot.togglePermissionPerm)) { + toggleOn(slot, player, inventory); } else { - ItemStack item = ItemVersion.getHeadIS(); - SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); - if (slot.Base64_Enable) { - - if (Main.PaPi) { - itemMeta.setDisplayName(Replace.replace(prefix, player, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, player, slot.Lore, slot.Price + " " + SelectConfig.Currency)); - } else { - itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, slot.Lore, slot.Price + " " + SelectConfig.Currency)); - } - GameProfile profile = new GameProfile(UUID.randomUUID(), ""); - profile.getProperties().put("textures", new Property("textures", slot.Base64Value)); - Field profileField = null; - try { - profileField = itemMeta.getClass().getDeclaredField("profile"); - profileField.setAccessible(true); - profileField.set(itemMeta, profile); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - item.setItemMeta(itemMeta); - Integer am; - if (slot.ItemAmount == 0) { - am = 1; - } else am = slot.ItemAmount; - item.setAmount(am); - inventory.setItem(slot.Slot, item); - } else { - if (slot.PlayerWhoHasOpenedTheGUI) { - if (Main.PaPi) { - itemMeta.setDisplayName(Replace.replace(prefix, player, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, player, slot.Lore, slot.Price + " " + SelectConfig.Currency)); - } else { - itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, slot.Lore, slot.Price + " " + SelectConfig.Currency)); - } - itemMeta.setOwner(player.getName()); - item.setItemMeta(itemMeta); - Integer am; - if (slot.ItemAmount == 0) { - am = 1; - } else am = slot.ItemAmount; - item.setAmount(am); - inventory.setItem(slot.Slot, item); - } else { - if (Main.PaPi) { - itemMeta.setDisplayName(Replace.replace(prefix, player, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, player, slot.Lore, slot.Price + " " + SelectConfig.Currency)); - } else { - itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, player, slot.Lore, slot.Price + " " + SelectConfig.Currency)); - } - itemMeta.setOwner(slot.PlayerName); - item.setItemMeta(itemMeta); - Integer am; - if (slot.ItemAmount == 0) { - am = 1; - } else am = slot.ItemAmount; - item.setAmount(am); - inventory.setItem(slot.Slot, item); - } - } + toggleOff(slot, player, inventory); + } + } else if (slot.toggleUseItem) { + if (Events.useItemHashMap.get(player)) { + toggleOn(slot, player, inventory); + } else { + toggleOff(slot, player, inventory); } } else { - ItemStack item = new ItemStack(Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))); - ItemMeta itemMeta = item.getItemMeta(); - if (Main.PaPi) { - itemMeta.setDisplayName(Replace.replace(prefix, player, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, player, slot.Lore, slot.Price + " " + SelectConfig.Currency)); + if (slot.playerHead_Enable) { + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, slot.name)); + send.error(plugin, "Playerheads are only available from version 1.13!"); + send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, slot.name)); + } else { + if (slot.base64_Enable) { + GuiBuilder.base64(slot, player, inventory); + } else { + if (slot.playerWhoHasOpenedTheGUI) { + GuiBuilder.base64(slot, player, inventory); + } else { + GuiBuilder.playerHead(slot, player, inventory); + } + } + } } else { - itemMeta.setDisplayName(Replace.replace(prefix, slot.Name.replace("[player]", player.getName()))); - itemMeta.setLore(Replace.replacePrice(prefix, slot.Lore, slot.Price + " " + SelectConfig.Currency)); + GuiBuilder.item(slot, player, inventory); } - item.setItemMeta(itemMeta); - Integer am; - if (slot.ItemAmount == 0) { - am = 1; - } else am = slot.ItemAmount; - item.setAmount(am); - inventory.setItem(slot.Slot, item); } } } @@ -195,4 +134,16 @@ public class OpenGUI { send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name))); } + + private static void toggleOn(Slot slot, Player player, Inventory inventory) { + if (SelectConfig.toggleItemOnOrYesBase64) { + GuiBuilder.base64(SelectConfig.toggleItemOnOrYesBase64Value, slot, player, inventory); + } else GuiBuilder.item(SelectConfig.toggleItemOnOrYesMaterial, slot, player, inventory); + } + + private static void toggleOff(Slot slot, Player player, Inventory inventory) { + if (SelectConfig.toggleItemOffOrNoBase64) { + GuiBuilder.base64(SelectConfig.toggleItemOffOrNoBase64Value, slot, player, inventory); + } else GuiBuilder.item(SelectConfig.toggleItemOffOrNoMaterial, slot, player, inventory); + } } 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 63f4648..5b389ff 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 @@ -2,6 +2,7 @@ package de.jatitv.commandguiv2.Spigot.system; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; @@ -27,10 +28,10 @@ public class Give_UseItem { if (SelectConfig.UseItem_InventorySlotEnforce){ slot = SelectConfig.UseItem_InventorySlot; } else { - if (Select_Database.selectSlot(player) == null) { + if (Events.useItemSlotHashMap.get(player)== null) { slot = SelectConfig.UseItem_InventorySlot; } else { - slot = Select_Database.selectSlot(player); + slot = Events.useItemSlotHashMap.get(player); } } if (SelectConfig.UseItem_InventorySlot_FreeSlot) { 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 6a2daf8..db454b0 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,7 +2,7 @@ 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_GUI; +import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help; import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister; @@ -19,6 +19,7 @@ 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; +import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; @@ -70,6 +71,10 @@ public class Load { } } + if (PluginCheck.papi()){ + new Placeholder().register(); + } + try { LanguagesCreate.langCreate(); } catch (Exception e) { @@ -81,7 +86,7 @@ public class Load { e.printStackTrace(); } try { - CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); + CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); } catch (Exception e) { e.printStackTrace(); } @@ -99,6 +104,7 @@ public class Load { send.console(prefix + " §8-------------------------------"); if (SelectConfig.Storage.equals("MYSQL")) { MySQL.main(); + send.console(prefix + " §2Storage medium §6MySQL §2is used."); try { MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + " `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," + @@ -116,7 +122,7 @@ public class Load { } } else { - if (SelectConfig.Debug) send.console(prefix + " §6Storage medium §2YML §6is used."); + send.console(prefix + " §2Storage medium §6YML §2is used."); } if (Main.PaPi) { send.console(prefix + " §2PlaceholderAPI successfully connected!"); @@ -130,17 +136,14 @@ public class Load { e.printStackTrace(); } - // Main.plugin.getCommand("commandguiadmin").setExecutor(new CmdExecuter_Admin()); - // send.debug(plugin, "Commandregister: commandguiadmin"); - if (SelectConfig.HelpAlias) { Main.plugin.getCommand("commandguihelp").setExecutor(new CmdExecuter_Help()); - send.debug(plugin, "Commandregister: commandguihelp"); + send.debug(plugin, "CommandRegister: commandguihelp"); } - Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUI()); - send.debug(plugin, "Commandregister: commandgui"); + Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUITab()); + send.debug(plugin, "CommandRegister: commandgui"); Main.plugin.getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem()); - send.debug(plugin, "Commandregister: commandgui-item"); + send.debug(plugin, "CommandRegister: commandgui-item"); try { AliasRegister.onRegister(); @@ -148,7 +151,6 @@ public class Load { e.printStackTrace(); } - Bukkit.getServer().getPluginManager().registerEvents(new GUI_Listener(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new PluginEvent(), plugin); @@ -158,7 +160,6 @@ public class Load { Bukkit.getServer().getPluginManager().registerEvents(new Events_from1_10(), plugin); } - UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord); Metrics.Bstats(); Main.addonLoad(); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Placeholder.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Placeholder.java new file mode 100644 index 0000000..aa87c76 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Placeholder.java @@ -0,0 +1,56 @@ +// This claas was created by JaTiTV + +package de.jatitv.commandguiv2.Spigot.system; + +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; +import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import org.bukkit.entity.Player; + +public class Placeholder extends PlaceholderExpansion { + + @Override + public String getIdentifier() { + return "commandgui"; + } + + @Override + public String getAuthor() { + return Main.plugin.getDescription().getAuthors().toString(); + } + + @Override + public String getVersion() { + return Main.plugin.getDescription().getVersion(); + } + + @Override + public boolean canRegister() { + return true; + } + + @Override + public boolean persist() { + return true; + } + + @Override + public String onPlaceholderRequest(Player p, String params) { + if (params.contains("useitem_boolean")) { + return Events.useItemHashMap.get(p).toString(); + } + + if (params.contains("useitem")) { + if (Events.useItemHashMap.get(p)) { + return SelectConfig.placeholderTrue; + } else return SelectConfig.placeholderFalse; + } + + if (params.contains("slot")){ + return Events.useItemSlotHashMap.get(p).toString(); + } + + return null; + } +} \ No newline at end of file diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java index 4d883ab..e84ad77 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java @@ -13,8 +13,8 @@ public class RegisterPermissions { Bukkit.getPluginManager().addPermission(new Permission("commandgui.command." + gui.Command_Command)); } for (Slot slot : gui.GUI_Slots) { - if (Bukkit.getPluginManager().getPermission("commandgui." + gui.Command_Command + ".slot." + (slot.Slot + 1)) == null) { - Bukkit.getPluginManager().addPermission(new Permission("commandgui." + gui.Command_Command + ".slot." + (slot.Slot + 1))); + if (Bukkit.getPluginManager().getPermission("commandgui." + gui.Command_Command + ".slot." + (slot.slot + 1)) == null) { + Bukkit.getPluginManager().addPermission(new Permission("commandgui." + gui.Command_Command + ".slot." + (slot.slot + 1))); } } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java index e4786d6..49ddaf3 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java @@ -4,7 +4,6 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import de.jatitv.commandguiv2.Spigot.Main; import net.t2code.lib.Spigot.Lib.messages.send; -import org.bukkit.plugin.Plugin; import java.sql.*; import java.time.ZoneId; @@ -152,6 +151,6 @@ public class MySQL { } public static void close() { - ds.close(); + if (ds != null) ds.close(); } } 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 25e890a..8b838a7 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,5 +1,6 @@ package de.jatitv.commandguiv2.Spigot.system.database; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import org.bukkit.entity.Player; @@ -21,6 +22,7 @@ public class Select_Database { } public static void setItemStatusTrue(Player player) { + Events.useItemHashMap.replace(player, true); if (SelectConfig.Storage.equals("MYSQL")) { MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';"); @@ -30,6 +32,7 @@ public class Select_Database { } public static void setItemStatusFalse(Player player) { + Events.useItemHashMap.replace(player, false); if (SelectConfig.Storage.equals("MYSQL")) { MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() 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 30dd7ea..a79aebf 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,6 +1,7 @@ package de.jatitv.commandguiv2.api; import de.jatitv.commandguiv2.Spigot.Listener.ItemChange; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands; import de.jatitv.commandguiv2.Spigot.cmdManagement.Help; @@ -42,11 +43,11 @@ public class CGuiAPI { } public static Boolean selectPlayerItemEnable(Player player) { - return Select_Database.selectItemStatus(player); + return Events.useItemHashMap.get(player); } public static Integer selectPlayerItemSlot(Player player) { - return Select_Database.selectSlot(player); + return Events.useItemSlotHashMap.get(player); } public static void setPlayerItemEnable(Player player, Boolean value) { diff --git a/CommandGUI V2/src/main/resources/META-INF/MANIFEST.MF b/CommandGUI V2/src/main/resources/META-INF/MANIFEST.MF index 7f041a7..c51a347 100644 --- a/CommandGUI V2/src/main/resources/META-INF/MANIFEST.MF +++ b/CommandGUI V2/src/main/resources/META-INF/MANIFEST.MF @@ -1,5 +1,4 @@ Manifest-Version: 1.0 -Main-Class: Class-Path: PlugmanGUI-3.0.jar spigot-1.8r3.jar spigot-1.9r1.jar spigot- 1.15r1.jar T2CodeLib-10.3.jar spigot-1.18r1.jar bungee-1615.jar spigot- 1.9r2.jar spigot-1.16r3.jar spigot-1.14r1.jar slf4j-api-1.7.25.jar Luck -- 2.34.1 From 0c45b650b89c269c42f4b4ef85ae25582c24d18a Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Sat, 16 Apr 2022 14:32:41 +0200 Subject: [PATCH 02/16] Update pom.xml --- CommandGUI V2/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 76ea62d..54d8402 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,11 +6,7 @@ net.t2code CommandGUI_V2 -<<<<<<< Updated upstream - 2.6.1 -======= 2.6.10_Snapshot-1 ->>>>>>> Stashed changes jar CommandGUI -- 2.34.1 From 31a4f2d2adcc738bd62a4868474774df9c8bf7fc Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Sat, 16 Apr 2022 14:38:36 +0200 Subject: [PATCH 03/16] fix --- CommandGUI V2/pom.xml | 2 +- .../Spigot/Listener/GUI_Listener.java | 358 +----------------- 2 files changed, 2 insertions(+), 358 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 54d8402..42a4635 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -86,7 +86,7 @@ net.t2code T2CodeLib - 10.3 + 11.4 net.t2code 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 91d81d6..1bc4f84 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 @@ -24,6 +24,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; @@ -38,111 +39,6 @@ public class GUI_Listener implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent e) { Player player = (Player) e.getWhoClicked(); -<<<<<<< Updated upstream - if (e.getInventory() != null && e.getCurrentItem() != null) { - for (Object gui : Main.guiHashMap.values()) { - if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name)) - || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) { - e.setCancelled(true); - for (Slot slot : gui.GUI_Slots) { - /* if (!slot.ItemsRemovable) { - e.setCancelled(true); - } - */ - - if (e.getSlot() == slot.Slot) { - if (!slot.Perm - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)) - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use") - || player.hasPermission("commandgui.admin")) { - if (slot.Enable) { - if (e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.Name))) { - if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) { - if (slot.Cost_Enable) { - if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) { - if (Vault.buy(prefix, player, slot.Price)) { - player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name)) - .replace("[price]", slot.Price + " " + SelectConfig.Currency)); - if (slot.Command_Enable) { - - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - new BukkitRunnable() { - @Override - public void run() { - if (slot.Command_BungeeCommand && SelectConfig.Bungee) { - for (String cmd : slot.Command) { - Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole); - } - } else { - if (slot.CommandAsConsole) { - for (String cmd : slot.Command) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName())); - } - } else { - for (String cmd : slot.Command) { - player.chat("/" + cmd.replace("[player]", player.getName())); - } - } - } - } - }.runTaskLater(plugin, 2L); - } - if (slot.OpenGUI_Enable) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - - } - }.runTaskLater(plugin, 1L); - new BukkitRunnable() { - @Override - public void run() { - OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI); - } - }.runTaskLater(plugin, 2L); - } - if (slot.Message_Enable) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - for (String msg : slot.Message) { - if (Main.PaPi) { - player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.Price + " " + SelectConfig.Currency)); - } else - player.sendMessage(Replace.replacePrice(prefix, msg, slot.Price + " " + SelectConfig.Currency)); - } - } - if (slot.ServerChange) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer)); - new BukkitRunnable() { - @Override - public void run() { - ServerChange.send(player, slot.ServerChangeServer); - } - }.runTaskLater(Main.plugin, 20L); - } - if (slot.SetConfigEnable) { - File config = new File(slot.ConfigFilePath); - YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); -======= JavaPlugin plugin = Main.plugin; if (e.getInventory() == null) return; if (e.getCurrentItem() == null) return; @@ -281,258 +177,7 @@ public class GUI_Listener implements Listener { private static void setConfig(Slot slot, Player player, InventoryClickEvent e) { File config = new File(slot.configFilePath); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); ->>>>>>> Stashed changes - /*if (slot.ConfigChatInput){ - ConfigChat.EditChat.put(player, slot.ConfigOptionPath); - player.sendMessage(DefaultValue.SettingsGUIchatSet.replace("[setting]", "Shop Name Chest small")); - player.sendMessage(DefaultValue.SettingsGUIchatCancel); - } else - { - */ -<<<<<<< Updated upstream - if (e.getClick() == ClickType.LEFT) { - if (slot.ConfigOptionPremat.equals("String")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft); - } else if (slot.ConfigOptionPremat.equals("Boolean")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft); - } else if (slot.ConfigOptionPremat.equals("Integer")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft); - } else if (slot.ConfigOptionPremat.equals("Double")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft); - } else if (slot.ConfigOptionPremat.equals("List")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft); - } else { - player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo - } - } - if (e.getClick() == ClickType.RIGHT) { - if (slot.ConfigOptionPremat.equals("String")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight); - } else if (slot.ConfigOptionPremat.equals("Boolean")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight); - } else if (slot.ConfigOptionPremat.equals("Integer")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight); - } else if (slot.ConfigOptionPremat.equals("Double")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight); - } else if (slot.ConfigOptionPremat.equals("List")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight); - } else { - player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo - } - } - try { - yamlConfiguration.save(config); - } catch (IOException tac) { - tac.printStackTrace(); - } - if (slot.PluginReloadEnable) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand); - } - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - } - if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) { - if (slot.CustomSound_Enable) { - if (!slot.CustomSound_NoSound) { - try { - player.playSound(player.getLocation(), Sound.valueOf(slot.CustomSound_Sound.toUpperCase().replace(".", "_")), 3, 1); - - } catch (Exception e1) { - send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) - .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound)); - player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); - } - } - } else - player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); - } - - } else { - - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - player.sendMessage(SelectMessages.No_money); - if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) { - player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1); - } - } - } - } else { - if (slot.Command_Enable) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - new BukkitRunnable() { - @Override - public void run() { - if (slot.Command_BungeeCommand) { - if (SelectConfig.Bungee) { - for (String cmd : slot.Command) { - Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole); - } - } else { - send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config."); - send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config."); - } - - } else { - if (slot.CommandAsConsole) { - for (String cmd : slot.Command) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName())); - } - } else { - for (String cmd : slot.Command) { - player.chat("/" + cmd); - } - } - } - } - }.runTaskLater(plugin, 2L); - } - if (slot.OpenGUI_Enable) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - new BukkitRunnable() { - @Override - public void run() { - - OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI); - } - }.runTaskLater(plugin, 2L); - } - if (slot.Message_Enable) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - - for (String msg : slot.Message) { - if (Main.PaPi) { - player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix))); - } else - player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix))); - } - } - if (slot.ServerChange) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - - send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer)); - - - new BukkitRunnable() { - @Override - public void run() { - ServerChange.send(player, slot.ServerChangeServer); - } - }.runTaskLater(Main.plugin, 20L); - } - if (slot.SetConfigEnable) { - File config = new File(slot.ConfigFilePath); - YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - /*if (slot.ConfigChatInput){ - ConfigChat.EditChat.put(player, slot.ConfigOptionPath); - player.sendMessage(DefaultValue.SettingsGUIchatSet.replace("[setting]", "Shop Name Chest small")); - player.sendMessage(DefaultValue.SettingsGUIchatCancel); - } else - { - */ - if (e.isLeftClick()) { - if (slot.ConfigOptionPremat.equals("String")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft); - } else if (slot.ConfigOptionPremat.equals("Boolean")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft); - } else if (slot.ConfigOptionPremat.equals("Integer")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft); - } else if (slot.ConfigOptionPremat.equals("Double")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft); - } else if (slot.ConfigOptionPremat.equals("List")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft); - } else { - player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo - } - } - if (e.isRightClick()) { - if (slot.ConfigOptionPremat.equals("String")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight); - } else if (slot.ConfigOptionPremat.equals("Boolean")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight); - } else if (slot.ConfigOptionPremat.equals("Integer")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight); - } else if (slot.ConfigOptionPremat.equals("Double")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight); - } else if (slot.ConfigOptionPremat.equals("List")) { - yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight); - } else { - player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo - } - } - try { - yamlConfiguration.save(config); - } catch (IOException tac) { - tac.printStackTrace(); - } - if (slot.PluginReloadEnable) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand); - } - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - } - if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) { - if (slot.CustomSound_Enable) { - if (!slot.CustomSound_NoSound) { - try { - player.playSound(player.getLocation(), Sound.valueOf(slot.CustomSound_Sound.toUpperCase().replace(".", "_")), 3, 1); - - } catch (Exception e1) { - send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) - .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound)); - player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); - } - } - } else - player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); - } - } - } - } - } - } else { - player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name)) - .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))); - } - } - } -======= if (e.getClick() == ClickType.LEFT) { if (slot.configOptionPremat.equals("String")) { yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configStringValueLeft); @@ -589,7 +234,6 @@ public class GUI_Listener implements Listener { send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + slot.customSound_Sound)); player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); ->>>>>>> Stashed changes } } } -- 2.34.1 From 65a01513cefa89b4c2b7fbf093c9714871ff90cd Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Mon, 18 Apr 2022 23:12:50 +0200 Subject: [PATCH 04/16] Snapshot 3 --- CommandGUI V2/pom.xml | 2 +- .../Spigot/Listener/GUI_Listener.java | 13 +- .../Listener/UseItem_Listener/Events.java | 2 +- .../Spigot/cmdManagement/Commands.java | 4 +- .../register/RegisterCommand.java | 2 +- .../commandguiv2/Spigot/gui/GuiBuilder.java | 125 +++++++++--------- .../commandguiv2/Spigot/gui/OpenGUI.java | 21 +-- 7 files changed, 78 insertions(+), 91 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 42a4635..5dd6d0a 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.6.10_Snapshot-1 + 2.6.10_Snapshot-3 jar CommandGUI 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 1bc4f84..40c3cb6 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 @@ -124,18 +124,13 @@ public class GUI_Listener implements Listener { } private static void openGUI(Slot slot, Player player) { + player.closeInventory(); new BukkitRunnable() { @Override public void run() { - player.closeInventory(); + OpenGUI.openGUI(player, slot.openGUI); } }.runTaskLater(plugin, 1L); - new BukkitRunnable() { - @Override - public void run() { - OpenGUI.openGUI(player, Main.guiHashMap.get(slot.openGUI), slot.openGUI); - } - }.runTaskLater(plugin, 2L); } private static void message(Slot slot, Player player) { @@ -251,6 +246,4 @@ public class GUI_Listener implements Listener { Commands.itemOff(player); } else Commands.itemOn(player); } -} - - +} \ 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 4981627..f55d9e0 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 @@ -203,7 +203,7 @@ public class Events implements Listener { } } if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) { - OpenGUI.openGUI(p, Main.guiHashMap.get(SelectConfig.UseItem_OpenGUI), SelectConfig.UseItem_OpenGUI); + OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI); if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); } 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 f9ad4b2..1017f09 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 @@ -218,7 +218,7 @@ public class Commands { Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, gui, SelectConfig.DefaultGUI); + OpenGUI.openGUI(player, SelectConfig.DefaultGUI); if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); } @@ -233,7 +233,7 @@ public class Commands { Object gui = Main.guiHashMap.get(arg); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, gui, arg); + OpenGUI.openGUI(player, arg); if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); } 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 55fedd5..330a672 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 @@ -26,7 +26,7 @@ public class RegisterCommand extends Command { Object gui = Main.guiHashMap.get(alias); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, gui, alias); + OpenGUI.openGUI(player, alias); if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java index 634afe8..dca1cc2 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java @@ -3,10 +3,13 @@ package de.jatitv.commandguiv2.Spigot.gui; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Spigot.Objekte.Object; import de.jatitv.commandguiv2.Spigot.Objekte.Slot; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.replace.Replace; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -25,7 +28,7 @@ public class GuiBuilder { protected static void item(Slot slot, Player player, Inventory inventory) { ItemStack item = new ItemStack(Material.valueOf(slot.item.toUpperCase().replace(".", "_"))); ItemMeta itemMeta = item.getItemMeta(); - setMeta(itemMeta, player, slot); + setDisplayNameAndLore(itemMeta, player, slot); item.setItemMeta(itemMeta); Integer am; if (slot.itemAmount == 0) { @@ -38,7 +41,7 @@ public class GuiBuilder { protected static void item(String material, Slot slot, Player player, Inventory inventory) { ItemStack item = new ItemStack(Material.valueOf(material)); ItemMeta itemMeta = item.getItemMeta(); - setMeta(itemMeta, player, slot); + setDisplayNameAndLore(itemMeta, player, slot); item.setItemMeta(itemMeta); Integer am; if (slot.itemAmount == 0) { @@ -48,66 +51,8 @@ public class GuiBuilder { inventory.setItem(slot.slot, item); } - protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) { - ItemStack item = ItemVersion.getHeadIS(); - SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); - setMeta(itemMeta, player, slot); - GameProfile profile = new GameProfile(UUID.randomUUID(), ""); - profile.getProperties().put("textures", new Property("textures", base64Value)); - Field profileField = null; - try { - profileField = itemMeta.getClass().getDeclaredField("profile"); - profileField.setAccessible(true); - profileField.set(itemMeta, profile); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - item.setItemMeta(itemMeta); - Integer am; - if (slot.itemAmount == 0) { - am = 1; - } else am = slot.itemAmount; - item.setAmount(am); - inventory.setItem(slot.slot, item); - } - protected static void base64(Slot slot, Player player, Inventory inventory) { - ItemStack item = ItemVersion.getHeadIS(); - SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); - setMeta(itemMeta, player, slot); - GameProfile profile = new GameProfile(UUID.randomUUID(), ""); - profile.getProperties().put("textures", new Property("textures", slot.base64Value)); - Field profileField = null; - try { - profileField = itemMeta.getClass().getDeclaredField("profile"); - profileField.setAccessible(true); - profileField.set(itemMeta, profile); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - item.setItemMeta(itemMeta); - Integer am; - if (slot.itemAmount == 0) { - am = 1; - } else am = slot.itemAmount; - item.setAmount(am); - inventory.setItem(slot.slot, item); - } - - protected static void playerHead(Slot slot, Player player, Inventory inventory) { - ItemStack item = ItemVersion.getHeadIS(); - SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); - setMeta(itemMeta, player, slot); - item.setItemMeta(itemMeta); - Integer am; - if (slot.itemAmount == 0) { - am = 1; - } else am = slot.itemAmount; - item.setAmount(am); - inventory.setItem(slot.slot, item); - } - - private static void setMeta(ItemMeta itemMeta, Player player, Slot slot) { + private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Slot slot) { if (Main.PaPi) { itemMeta.setDisplayName(Replace.replace(prefix, player, slot.name.replace("[player]", player.getName()))); itemMeta.setLore(Replace.replacePrice(prefix, player, slot.lore, slot.price + " " + SelectConfig.Currency)); @@ -117,4 +62,62 @@ public class GuiBuilder { } } + protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) { + ItemStack item = ItemVersion.getHeadIS(); + SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); + setBase64(itemMeta, base64Value); + setDisplayNameAndLore(itemMeta, player, slot); + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + private static void setBase64(ItemMeta itemMeta, String base64Value) { + GameProfile profile = new GameProfile(UUID.randomUUID(), ""); + profile.getProperties().put("textures", new Property("textures", base64Value == null ? "" : base64Value)); + Field profileField; + try { + profileField = itemMeta.getClass().getDeclaredField("profile"); + profileField.setAccessible(true); + profileField.set(itemMeta, profile); + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { + e.printStackTrace(); + } + } + + protected static void base64(Slot slot, Player player, Inventory inventory) { + base64(slot.base64Value, slot, player, inventory); + } + + protected static void playerHead(Slot slot, Player player, Inventory inventory, String skullName) { + ItemStack item = ItemVersion.getHeadIS(); + SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); + setDisplayNameAndLore(itemMeta, player, slot); + itemMeta.setOwner(skullName); + item.setItemMeta(itemMeta); + Integer am; + if (slot.itemAmount == 0) { + am = 1; + } else am = slot.itemAmount; + item.setAmount(am); + inventory.setItem(slot.slot, item); + } + + public static void fillItem(Inventory inventory, Object gui) { + ItemStack glass; + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item)); + } else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_"))); + ItemMeta itemMetaglass = glass.getItemMeta(); + itemMetaglass.setDisplayName(" "); + glass.setItemMeta(itemMetaglass); + glass.setAmount(1); + for (int i = 0; i < 9 * gui.GUI_Lines; i++) { + inventory.setItem(i, glass); + } + } } 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 90cb951..017082f 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 @@ -26,7 +26,8 @@ public class OpenGUI { private static Plugin plugin = Main.plugin; private static String prefix = Util.getPrefix(); - public static void openGUI(Player player, Object gui, String guiString) { + public static void openGUI(Player player, String guiString) { + Object gui = Main.guiHashMap.get(guiString); Long long_ = Long.valueOf(System.currentTimeMillis()); switch (guiString) { //case "plugin.PlotSquaredGUI": @@ -67,21 +68,11 @@ public class OpenGUI { if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { Inventory inventory; if (Main.PaPi) { - inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name))); + inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name))); } else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name))); if (gui.GUI_FillItem_Enable) { - ItemStack glass; - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item)); - } else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_"))); - ItemMeta itemMetaglass = glass.getItemMeta(); - itemMetaglass.setDisplayName(" "); - glass.setItemMeta(itemMetaglass); - glass.setAmount(1); - for (int i = 0; i < 9 * gui.GUI_Lines; i++) { - inventory.setItem(i, glass); - } + GuiBuilder.fillItem(inventory, gui); } for (Slot slot : gui.GUI_Slots) { if (!slot.perm @@ -116,9 +107,9 @@ public class OpenGUI { GuiBuilder.base64(slot, player, inventory); } else { if (slot.playerWhoHasOpenedTheGUI) { - GuiBuilder.base64(slot, player, inventory); + GuiBuilder.playerHead(slot, player, inventory, player.getName()); } else { - GuiBuilder.playerHead(slot, player, inventory); + GuiBuilder.playerHead(slot, player, inventory,slot.playerName); } } } -- 2.34.1 From f2a666773f270f978a83383b7da2072e6cca641c Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 07:08:33 +0200 Subject: [PATCH 05/16] 2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui ' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised. --- CommandGUI V2/pom.xml | 2 +- .../Spigot/Listener/ConfigChat.java | 34 ---- .../Spigot/Listener/GUI_Listener.java | 105 +++++----- .../Listener/UseItem_Listener/Events.java | 2 - .../de/jatitv/commandguiv2/Spigot/Main.java | 8 +- .../Spigot/Objekte/Obj_Select.java | 115 ----------- .../cmdManagement/CmdExecuter_GUIItem.java | 3 +- .../cmdManagement/CmdExecuter_GUITab.java | 4 +- .../Spigot/cmdManagement/Commands.java | 8 +- .../Spigot/cmdManagement/Help.java | 4 +- .../register/RegisterCommand.java | 4 +- .../Spigot/config/DefaultGUICreate.java | 185 ------------------ .../Spigot/config/config/ConfigCreate.java | 15 +- .../Spigot/config/config/SelectConfig.java | 29 ++- .../ConfigConverterUnderV5.java | 176 +++++++++++++++++ .../config/functions/CreateFunctions.java | 146 ++++++++++++++ .../Spigot/config/gui/CreateGUI.java | 72 +++++++ .../commandguiv2/Spigot/gui/GuiBuilder.java | 55 +++--- .../commandguiv2/Spigot/gui/OpenGUI.java | 94 ++++----- .../Spigot/objects/Obj_Select.java | 162 +++++++++++++++ .../functions/Function.java} | 111 +++++------ .../Object.java => objects/guis/Gui.java} | 14 +- .../Spigot/objects/slots/Slot.java | 28 +++ .../commandguiv2/Spigot/system/Load.java | 22 ++- .../Spigot/system/RegisterPermissions.java | 16 +- .../Spigot/system/database/YML.java | 2 +- .../java/de/jatitv/commandguiv2/Util.java | 5 + .../de/jatitv/commandguiv2/api/CGuiAPI.java | 4 +- 28 files changed, 850 insertions(+), 575 deletions(-) delete mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java delete mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java delete mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/functions/CreateFunctions.java create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{Objekte/Slot.java => objects/functions/Function.java} (61%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/{Objekte/Object.java => objects/guis/Gui.java} (61%) create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/slots/Slot.java diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 5dd6d0a..dac2e8e 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.6.10_Snapshot-3 + 2.7.0_Snapshot-1 jar CommandGUI diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java deleted file mode 100644 index a02403a..0000000 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/ConfigChat.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.jatitv.commandguiv2.Spigot.Listener; - -import de.jatitv.commandguiv2.Spigot.Objekte.Slot; -import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.Objekte.Object; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; - -import java.util.HashMap; - -public class ConfigChat implements Listener { - public static HashMap EditChat = new HashMap<>(); - - @EventHandler - public void onChat(AsyncPlayerChatEvent playerChatEvent) { - Player player = playerChatEvent.getPlayer(); - if (EditChat.containsKey(player)) { - if (playerChatEvent.getMessage().equals("cancel")) { - //player.sendMessage(DefaultValue.SettingsGUIchatIsCanceled.replace("[setting]", EditChat.get(player))); - } else { - for (Object gui : Main.guiHashMap.values()) { - for (Slot slot : gui.GUI_Slots) { - if (slot.configOptionPath.equals(EditChat.get(player))) { - - - } - } - } - } - } - } -} 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 40c3cb6..d0d0dc0 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 @@ -1,11 +1,12 @@ package de.jatitv.commandguiv2.Spigot.Listener; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; -import de.jatitv.commandguiv2.Spigot.Objekte.Slot; +import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands; +import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import de.jatitv.commandguiv2.Spigot.system.Bungee_Sender_Reciver; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; -import de.jatitv.commandguiv2.Spigot.Objekte.Object; +import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.Main; @@ -42,58 +43,60 @@ public class GUI_Listener implements Listener { JavaPlugin plugin = Main.plugin; if (e.getInventory() == null) return; if (e.getCurrentItem() == null) return; - for (Object gui : Main.guiHashMap.values()) { + for (Gui gui : Main.guiHashMap.values()) { if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name)) || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) { e.setCancelled(true); - for (Slot slot : gui.GUI_Slots) { + for (Slot slot : gui.slots) { + Function function = Main.functionHashMap.get(slot.function); if (e.getSlot() != slot.slot) continue; - if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() || e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() || e.getCurrentItem().getType() == Material.valueOf(slot.item.toUpperCase().replace(".", "_"))) { - if (!slot.perm - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1)) - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1) + ".use") - || player.hasPermission("commandgui.admin")) { - if (!slot.enable) continue; - if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.name))) continue; - if (slot.cost_Enable) { - if (slot.command_Enable || slot.message_Enable || slot.openGUI_Enable || slot.serverChange) { - if (!Vault.buy(prefix, player, slot.price)) { - new BukkitRunnable() { - @Override - public void run() { - player.closeInventory(); - } - }.runTaskLater(plugin, 1L); - player.sendMessage(SelectMessages.No_money); - if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) - player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1); - } else { - player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.name)) - .replace("[price]", slot.price + " " + SelectConfig.Currency)); - execute(slot, player, e, gui); - } + if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() || + e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() || + e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) { + if (slot.permission || !player.hasPermission(slot.permissionToUse)) { + player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name)) + .replace("[perm]", slot.permissionToUse)); + continue; + } + if (!slot.enable) continue; + if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, function.name))) continue; + if (function.cost_Enable) { + if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) { + if (!Vault.buy(prefix, player, function.price)) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + player.sendMessage(SelectMessages.No_money); + if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) + player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1); + } else { + player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name)) + .replace("[price]", function.price + " " + SelectConfig.Currency)); + execute(function, slot, player, e, gui); } - } else execute(slot, player, e, gui); - } else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.name)) - .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1))); + } + } else execute(function, slot, player, e, gui); } } } } } - private static void execute(Slot slot, Player player, InventoryClickEvent e, Object gui) { - if (slot.togglePermission) togglePerm(slot, player); - if (slot.toggleUseItem) toggleUseItem(player); - if (slot.command_Enable) command(slot, player); - if (slot.openGUI_Enable) openGUI(slot, player); - if (slot.message_Enable) message(slot, player); - if (slot.serverChange) serverChange(slot, player); - if (slot.setConfigEnable) setConfig(slot, player, e); - if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(slot, player, gui); + private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) { + if (function.togglePermission) togglePerm(function, player); + if (function.toggleUseItem) toggleUseItem(player); + if (function.command_Enable) command(function, player); + if (function.openGUI_Enable) openGUI(function, player); + if (function.message_Enable) message(function, player); + if (function.serverChange) serverChange(function, player); + if (function.setConfigEnable) setConfig(function, player, e); + if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(function, slot, player, gui); } - private static void command(Slot slot, Player player) { + private static void command(Function slot, Player player) { new BukkitRunnable() { @Override public void run() { @@ -123,7 +126,7 @@ public class GUI_Listener implements Listener { }.runTaskLater(plugin, 2L); } - private static void openGUI(Slot slot, Player player) { + private static void openGUI(Function slot, Player player) { player.closeInventory(); new BukkitRunnable() { @Override @@ -133,7 +136,7 @@ public class GUI_Listener implements Listener { }.runTaskLater(plugin, 1L); } - private static void message(Slot slot, Player player) { + private static void message(Function slot, Player player) { new BukkitRunnable() { @Override public void run() { @@ -153,7 +156,7 @@ public class GUI_Listener implements Listener { } } - private static void serverChange(Slot slot, Player player) { + private static void serverChange(Function slot, Player player) { new BukkitRunnable() { @Override public void run() { @@ -169,7 +172,7 @@ public class GUI_Listener implements Listener { }.runTaskLater(Main.plugin, 20L); } - private static void setConfig(Slot slot, Player player, InventoryClickEvent e) { + private static void setConfig(Function slot, Player player, InventoryClickEvent e) { File config = new File(slot.configFilePath); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); @@ -219,22 +222,22 @@ public class GUI_Listener implements Listener { }.runTaskLater(plugin, 1L); } - private static void sound(Slot slot, Player player, Object gui) { - if (slot.customSound_Enable) { - if (!slot.customSound_NoSound) { + private static void sound(Function function, Slot slot, Player player, Gui gui) { + if (function.customSound_Enable) { + if (!function.customSound_NoSound) { try { - player.playSound(player.getLocation(), Sound.valueOf(slot.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1); + player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1); } catch (Exception e1) { send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) - .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + slot.customSound_Sound)); + .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound)); player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); } } } } - private static void togglePerm(Slot slot, Player player) { + private static void togglePerm(Function slot, Player player) { if (player.hasPermission(slot.togglePermissionPerm)) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm)); } else 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 f55d9e0..7906ce2 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 @@ -2,14 +2,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.Objekte.Object; 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.Spigot.system.database.Select_Database; import de.jatitv.commandguiv2.api.CGuiAPI; -import net.t2code.lib.Bungee.Lib.messages.Bsend; import net.t2code.lib.Spigot.Lib.items.ItemVersion; 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/Main.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java index 040854a..6976b71 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java @@ -1,9 +1,9 @@ package de.jatitv.commandguiv2.Spigot; //s guiHashMap = new HashMap<>(); + public static HashMap guiHashMap = new HashMap<>(); public static ArrayList allAliases = new ArrayList<>(); + public static HashMap functionHashMap = new HashMap<>(); + @Override public void onEnable() { plugins = Arrays.asList(getServer().getPluginManager().getPlugins()); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java deleted file mode 100644 index 43d20c3..0000000 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java +++ /dev/null @@ -1,115 +0,0 @@ -package de.jatitv.commandguiv2.Spigot.Objekte; - -import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; -import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; - -public class Obj_Select { - public static void onSelect() { - Main.guiHashMap.clear(); - Main.allAliases.clear(); - File f = new File(Main.getPath() + "/GUIs/"); - File[] fileArray = f.listFiles(); - - for (File config_gui : fileArray) { - String sub = config_gui.getName().substring(config_gui.getName().length() - 4); - if (sub.equals(".yml")) { - Main.allAliases.add(config_gui.getName().replace(".yml", "")); - YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui); - - Boolean GUI_Enable = yamlConfiguration_gui.getBoolean("GUI.Enable"); - Integer GUI_Lines = yamlConfiguration_gui.getInt("GUI.Lines"); - if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) { - yamlConfiguration_gui.set("GUI.Lines", 6); - } - if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) { - yamlConfiguration_gui.set("GUI.Lines", 1); - } - String GUI_Name = yamlConfiguration_gui.getString("GUI.Name"); - Boolean GUI_FillItem_Enable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable"); - String GUI_FillItem_Item; - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - GUI_FillItem_Item = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneCollor"); - } else GUI_FillItem_Item = yamlConfiguration_gui.getString("GUI.FillItem.Item"); - - Boolean Command_Alias_Enable = yamlConfiguration_gui.getBoolean("Command.Alias"); - Boolean Command_Permission = yamlConfiguration_gui.getBoolean("Command.Permission.Required"); - - ArrayList slots = new ArrayList<>(); - for (String key : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) { - Slot slot = new Slot(yamlConfiguration_gui.getInt("Slots." + key + ".Slot") - 1, - yamlConfiguration_gui.getBoolean("Slots." + key + ".Enable"), - // yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.Removable"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.Empty"), - yamlConfiguration_gui.getInt("Slots." + key + ".Item.Amount"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.PlayerHead.Enable"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.PlayerHead.Base64.Enable"), - yamlConfiguration_gui.getString("Slots." + key + ".Item.PlayerHead.Base64.Base64Value"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Item.PlayerHead.PlayerWhoHasOpenedTheGUI"), - yamlConfiguration_gui.getString("Slots." + key + ".Item.PlayerHead.PlayerName"), - yamlConfiguration_gui.getString("Slots." + key + ".Item.Material"), - yamlConfiguration_gui.getString("Slots." + key + ".Item.Name"), - yamlConfiguration_gui.getStringList("Slots." + key + ".Item.Lore"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".CustomSound.Enable"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".CustomSound.NoSound"), - yamlConfiguration_gui.getString("Slots." + key + ".CustomSound.Sound"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Cost.Enable"), - yamlConfiguration_gui.getDouble("Slots." + key + ".Cost.Price"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Command.Enable"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Command.BungeeCommand"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Command.CommandAsConsole"), - yamlConfiguration_gui.getStringList("Slots." + key + ".Command.Command"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".ServerChange.Enable"), - yamlConfiguration_gui.getString("Slots." + key + ".ServerChange.Server"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".OpenGUI.Enable"), - yamlConfiguration_gui.getString("Slots." + key + ".OpenGUI.GUI"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Toggle.Permission.Enable"), - yamlConfiguration_gui.getString("Slots." + key + ".Toggle.Permission.Permission"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Toggle.UseItem.Enable"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Message.Enable"), - yamlConfiguration_gui.getStringList("Slots." + key + ".Message.Message"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Enable"), - yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.File.Path"), - yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Option.Path"), - yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Option.Premat"), - // yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Value.ChatInput"), - - yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Value.LeftClick.String"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Value.LeftClick.Boolean"), - yamlConfiguration_gui.getInt("Slots." + key + ".SetConfig.Value.LeftClick.Integer"), - yamlConfiguration_gui.getDouble("Slots." + key + ".SetConfig.Value.LeftClick.Double"), - yamlConfiguration_gui.getStringList("Slots." + key + ".SetConfig.Value.LeftClick.List"), - - yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.Value.RightClick.String"), - yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.Value.RightClick.Boolean"), - yamlConfiguration_gui.getInt("Slots." + key + ".SetConfig.Value.RightClick.Integer"), - yamlConfiguration_gui.getDouble("Slots." + key + ".SetConfig.Value.RightClick.Double"), - yamlConfiguration_gui.getStringList("Slots." + key + ".SetConfig.RightClick.Value.List"), - - yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable"), - yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.PluginReload.Command")); - slots.add(slot); - - } - Object objekt = new Object(GUI_Enable, GUI_Lines, GUI_Name, GUI_FillItem_Enable, GUI_FillItem_Item, - config_gui.getName().replace(".yml", ""), Command_Alias_Enable, Command_Permission, slots); - - Main.guiHashMap.put(config_gui.getName().replace(".yml", ""), objekt); - CmdExecuter_GUITab.arg1.put(config_gui.getName().replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", "")); - - try { - yamlConfiguration_gui.save(config_gui); - } catch (IOException e) { - e.printStackTrace(); - } - } - - } - } -} 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 f94abd8..c35683b 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 @@ -55,7 +55,8 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter { } else sender.sendMessage(SelectMessages.OnlyForPlayer); } } - } else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui-item").replace("[perm]", "commandgui.useitem.toggle")); + } else sender.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui-item") + .replace("[perm]", "commandgui.useitem.toggle")); return false; } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUITab.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUITab.java index ff4a795..b8b7ce7 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUITab.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/CmdExecuter_GUITab.java @@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.system.Debug; -import de.jatitv.commandguiv2.Spigot.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.commands.Tab; @@ -56,7 +56,7 @@ public class CmdExecuter_GUITab implements CommandExecutor, TabCompleter { break; case "createdefaultgui": if (sender.hasPermission("commandgui.admin")) { - DefaultGUICreate.configCreate(); + CreateGUI.configCreate(); sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "/GUIs/default.yml")); } else sender.sendMessage(SelectMessages.NoPermissionForCommand .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); 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 1017f09..0dc832a 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 @@ -2,8 +2,8 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; 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.Objekte.Object; +import de.jatitv.commandguiv2.Spigot.objects.Obj_Select; +import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.system.Give_UseItem; @@ -215,7 +215,7 @@ public class Commands { public static void gui(Player player) { if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) { - Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); + Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, SelectConfig.DefaultGUI); @@ -230,7 +230,7 @@ public class Commands { public static void gui(Player player, String arg) { if (Main.guiHashMap.containsKey(arg)) { - Object gui = Main.guiHashMap.get(arg); + Gui gui = Main.guiHashMap.get(arg); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, arg); 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 2748c9c..1483836 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 @@ -2,7 +2,7 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement; 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.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; @@ -14,7 +14,7 @@ public class Help { public static void sendHelp(CommandSender sender, String Prefix) { send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----"); if (sender.hasPermission("commandgui.command")) { - Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); + Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.GUI_Name))); for (String alias : Main.allAliases) { if (Main.guiHashMap.get(alias).GUI_Enable || sender.hasPermission("commandgui.bypass")) { 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 330a672..9f5cb9b 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 @@ -2,7 +2,7 @@ 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.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; @@ -23,7 +23,7 @@ public class RegisterCommand extends Command { if (sender instanceof Player) { Player player = (Player) sender; - Object gui = Main.guiHashMap.get(alias); + Gui gui = Main.guiHashMap.get(alias); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, alias); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java deleted file mode 100644 index c55b254..0000000 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/DefaultGUICreate.java +++ /dev/null @@ -1,185 +0,0 @@ -package de.jatitv.commandguiv2.Spigot.config; - -import de.jatitv.commandguiv2.Spigot.Main; -import net.t2code.lib.Spigot.Lib.messages.send; -import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - - -public class DefaultGUICreate { - public static void configCreate() { - Long long_ = Long.valueOf(System.currentTimeMillis()); - send.console(Main.prefix + " §4Default GUI file (GUIs/default.yml) is loaded..."); - File config = new File(Main.getPath(), "GUIs/default.yml"); - YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - - set("GUI.Enable", true, yamlConfiguration); - set("GUI.Lines", 1, yamlConfiguration); - set("GUI.Name", "&5default &9GUI", yamlConfiguration); - set("GUI.FillItem.Enable", true, yamlConfiguration); - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - set("GUI.FillItem.GlassPaneCollor", 15, yamlConfiguration); - } else set("GUI.FillItem.Item", "BLACK_STAINED_GLASS_PANE", yamlConfiguration); - - set("Command.Alias", true, yamlConfiguration); - set("Command.Permission.Required", true, yamlConfiguration); - set("Slots.SupportDiscord.Slot", 4, yamlConfiguration); - set("Slots.SupportDiscord.Enable", true, yamlConfiguration); - set("Slots.SupportDiscord.Item.Empty", false, yamlConfiguration); - set("Slots.SupportDiscord.Item.Amount", 1, yamlConfiguration); - if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { - set("Slots.SupportDiscord.Item.PlayerHead.Enable", true, yamlConfiguration); - set("Slots.SupportDiscord.Item.PlayerHead.Base64.Enable", true, yamlConfiguration); - set("Slots.SupportDiscord.Item.PlayerHead.Base64.Base64Value", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19", yamlConfiguration); - set("Slots.SupportDiscord.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration); - set("Slots.SupportDiscord.Item.PlayerHead.PlayerName", "", yamlConfiguration); - } - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - set("Slots.SupportDiscord.Item.Material", "TNT", yamlConfiguration); - } else set("Slots.SupportDiscord.Item.Material", "", yamlConfiguration); - set("Slots.SupportDiscord.Item.Name", "&3Support Discord", yamlConfiguration); - set("Slots.SupportDiscord.Item.Lore", Arrays.asList("&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: §7http://dc.t2code.net"), - yamlConfiguration); - set("Slots.SupportDiscord.CustomSound.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.CustomSound.NoSound", false, yamlConfiguration); - set("Slots.SupportDiscord.CustomSound.Sound", "", yamlConfiguration); - set("Slots.SupportDiscord.Cost.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.Cost.Price", 0.0, yamlConfiguration); - set("Slots.SupportDiscord.Command.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.Command.BungeeCommand", false, yamlConfiguration); - set("Slots.SupportDiscord.Command.CommandAsConsole", false, yamlConfiguration); - set("Slots.SupportDiscord.Command.Command", Arrays.asList(), yamlConfiguration); - set("Slots.SupportDiscord.ServerChange.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.ServerChange.Server", "", yamlConfiguration); - set("Slots.SupportDiscord.OpenGUI.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.OpenGUI.GUI", "", yamlConfiguration); - - set("Slots.SupportDiscord.Toggle.Permission.Enable", false, yamlConfiguration); - - set("Slots.SupportDiscord.Toggle.Permission.Permission", "", yamlConfiguration); - - set("Slots.SupportDiscord.Toggle.UseItem.Enable", false, yamlConfiguration); - - set("Slots.SupportDiscord.Message.Enable", true, yamlConfiguration); - set("Slots.SupportDiscord.Message.Message", Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"), yamlConfiguration); - set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration); - - set("Slots.SupportDiscord.SetConfig.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.File.Path", "", yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Option.Path", "", yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Option.Premat", "String", yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.LeftClick.String", "", yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Boolean", false, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Integer", 0, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.LeftClick.Double", 0.0, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.LeftClick.List", Arrays.asList(), yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.RightClick.String", "", yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.RightClick.Boolean", false, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.RightClick.Integer", 0, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.RightClick.Double", 0.0, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.Value.RightClick.List", Arrays.asList(), yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.PluginReload.Enable", false, yamlConfiguration); - set("Slots.SupportDiscord.SetConfig.PluginReload.Command", "", yamlConfiguration); - - set("Slots.UseItem.Slot", 6, yamlConfiguration); - set("Slots.UseItem.Enable", true, yamlConfiguration); - set("Slots.UseItem.Item.Empty", false, yamlConfiguration); - set("Slots.UseItem.Item.Amount", 1, yamlConfiguration); - if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { - set("Slots.UseItem.Item.PlayerHead.Enable", false, yamlConfiguration); - set("Slots.UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration); - set("Slots.UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration); - set("Slots.UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration); - set("Slots.UseItem.Item.PlayerHead.PlayerName", "", yamlConfiguration); - } - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - set("Slots.UseItem.Item.Material", "", yamlConfiguration); - } else set("Slots.UseItem.Item.Material", "", yamlConfiguration); - set("Slots.UseItem.Item.Name", "&6Toggle UseItem", yamlConfiguration); - set("Slots.UseItem.Item.Lore", Arrays.asList("&bYou currently have the UseItem set to: %commandgui_useitem%"), - yamlConfiguration); - set("Slots.UseItem.CustomSound.Enable", false, yamlConfiguration); - set("Slots.UseItem.CustomSound.NoSound", false, yamlConfiguration); - set("Slots.UseItem.CustomSound.Sound", "", yamlConfiguration); - set("Slots.UseItem.Cost.Enable", false, yamlConfiguration); - set("Slots.UseItem.Cost.Price", 0.0, yamlConfiguration); - set("Slots.UseItem.Command.Enable", false, yamlConfiguration); - set("Slots.UseItem.Command.BungeeCommand", false, yamlConfiguration); - set("Slots.UseItem.Command.CommandAsConsole", false, yamlConfiguration); - set("Slots.UseItem.Command.Command", Arrays.asList(), yamlConfiguration); - set("Slots.UseItem.ServerChange.Enable", false, yamlConfiguration); - set("Slots.UseItem.ServerChange.Server", "", yamlConfiguration); - set("Slots.UseItem.OpenGUI.Enable", false, yamlConfiguration); - set("Slots.UseItem.OpenGUI.GUI", "", yamlConfiguration); - - set("Slots.UseItem.Toggle.Permission.Enable", false, yamlConfiguration); - - set("Slots.UseItem.Toggle.Permission.Permission", "", yamlConfiguration); - - set("Slots.UseItem.Toggle.UseItem.Enable", true, yamlConfiguration); - - set("Slots.UseItem.Message.Enable", true, yamlConfiguration); - set("Slots.UseItem.Message.Message", Arrays.asList("&bYour UseItem was set to: %commandgui_useitem%&b."), yamlConfiguration); - set("Slots.UseItem.Permission.Required", false, yamlConfiguration); - - set("Slots.UseItem.SetConfig.Enable", false, yamlConfiguration); - set("Slots.UseItem.SetConfig.File.Path", "", yamlConfiguration); - set("Slots.UseItem.SetConfig.Option.Path", "", yamlConfiguration); - set("Slots.UseItem.SetConfig.Option.Premat", "String", yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.LeftClick.String", "", yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.LeftClick.Boolean", false, yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.LeftClick.Integer", 0, yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.LeftClick.Double", 0.0, yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.LeftClick.List", Arrays.asList(), yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.RightClick.String", "", yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.RightClick.Boolean", false, yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.RightClick.Integer", 0, yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.RightClick.Double", 0.0, yamlConfiguration); - set("Slots.UseItem.SetConfig.Value.RightClick.List", Arrays.asList(), yamlConfiguration); - set("Slots.UseItem.SetConfig.PluginReload.Enable", false, yamlConfiguration); - set("Slots.UseItem.SetConfig.PluginReload.Command", "", yamlConfiguration); - - try { - yamlConfiguration.save(config); - } catch (IOException e) { - e.printStackTrace(); - } - send.console(Main.prefix + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); - } - - private static void set(String path, String value, YamlConfiguration config) { - if (!config.contains(path)) { - config.set(path, value); - } - } - - private static void set(String path, Integer value, YamlConfiguration config) { - if (!config.contains(path)) { - config.set(path, value); - } - } - - private static void set(String path, Boolean value, YamlConfiguration config) { - if (!config.contains(path)) { - config.set(path, value); - } - } - - private static void set(String path, List value, YamlConfiguration config) { - if (!config.contains(path)) { - config.set(path, value); - } - } - - private static void set(String path, Double value, YamlConfiguration config) { - if (!config.contains(path)) { - config.set(path, value); - } - } -} 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 6c19a96..5f285d1 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 @@ -15,10 +15,8 @@ import java.util.Arrays; public class ConfigCreate { - public static Integer ConfigVersion = 4; - public static void configCreate() { - Long long_ = Long.valueOf(System.currentTimeMillis()); + long long_ = 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..."); @@ -26,15 +24,8 @@ public class ConfigCreate { File config = new File(Main.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - if (yamlConfiguration.getInt("ConfigVersion") < ConfigVersion && new File(Main.getPath(), "config.yml").exists()) { - 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----------------------"); - } + if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration); - yamlConfiguration.set("ConfigVersion", ConfigVersion); Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration); Config.set("Plugin.Debug", false, yamlConfiguration); @@ -171,6 +162,6 @@ public class ConfigCreate { } catch (IOException e) { e.printStackTrace(); } - send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } } 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 7e7afbe..659ad25 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 @@ -1,22 +1,26 @@ package de.jatitv.commandguiv2.Spigot.config.config; import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; 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; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.replace.Replace; -import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; public class SelectConfig { + private static final File config = new File(Main.getPath(), "config.yml"); + private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + public static Boolean DisableUpdateChecker; public static Boolean UpdateCheckOnJoin; public static Boolean Debug; @@ -113,8 +117,17 @@ public class SelectConfig { public static void onSelect() { - File config = new File(Main.getPath(), "config.yml"); - YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) { + 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----------------------"); + if (yamlConfiguration.getInt("ConfigVersion") < 5) { + ConfigConverterUnderV5.convert(); + } + } + if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) { DisableUpdateChecker = false; @@ -211,6 +224,7 @@ public class SelectConfig { Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_")); Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable"); Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_")); + setConfigVersion(); } @@ -333,4 +347,13 @@ public class SelectConfig { } } + + private static void setConfigVersion() { + yamlConfiguration.set("ConfigVersion", Util.getConfigVersion()); + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java new file mode 100644 index 0000000..f8f5375 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java @@ -0,0 +1,176 @@ +package de.jatitv.commandguiv2.Spigot.config.configConverter; + +import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions; +import de.jatitv.commandguiv2.Util; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; +import org.apache.commons.io.FileUtils; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +public class ConfigConverterUnderV5 { + public static void convert() { + renameFolder(); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4Config conversion to the new config structure starts!"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------"); + File f = new File(Main.getPath() + "/OldConfig/GUIs/Version4"); + File[] fileArray = f.listFiles(); + + for (File configOld : fileArray) { + String sub = configOld.getName().substring(configOld.getName().length() - 4); + if (sub.equals(".yml")) { + YamlConfiguration yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld); + + File config = new File(Main.getPath(), "GUIs/" + configOld.getName().replace(".yml", "") + ".yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + Boolean enable = yamlConfigurationOld.getBoolean("GUI.Enable"); + Integer lines = yamlConfigurationOld.getInt("GUI.Lines"); + + String name = yamlConfigurationOld.getString("GUI.Name"); + Boolean fillItemEnable = yamlConfigurationOld.getBoolean("GUI.FillItem.Enable"); + String fillItem; + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + fillItem = yamlConfigurationOld.getString("GUI.FillItem.GlassPaneColor"); + } else fillItem = yamlConfigurationOld.getString("GUI.FillItem.Item"); + + Boolean alias = yamlConfigurationOld.getBoolean("Command.Alias"); + Boolean aliasPerm = yamlConfigurationOld.getBoolean("Command.Permission.Required"); + + setNew(enable, lines, name, fillItemEnable, fillItem, alias, aliasPerm, yamlConfiguration); + + for (String key : yamlConfigurationOld.getConfigurationSection("Slots").getKeys(false)) { + Integer slotNumber = yamlConfigurationOld.getInt("Slots." + key + ".Slot"); + Boolean slotEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Enable"); + Boolean permRequired = yamlConfigurationOld.getBoolean("Slots." + key + ".Permission.Required"); + + Boolean empty = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.Empty"); + Integer itemAmount = yamlConfigurationOld.getInt("Slots." + key + ".Item.Amount"); + Boolean playerHeadEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.PlayerHead.Enable"); + Boolean base64Enable = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.PlayerHead.Base64.Enable"); + String base64Value = yamlConfigurationOld.getString("Slots." + key + ".Item.PlayerHead.Base64.Base64Value"); + Boolean playerWhoHasOpenedTheGUI = yamlConfigurationOld.getBoolean("Slots." + key + ".Item.PlayerHead.PlayerWhoHasOpenedTheGUI"); + String playerName = yamlConfigurationOld.getString("Slots." + key + ".Item.PlayerHead.PlayerName"); + String itemMaterial = yamlConfigurationOld.getString("Slots." + key + ".Item.Material"); + String itemName = yamlConfigurationOld.getString("Slots." + key + ".Item.Name"); + List lore = yamlConfigurationOld.getStringList("Slots." + key + ".Item.Lore"); + Boolean customSoundEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".CustomSound.Enable"); + Boolean customSoundNoSound = yamlConfigurationOld.getBoolean("Slots." + key + ".CustomSound.NoSound"); + String customSoundSound = yamlConfigurationOld.getString("Slots." + key + ".CustomSound.Sound"); + Boolean costEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Cost.Enable"); + Double price = yamlConfigurationOld.getDouble("Slots." + key + ".Cost.Price"); + Boolean commandEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Command.Enable"); + Boolean commandBungeeCommand = yamlConfigurationOld.getBoolean("Slots." + key + ".Command.BungeeCommand"); + Boolean commandAsConsole = yamlConfigurationOld.getBoolean("Slots." + key + ".Command.CommandAsConsole"); + List command = yamlConfigurationOld.getStringList("Slots." + key + ".Command.Command"); + Boolean serverChange = yamlConfigurationOld.getBoolean("Slots." + key + ".ServerChange.Enable"); + String serverChangeServer = yamlConfigurationOld.getString("Slots." + key + ".ServerChange.Server"); + Boolean openGUIEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".OpenGUI.Enable"); + String openGUI = yamlConfigurationOld.getString("Slots." + key + ".OpenGUI.GUI"); + Boolean togglePermission = yamlConfigurationOld.getBoolean("Slots." + key + ".Toggle.Permission.Enable"); + String togglePermissionPerm = yamlConfigurationOld.getString("Slots." + key + ".Toggle.Permission.Permission"); + Boolean toggleUseItem = yamlConfigurationOld.getBoolean("Slots." + key + ".Toggle.UseItem.Enable"); + Boolean messageEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".Message.Enable"); + List message = yamlConfigurationOld.getStringList("Slots." + key + ".Message.Message"); + Boolean setConfigEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.Enable"); + String configFilePath = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.File.Path"); + String configOptionPath = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Option.Path"); + String configOptionPremat = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Option.Premat"); + // Boolean ConfigChatInput = ; + + String configStringValueLeft = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Value.LeftClick.String"); + Boolean configBooleanValueLeft = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.Value.LeftClick.Boolean"); + Integer configIntegerValueLeft = yamlConfigurationOld.getInt("Slots." + key + ".SetConfig.Value.LeftClick.Integer"); + Double configDoubleValueLeft = yamlConfigurationOld.getDouble("Slots." + key + ".SetConfig.Value.LeftClick.Double"); + List configListValueLeft = yamlConfigurationOld.getStringList("Slots." + key + ".SetConfig.Value.LeftClick.List"); + + String configStringValueRight = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.Value.RightClick.String"); + Boolean configBooleanValueRight = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.Value.RightClick.Boolean"); + Integer configIntegerValueRight = yamlConfigurationOld.getInt("Slots." + key + ".SetConfig.Value.RightClick.Integer"); + Double configDoubleValueRight = yamlConfigurationOld.getDouble("Slots." + key + ".SetConfig.Value.RightClick.Double"); + List configListValueRight = yamlConfigurationOld.getStringList("Slots." + key + ".SetConfig.RightClick.Value.List"); + + Boolean pluginReloadEnable = yamlConfigurationOld.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable"); + String pluginReloadCommand = yamlConfigurationOld.getString("Slots." + key + ".SetConfig.PluginReload.Command"); + + setNew(key, slotNumber, slotEnable, key, permRequired, yamlConfiguration); + CreateFunctions.createFunction(key, empty, itemAmount, playerHeadEnable, base64Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, itemMaterial, itemName, lore, + customSoundEnable, customSoundNoSound, customSoundSound, costEnable, price, commandEnable, commandBungeeCommand, commandAsConsole, command, serverChange, + serverChangeServer, openGUIEnable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, messageEnable, message, setConfigEnable, configFilePath, + configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft, configDoubleValueLeft, configListValueLeft, + configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, configListValueRight, pluginReloadEnable, pluginReloadCommand); + } + + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4The conversion to the new config structure is completed!"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]"); + send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------"); + } + + private static void renameFolder() { + File dir = new File(Main.getPath() + "/GUIs"); + File newDir = new File(Main.getPath() + "/OldConfig/GUIs/Version4"); + + try { + FileUtils.moveDirectory(dir, newDir); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void setNew(Boolean enable, Integer lines, String name, Boolean fillItemEnable, String fillItem, Boolean alias, Boolean aliasPerm, YamlConfiguration yamlConfiguration) { + set("GUI.Enable", enable, yamlConfiguration); + set("GUI.Lines", lines, yamlConfiguration); + set("GUI.Name", name, yamlConfiguration); + set("GUI.FillItem.Enable", fillItemEnable, yamlConfiguration); + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + set("GUI.FillItem.GlassPaneColor", fillItem, yamlConfiguration); + } else set("GUI.FillItem.Item", fillItem, yamlConfiguration); + + set("Command.Alias", alias, yamlConfiguration); + set("Command.Permission.Required", aliasPerm, yamlConfiguration); + } + + private static void setNew(String key, Integer slotNumber, Boolean slotEnable, String function, Boolean permRequired, YamlConfiguration yamlConfiguration) { + set("Slots." + key + ".Slot", slotNumber, yamlConfiguration); + set("Slots." + key + ".Enable", slotEnable, yamlConfiguration); + set("Slots." + key + ".Function", function, yamlConfiguration); + set("Slots." + key + ".Permission.Required", permRequired, yamlConfiguration); + set("Slots." + key + ".Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration); + set("Slots." + key + ".Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration); + } + + private static void set(String path, String value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Integer value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Boolean value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } +} diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/functions/CreateFunctions.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/functions/CreateFunctions.java new file mode 100644 index 0000000..536d230 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/functions/CreateFunctions.java @@ -0,0 +1,146 @@ +package de.jatitv.commandguiv2.Spigot.config.functions; + +import de.jatitv.commandguiv2.Spigot.Main; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public class CreateFunctions { + public static void create() { + createFunction("UseItem", false, 1, false, false, "", false, "", "", + "&6Toggle UseItem", Arrays.asList("&bYou currently have the UseItem set to: %commandgui_useitem%"), false, false, + "", false, 0.0, false, false, false, Arrays.asList(), false, + "", false, "", false, "", true, true, + Arrays.asList("&bYour UseItem was set to: %commandgui_useitem%&b."), false, "", "", "String", + "", false, 0, 0.0, Arrays.asList(), "", false, + 0, 0.0, Arrays.asList(), false, ""); + + createFunction("SupportDiscord", false, 1, true, true, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19", + false, "", (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) ? "TNT" : "", + "&3Support Discord", Arrays.asList("&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: §7http://dc.t2code.net"), + false, false, "", false, 0.0, false, false, + false, Arrays.asList(), false, "", false, "", false, "", + false, true, Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"), false, "", + "", "String", "", false, 0, 0.0, Arrays.asList(), + "", false, 0, 0.0, Arrays.asList(), false, ""); + + + } + + public static void createFunction(String fileName, Boolean empty, Integer itemAmount, Boolean playerHeadEnable, Boolean base64Enable, String base64Value, Boolean playerWhoHasOpenedTheGUI, + String playerName, String itemMaterial, String name, List lore, Boolean customSoundEnable, Boolean customSoundNoSound, String customSoundSound, + Boolean costEnable, Double price, Boolean commandEnable, Boolean commandBungeeCommand, Boolean commandAsConsole, List command, + Boolean serverChange, String serverChangeServer, Boolean openGUIEnable, String openGUI, Boolean togglePermission, String togglePermissionPerm, + Boolean toggleUseItem, Boolean messageEnable, List message, Boolean setConfigEnable, String configFilePath, String configOptionPath, + String configOptionPremat, String configStringValueLeft, Boolean configBooleanValueLeft, Integer configIntegerValueLeft, Double configDoubleValueLeft, + List configListValueLeft, String configStringValueRight, Boolean configBooleanValueRight, Integer configIntegerValueRight, Double configDoubleValueRight, + List configListValueRight, Boolean pluginReloadEnable, String pluginReloadCommand) { + long long_ = System.currentTimeMillis(); + + File config = new File(Main.getPath(), "Functions/" + fileName + ".yml"); + int i = 1; + while (config.exists()) { + config = new File(Main.getPath(), "Functions/" + fileName + "-" + i + ".yml"); + i++; + } + + send.console(Main.prefix + " §4Function GUI file (Functions/" + config.getName() + ") is loaded..."); + + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + set("Slots.Function.Item.Empty", empty, yamlConfiguration); + set("Slots.Function.Item.Amount", itemAmount, yamlConfiguration); + // if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { + set("Slots.Function.Item.PlayerHead.Enable", playerHeadEnable, yamlConfiguration); + set("Slots.Function.Item.PlayerHead.Base64.Enable", base64Enable, yamlConfiguration); + set("Slots.Function.Item.PlayerHead.Base64.Base64Value", base64Value, yamlConfiguration); + set("Slots.Function.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", playerWhoHasOpenedTheGUI, yamlConfiguration); + set("Slots.Function.Item.PlayerHead.PlayerName", playerName, yamlConfiguration); + // } + set("Slots.Function.Item.Material", itemMaterial == null ? "" : itemMaterial, yamlConfiguration); + set("Slots.Function.Item.Name", name == null ? "" : name, yamlConfiguration); + set("Slots.Function.Item.Lore", lore, yamlConfiguration); + set("Slots.Function.CustomSound.Enable", customSoundEnable, yamlConfiguration); + set("Slots.Function.CustomSound.NoSound", customSoundNoSound, yamlConfiguration); + set("Slots.Function.CustomSound.Sound", customSoundSound == null ? "" : customSoundSound, yamlConfiguration); + set("Slots.Function.Cost.Enable", costEnable, yamlConfiguration); + set("Slots.Function.Cost.Price", price, yamlConfiguration); + set("Slots.Function.Command.Enable", commandEnable, yamlConfiguration); + set("Slots.Function.Command.BungeeCommand", commandBungeeCommand, yamlConfiguration); + set("Slots.Function.Command.CommandAsConsole", commandAsConsole, yamlConfiguration); + set("Slots.Function.Command.Command", command, yamlConfiguration); + set("Slots.Function.ServerChange.Enable", serverChange, yamlConfiguration); + set("Slots.Function.ServerChange.Server", serverChangeServer == null ? "" : serverChangeServer, yamlConfiguration); + set("Slots.Function.OpenGUI.Enable", openGUIEnable, yamlConfiguration); + set("Slots.Function.OpenGUI.GUI", openGUI == null ? "" : openGUI, yamlConfiguration); + + set("Slots.Function.Toggle.Permission.Enable", togglePermission, yamlConfiguration); + set("Slots.Function.Toggle.Permission.Permission", togglePermissionPerm == null ? "" : togglePermissionPerm, yamlConfiguration); + set("Slots.Function.Toggle.UseItem.Enable", toggleUseItem, yamlConfiguration); + + set("Slots.Function.Message.Enable", messageEnable, yamlConfiguration); + set("Slots.Function.Message.Message", message, yamlConfiguration); + + set("Slots.Function.SetConfig.Enable", setConfigEnable, yamlConfiguration); + set("Slots.Function.SetConfig.File.Path", configFilePath == null ? "" : configFilePath, yamlConfiguration); + set("Slots.Function.SetConfig.Option.Path", configOptionPath == null ? "" : configOptionPath, yamlConfiguration); + set("Slots.Function.SetConfig.Option.Premat", configOptionPremat == null ? "" : configOptionPremat, yamlConfiguration); + set("Slots.Function.SetConfig.Value.LeftClick.String", configStringValueLeft == null ? "" : configStringValueLeft, yamlConfiguration); + set("Slots.Function.SetConfig.Value.LeftClick.Boolean", configBooleanValueLeft, yamlConfiguration); + set("Slots.Function.SetConfig.Value.LeftClick.Integer", configIntegerValueLeft, yamlConfiguration); + set("Slots.Function.SetConfig.Value.LeftClick.Double", configDoubleValueLeft, yamlConfiguration); + set("Slots.Function.SetConfig.Value.LeftClick.List", configListValueLeft, yamlConfiguration); + set("Slots.Function.SetConfig.Value.RightClick.String", configStringValueRight == null ? "" : configStringValueRight, yamlConfiguration); + set("Slots.Function.SetConfig.Value.RightClick.Boolean", configBooleanValueRight, yamlConfiguration); + set("Slots.Function.SetConfig.Value.RightClick.Integer", configIntegerValueRight, yamlConfiguration); + set("Slots.Function.SetConfig.Value.RightClick.Double", configDoubleValueRight, yamlConfiguration); + set("Slots.Function.SetConfig.Value.RightClick.List", configListValueRight, yamlConfiguration); + set("Slots.Function.SetConfig.PluginReload.Enable", pluginReloadEnable, yamlConfiguration); + set("Slots.Function.SetConfig.PluginReload.Command", pluginReloadCommand == null ? "" : pluginReloadCommand, yamlConfiguration); + + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + send.console(Main.prefix + " §2Function file (Functions/" + config.getName() + ") was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + + } + + + private static void set(String path, String value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Integer value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Boolean value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, List value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Double value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } +} diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java new file mode 100644 index 0000000..4832a79 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java @@ -0,0 +1,72 @@ +package de.jatitv.commandguiv2.Spigot.config.gui; + +import de.jatitv.commandguiv2.Spigot.Main; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + + +public class CreateGUI { + public static void configCreate() { + long long_ = System.currentTimeMillis(); + send.console(Main.prefix + " §4Default GUI file (GUIs/default.yml) is loaded..."); + File config = new File(Main.getPath(), "GUIs/default.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + set("GUI.Enable", true, yamlConfiguration); + set("GUI.Lines", 1, yamlConfiguration); + set("GUI.Name", "&5default &9GUI", yamlConfiguration); + set("GUI.FillItem.Enable", true, yamlConfiguration); + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + set("GUI.FillItem.GlassPaneColor", 15, yamlConfiguration); + } else set("GUI.FillItem.Item", "BLACK_STAINED_GLASS_PANE", yamlConfiguration); + + set("Command.Alias", true, yamlConfiguration); + set("Command.Permission.Required", true, yamlConfiguration); + + set("Slots.SupportDiscord.Slot", 4, yamlConfiguration); + set("Slots.SupportDiscord.Enable", true, yamlConfiguration); + set("Slots.SupportDiscord.Function", "SupportDiscord", yamlConfiguration); + set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration); + set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration); + set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration); + + set("Slots.UseItem.Slot", 6, yamlConfiguration); + set("Slots.UseItem.Enable", true, yamlConfiguration); + set("Slots.UseItem.Function", "UseItem", yamlConfiguration); + set("Slots.UseItem.Permission.Required", false, yamlConfiguration); + set("Slots.UseItem.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration); + set("Slots.UseItem.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration); + + + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + send.console(Main.prefix + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + } + + private static void set(String path, String value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Integer value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } + + private static void set(String path, Boolean value, YamlConfiguration config) { + if (!config.contains(path)) { + config.set(path, value); + } + } +} diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java index dca1cc2..4886a33 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java @@ -3,12 +3,11 @@ package de.jatitv.commandguiv2.Spigot.gui; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.Objekte.Object; -import de.jatitv.commandguiv2.Spigot.Objekte.Slot; +import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; +import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; -import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import net.t2code.lib.Spigot.Lib.replace.Replace; import org.bukkit.Material; @@ -25,34 +24,34 @@ public class GuiBuilder { private static String prefix = Util.getPrefix(); - protected static void item(Slot slot, Player player, Inventory inventory) { - ItemStack item = new ItemStack(Material.valueOf(slot.item.toUpperCase().replace(".", "_"))); + protected static void item(Function function, Integer slot, Player player, Inventory inventory) { + ItemStack item = new ItemStack(Material.valueOf(function.item.toUpperCase().replace(".", "_"))); ItemMeta itemMeta = item.getItemMeta(); - setDisplayNameAndLore(itemMeta, player, slot); + setDisplayNameAndLore(itemMeta, player, function); item.setItemMeta(itemMeta); Integer am; - if (slot.itemAmount == 0) { + if (function.itemAmount == 0) { am = 1; - } else am = slot.itemAmount; + } else am = function.itemAmount; item.setAmount(am); - inventory.setItem(slot.slot, item); + inventory.setItem(slot, item); } - protected static void item(String material, Slot slot, Player player, Inventory inventory) { + protected static void item(String material, Function function,Integer slot, Player player, Inventory inventory) { ItemStack item = new ItemStack(Material.valueOf(material)); ItemMeta itemMeta = item.getItemMeta(); - setDisplayNameAndLore(itemMeta, player, slot); + setDisplayNameAndLore(itemMeta, player, function); item.setItemMeta(itemMeta); Integer am; - if (slot.itemAmount == 0) { + if (function.itemAmount == 0) { am = 1; - } else am = slot.itemAmount; + } else am = function.itemAmount; item.setAmount(am); - inventory.setItem(slot.slot, item); + inventory.setItem(slot, item); } - private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Slot slot) { + private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Function slot) { if (Main.PaPi) { itemMeta.setDisplayName(Replace.replace(prefix, player, slot.name.replace("[player]", player.getName()))); itemMeta.setLore(Replace.replacePrice(prefix, player, slot.lore, slot.price + " " + SelectConfig.Currency)); @@ -62,18 +61,18 @@ public class GuiBuilder { } } - protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) { + protected static void base64(String base64Value, Function function, Integer slot, Player player, Inventory inventory) { ItemStack item = ItemVersion.getHeadIS(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); setBase64(itemMeta, base64Value); - setDisplayNameAndLore(itemMeta, player, slot); + setDisplayNameAndLore(itemMeta, player, function); item.setItemMeta(itemMeta); Integer am; - if (slot.itemAmount == 0) { + if (function.itemAmount == 0) { am = 1; - } else am = slot.itemAmount; + } else am = function.itemAmount; item.setAmount(am); - inventory.setItem(slot.slot, item); + inventory.setItem(slot, item); } private static void setBase64(ItemMeta itemMeta, String base64Value) { @@ -89,25 +88,25 @@ public class GuiBuilder { } } - protected static void base64(Slot slot, Player player, Inventory inventory) { - base64(slot.base64Value, slot, player, inventory); + protected static void base64(Function function,Integer slot, Player player, Inventory inventory) { + base64(function.base64Value, function,slot, player, inventory); } - protected static void playerHead(Slot slot, Player player, Inventory inventory, String skullName) { + protected static void playerHead(Function function, Integer slot,Player player, Inventory inventory, String skullName) { ItemStack item = ItemVersion.getHeadIS(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); - setDisplayNameAndLore(itemMeta, player, slot); + setDisplayNameAndLore(itemMeta, player, function); itemMeta.setOwner(skullName); item.setItemMeta(itemMeta); Integer am; - if (slot.itemAmount == 0) { + if (function.itemAmount == 0) { am = 1; - } else am = slot.itemAmount; + } else am = function.itemAmount; item.setAmount(am); - inventory.setItem(slot.slot, item); + inventory.setItem(slot, item); } - public static void fillItem(Inventory inventory, Object gui) { + public static void fillItem(Inventory inventory, Gui gui) { ItemStack glass; if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item)); 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 017082f..d3679d5 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 @@ -3,10 +3,11 @@ package de.jatitv.commandguiv2.Spigot.gui; import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.Objekte.Slot; +import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; -import de.jatitv.commandguiv2.Spigot.Objekte.Object; +import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import de.jatitv.commandguiv2.Util; import io.github.solyze.plugmangui.inventories.PluginListGUI; import net.t2code.lib.Spigot.Lib.messages.send; @@ -19,7 +20,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; public class OpenGUI { @@ -27,7 +27,7 @@ public class OpenGUI { private static String prefix = Util.getPrefix(); public static void openGUI(Player player, String guiString) { - Object gui = Main.guiHashMap.get(guiString); + Gui gui = Main.guiHashMap.get(guiString); Long long_ = Long.valueOf(System.currentTimeMillis()); switch (guiString) { //case "plugin.PlotSquaredGUI": @@ -68,57 +68,57 @@ public class OpenGUI { if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { Inventory inventory; if (Main.PaPi) { - inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name))); + inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name))); } else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name))); if (gui.GUI_FillItem_Enable) { GuiBuilder.fillItem(inventory, gui); } - for (Slot slot : gui.GUI_Slots) { - if (!slot.perm - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1)) - || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.slot + 1) + ".see") - || player.hasPermission("commandgui.admin")) { - if (slot.enable) { - if (slot.empty) { - ItemStack air = new ItemStack(Material.AIR); - inventory.setItem(slot.slot, air); - } else { - if (slot.togglePermission) { - if (player.hasPermission(slot.togglePermissionPerm)) { - toggleOn(slot, player, inventory); - } else { - toggleOff(slot, player, inventory); - } - } else if (slot.toggleUseItem) { - if (Events.useItemHashMap.get(player)) { - toggleOn(slot, player, inventory); - } else { - toggleOff(slot, player, inventory); - } + for (Slot slot : gui.slots) { + Function function = Main.functionHashMap.get(slot.function); + if (slot.permission || !player.hasPermission(slot.permissionToSee)) continue; + if (slot.enable) { + if (function.empty) { + ItemStack air = new ItemStack(Material.AIR); + inventory.setItem(slot.slot, air); + } else { + if (function.togglePermission) { + if (player.hasPermission(function.togglePermissionPerm)) { + toggleOn(function, slot.slot, player, inventory); } else { - if (slot.playerHead_Enable) { - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, slot.name)); - send.error(plugin, "Playerheads are only available from version 1.13!"); - send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, slot.name)); + toggleOff(function, slot.slot, player, inventory); + } + } else if (function.toggleUseItem) { + if (Events.useItemHashMap.get(player)) { + toggleOn(function, slot.slot, player, inventory); + } else { + toggleOff(function, slot.slot, player, inventory); + } + } else { + if (function.playerHead_Enable) { + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name)); + send.error(plugin, "Playerheads are only available from version 1.13!"); + send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name)); + } else { + if (function.base64_Enable) { + GuiBuilder.base64(function, slot.slot, player, inventory); } else { - if (slot.base64_Enable) { - GuiBuilder.base64(slot, player, inventory); + if (function.playerWhoHasOpenedTheGUI) { + GuiBuilder.playerHead(function, slot.slot, player, inventory, player.getName()); } else { - if (slot.playerWhoHasOpenedTheGUI) { - GuiBuilder.playerHead(slot, player, inventory, player.getName()); - } else { - GuiBuilder.playerHead(slot, player, inventory,slot.playerName); - } + GuiBuilder.playerHead(function, slot.slot, player, inventory, function.playerName); } } - } else { - GuiBuilder.item(slot, player, inventory); } + } else { + GuiBuilder.item(function, slot.slot, player, inventory); } } } + } } player.openInventory(inventory); @@ -126,15 +126,15 @@ public class OpenGUI { } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name))); } - private static void toggleOn(Slot slot, Player player, Inventory inventory) { + private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) { if (SelectConfig.toggleItemOnOrYesBase64) { - GuiBuilder.base64(SelectConfig.toggleItemOnOrYesBase64Value, slot, player, inventory); - } else GuiBuilder.item(SelectConfig.toggleItemOnOrYesMaterial, slot, player, inventory); + GuiBuilder.base64(SelectConfig.toggleItemOnOrYesBase64Value, function, slot, player, inventory); + } else GuiBuilder.item(SelectConfig.toggleItemOnOrYesMaterial, function, slot, player, inventory); } - private static void toggleOff(Slot slot, Player player, Inventory inventory) { + private static void toggleOff(Function function, Integer slot, Player player, Inventory inventory) { if (SelectConfig.toggleItemOffOrNoBase64) { - GuiBuilder.base64(SelectConfig.toggleItemOffOrNoBase64Value, slot, player, inventory); - } else GuiBuilder.item(SelectConfig.toggleItemOffOrNoMaterial, slot, player, inventory); + GuiBuilder.base64(SelectConfig.toggleItemOffOrNoBase64Value, function, slot, player, inventory); + } else GuiBuilder.item(SelectConfig.toggleItemOffOrNoMaterial, function, slot, player, inventory); } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java new file mode 100644 index 0000000..8cddb0d --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java @@ -0,0 +1,162 @@ +package de.jatitv.commandguiv2.Spigot.objects; + +import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; +import de.jatitv.commandguiv2.Spigot.objects.functions.Function; +import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; +import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; +import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class Obj_Select { + public static void onSelect() { + onSelectGui(); + onSelectFunction(); + } + + public static void onSelectGui() { + Main.guiHashMap.clear(); + Main.allAliases.clear(); + File f = new File(Main.getPath() + "/GUIs/"); + File[] fileArray = f.listFiles(); + + for (File config_gui : fileArray) { + String sub = config_gui.getName().substring(config_gui.getName().length() - 4); + if (sub.equals(".yml")) { + Main.allAliases.add(config_gui.getName().replace(".yml", "")); + YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui); + String guiFileName = config_gui.getName().replace(".yml", ""); + + Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable"); + Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines"); + if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) { + yamlConfiguration_gui.set("GUI.Lines", 6); + } + if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) { + yamlConfiguration_gui.set("GUI.Lines", 1); + } + + String guiName = yamlConfiguration_gui.getString("GUI.Name"); + Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable"); + String guiFillItemItem; + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { + guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor"); + } else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item"); + + Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias"); + Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required"); + + ArrayList slots = new ArrayList<>(); + for (String key : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) { + Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + key + ".Slot") - 1; + Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + key + ".Enable"); + String function = yamlConfiguration_gui.getString("Slots." + key + ".Function"); + Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required"); + String permSee = yamlConfiguration_gui.getString("Slots." + key + ".Permission.See"); + String permUse = yamlConfiguration_gui.getString("Slots." + key + ".Permission.Use"); + + Slot slot = new Slot(slotNumber, enable, function, permRequired, + Objects.requireNonNull(permSee).replace("[guiname]", guiFileName).replace("[slot]", String.valueOf(slotNumber)) + .replace("[slotname]", key), permUse); + slots.add(slot); + } + Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, + config_gui.getName().replace(".yml", ""), commandAliasEnable, commandPermission, slots); + + Main.guiHashMap.put(guiFileName, gui); + CmdExecuter_GUITab.arg1.put(config_gui.getName() + .replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", "")); + + try { + yamlConfiguration_gui.save(config_gui); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public static void onSelectFunction() { + Main.functionHashMap.clear(); + File f = new File(Main.getPath() + "/Functions/"); + File[] fileArray = f.listFiles(); + + for (File config : fileArray) { + String sub = config.getName().substring(config.getName().length() - 4); + if (sub.equals(".yml")) { + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + Boolean empty = yamlConfiguration.getBoolean("Slots.Function.Item.Empty"); + Integer itemAmount = yamlConfiguration.getInt("Slots.Function.Item.Amount"); + Boolean playerHead_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Enable"); + Boolean base64_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Base64.Enable"); + String base64Value = yamlConfiguration.getString("Slots.Function.Item.PlayerHead.Base64.Base64Value"); + Boolean playerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.PlayerWhoHasOpenedTheGUI"); + String playerName = yamlConfiguration.getString("Slots.Function.Item.PlayerHead.PlayerName"); + String item = yamlConfiguration.getString("Slots.Function.Item.Material"); + String name = yamlConfiguration.getString("Slots.Function.Item.Name"); + List lore = yamlConfiguration.getStringList("Slots.Function.Item.Lore"); + Boolean customSound_Enable = yamlConfiguration.getBoolean("Slots.Function.CustomSound.Enable"); + Boolean customSound_NoSound = yamlConfiguration.getBoolean("Slots.Function.CustomSound.NoSound"); + String customSound_Sound = yamlConfiguration.getString("Slots.Function.CustomSound.Sound"); + Boolean cost_Enable = yamlConfiguration.getBoolean("Slots.Function.Cost.Enable"); + Double price = yamlConfiguration.getDouble("Slots.Function.Cost.Price"); + Boolean command_Enable = yamlConfiguration.getBoolean("Slots.Function.Command.Enable"); + Boolean command_BungeeCommand = yamlConfiguration.getBoolean("Slots.Function.Command.BungeeCommand"); + Boolean commandAsConsole = yamlConfiguration.getBoolean("Slots.Function.Command.CommandAsConsole"); + List command = yamlConfiguration.getStringList("Slots.Function.Command.Command"); + Boolean serverChange = yamlConfiguration.getBoolean("Slots.Function.ServerChange.Enable"); + String serverChangeServer = yamlConfiguration.getString("Slots.Function.ServerChange.Server"); + Boolean openGUI_Enable = yamlConfiguration.getBoolean("Slots.Function.OpenGUI.Enable"); + String openGUI = yamlConfiguration.getString("Slots.Function.OpenGUI.GUI"); + Boolean togglePermission = yamlConfiguration.getBoolean("Slots.Function.Toggle.Permission.Enable"); + String togglePermissionPerm = yamlConfiguration.getString("Slots.Function.Toggle.Permission.Permission"); + Boolean toggleUseItem = yamlConfiguration.getBoolean("Slots.Function.Toggle.UseItem.Enable"); + Boolean message_Enable = yamlConfiguration.getBoolean("Slots.Function.Message.Enable"); + List message = yamlConfiguration.getStringList("Slots.Function.Message.Message"); + Boolean setConfigEnable = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Enable"); + String configFilePath = yamlConfiguration.getString("Slots.Function.SetConfig.File.Path"); + String configOptionPath = yamlConfiguration.getString("Slots.Function.SetConfig.Option.Path"); + String configOptionPremat = yamlConfiguration.getString("Slots.Function.SetConfig.Option.Premat"); + // Boolean ConfigChatInput = ; + + String configStringValueLeft = yamlConfiguration.getString("Slots.Function.SetConfig.Value.LeftClick.String"); + Boolean configBooleanValueLeft = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Value.LeftClick.Boolean"); + Integer configIntegerValueLeft = yamlConfiguration.getInt("Slots.Function.SetConfig.Value.LeftClick.Integer"); + Double configDoubleValueLeft = yamlConfiguration.getDouble("Slots.Function.SetConfig.Value.LeftClick.Double"); + List configListValueLeft = yamlConfiguration.getStringList("Slots.Function.SetConfig.Value.LeftClick.List"); + + String configStringValueRight = yamlConfiguration.getString("Slots.Function.SetConfig.Value.RightClick.String"); + Boolean configBooleanValueRight = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Value.RightClick.Boolean"); + Integer configIntegerValueRight = yamlConfiguration.getInt("Slots.Function.SetConfig.Value.RightClick.Integer"); + Double configDoubleValueRight = yamlConfiguration.getDouble("Slots.Function.SetConfig.Value.RightClick.Double"); + List configListValueRight = yamlConfiguration.getStringList("Slots.Function.SetConfig.RightClick.Value.List"); + + + Boolean pluginReloadEnable = yamlConfiguration.getBoolean("Slots.Function.SetConfig.PluginReload.Enable"); + String pluginReloadCommand = yamlConfiguration.getString("Slots.Function.SetConfig.PluginReload.Command"); + + + Function function = new Function(empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore, + customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, price, command_Enable, command_BungeeCommand, commandAsConsole, command, + serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, message, + setConfigEnable, configFilePath, configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft, + configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, + configListValueRight, pluginReloadEnable, pluginReloadCommand); + Main.functionHashMap.put(config.getName().replace(".yml", ""), function); + + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } +} diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java similarity index 61% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java index 5292513..5801910 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Slot.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java @@ -1,12 +1,9 @@ -package de.jatitv.commandguiv2.Spigot.Objekte; +package de.jatitv.commandguiv2.Spigot.objects.functions; import java.util.List; -public class Slot { +public class Function { - public Integer slot; - public Boolean enable; - // public Boolean ItemsRemovable; public Boolean empty; public Integer itemAmount; public Boolean playerHead_Enable; @@ -35,12 +32,11 @@ public class Slot { public Boolean toggleUseItem; public Boolean message_Enable; public List message; - public Boolean perm; public Boolean setConfigEnable; public String configFilePath; public String configOptionPath; public String configOptionPremat; - // public Boolean ConfigChatInput; + // public Boolean ConfigChatInput; public String configStringValueLeft; public Boolean configBooleanValueLeft; @@ -58,60 +54,53 @@ public class Slot { public Boolean pluginReloadEnable; public String pluginReloadCommand; - public Slot(Integer slot, - Boolean enable, - // Boolean ItemsRemovable, - Boolean empty, - Integer itemAmount, - Boolean playerHead_Enable, - Boolean base64Value_Enable, - String base64Value, - Boolean playerWhoHasOpenedTheGUI, - String playerName, - String item, - String name, - List lore, - Boolean customSound_Enable, - Boolean customSound_NoSound, - String customSound_Sound, - Boolean cost_Enable, - Double price, - Boolean command_Enable, - Boolean command_BungeeCommand, - Boolean commandAsConsole, - List command, - Boolean serverChange, - String serverChangeServer, - Boolean openGUI_Enable, - String openGUI, - Boolean togglePermission, - String togglePermissionPerm, - Boolean toggleUseItem, - Boolean message_Enable, - List message, - Boolean perm, - Boolean setConfigEnable, - String configFilePath, - String configOptionPath, - String configOptionPremat, + public Function(Boolean empty, + Integer itemAmount, + Boolean playerHead_Enable, + Boolean base64Value_Enable, + String base64Value, + Boolean playerWhoHasOpenedTheGUI, + String playerName, + String item, + String name, + List lore, + Boolean customSound_Enable, + Boolean customSound_NoSound, + String customSound_Sound, + Boolean cost_Enable, + Double price, + Boolean command_Enable, + Boolean command_BungeeCommand, + Boolean commandAsConsole, + List command, + Boolean serverChange, + String serverChangeServer, + Boolean openGUI_Enable, + String openGUI, + Boolean togglePermission, + String togglePermissionPerm, + Boolean toggleUseItem, + Boolean message_Enable, + List message, + Boolean setConfigEnable, + String configFilePath, + String configOptionPath, + String configOptionPremat, - String configStringValueLeft, - Boolean configBooleanValueLeft, - Integer configIntegerValueLeft, - Double configDoubleValueLeft, - List configListValueLeft, + String configStringValueLeft, + Boolean configBooleanValueLeft, + Integer configIntegerValueLeft, + Double configDoubleValueLeft, + List configListValueLeft, - String configStringValueRight, - Boolean configBooleanValueRight, - Integer configIntegerValueRight, - Double configDoubleValueRight, - List configListValueRight, + String configStringValueRight, + Boolean configBooleanValueRight, + Integer configIntegerValueRight, + Double configDoubleValueRight, + List configListValueRight, - Boolean pluginReloadEnable, - String pluginReloadCommand) { - this.slot = slot; - this.enable = enable; - // this.ItemsRemovable = ItemsRemovable; + Boolean pluginReloadEnable, + String pluginReloadCommand) { this.empty = empty; this.itemAmount = itemAmount; this.playerHead_Enable = playerHead_Enable; @@ -140,12 +129,11 @@ public class Slot { this.toggleUseItem = toggleUseItem; this.message_Enable = message_Enable; this.message = message; - this.perm = perm; this.setConfigEnable = setConfigEnable; this.configFilePath = configFilePath; this.configOptionPath = configOptionPath; this.configOptionPremat = configOptionPremat; - // this.ConfigChatInput = ConfigChatInput; + // this.ConfigChatInput = ConfigChatInput; this.configStringValueLeft = configStringValueLeft; this.configBooleanValueLeft = configBooleanValueLeft; @@ -162,5 +150,8 @@ public class Slot { this.pluginReloadEnable = pluginReloadEnable; this.pluginReloadCommand = pluginReloadCommand; + + + } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Object.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java similarity index 61% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Object.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java index b7d493d..b2369fc 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Object.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java @@ -1,8 +1,10 @@ -package de.jatitv.commandguiv2.Spigot.Objekte; +package de.jatitv.commandguiv2.Spigot.objects.guis; + +import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import java.util.ArrayList; -public class Object { +public class Gui { public Boolean GUI_Enable; public Integer GUI_Lines; public String GUI_Name; @@ -13,10 +15,10 @@ public class Object { public String Command_Command; public Boolean Command_Alias_Enable; public Boolean Command_Permission_Enable; - public ArrayList GUI_Slots; + public ArrayList slots; - public Object(Boolean GUI_Enable, Integer GUI_Lines, String GUI_Name, Boolean GUI_FillItem_Enable, String GUI_FillItem_Item, - String Command_Command, Boolean Command_Alias_Enable, Boolean Command_Permission_Enable, ArrayList GUI_Slots){ + public Gui(Boolean GUI_Enable, Integer GUI_Lines, String GUI_Name, Boolean GUI_FillItem_Enable, String GUI_FillItem_Item, + String Command_Command, Boolean Command_Alias_Enable, Boolean Command_Permission_Enable, ArrayList slots){ this.GUI_Enable = GUI_Enable; this.GUI_Lines = GUI_Lines; this.GUI_Name = GUI_Name; @@ -25,6 +27,6 @@ public class Object { this.Command_Command = Command_Command; this.Command_Alias_Enable = Command_Alias_Enable; this.Command_Permission_Enable = Command_Permission_Enable; - this.GUI_Slots = GUI_Slots; + this.slots = slots; } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/slots/Slot.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/slots/Slot.java new file mode 100644 index 0000000..6c4173c --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/slots/Slot.java @@ -0,0 +1,28 @@ +package de.jatitv.commandguiv2.Spigot.objects.slots; + +public class Slot { + + public Integer slot; + public Boolean enable; + public String function; + public Boolean permission; + public String permissionToSee; + public String permissionToUse; + + + public Slot(Integer slot, + Boolean enable, + String function, + Boolean permission, + String permissionToSee, + String permissionToUse + ) { + this.slot = slot; + this.enable = enable; + this.function = function; + this.permission = permission; + this.permissionToSee = permissionToSee; + this.permissionToUse = permissionToUse; + + } +} 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 db454b0..1846917 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 @@ -6,14 +6,15 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; 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.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions; +import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI; 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.objects.Obj_Select; import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; @@ -44,7 +45,12 @@ public class Load { if (!new File(Main.getPath(), "config.yml").exists()) { try { - DefaultGUICreate.configCreate(); + CreateGUI.configCreate(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + CreateFunctions.create(); } catch (Exception e) { e.printStackTrace(); } @@ -61,17 +67,17 @@ public class Load { } if (SelectConfig.Bungee) { - if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin,"cgui:bungee")){ + if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) { send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee"); - Bukkit.getMessenger().registerOutgoingPluginChannel(plugin,"cgui:bungee"); + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "cgui:bungee"); } - if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin,"cgui:onlinepl")){ + if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "cgui:onlinepl")) { send.debug(plugin, "registerIncomingPluginChannel §ecgui:onlinepl"); - Bukkit.getMessenger().registerIncomingPluginChannel(plugin,"cgui:onlinepl", new Bungee_Sender_Reciver()); + Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "cgui:onlinepl", new Bungee_Sender_Reciver()); } } - if (PluginCheck.papi()){ + if (PluginCheck.papi()) { new Placeholder().register(); } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java index e84ad77..e7bfed2 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java @@ -1,20 +1,24 @@ package de.jatitv.commandguiv2.Spigot.system; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.Objekte.Object; -import de.jatitv.commandguiv2.Spigot.Objekte.Slot; +import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; +import de.jatitv.commandguiv2.Spigot.objects.functions.Function; +import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import org.bukkit.Bukkit; import org.bukkit.permissions.Permission; public class RegisterPermissions { public static void onPermRegister() { - for (Object gui : Main.guiHashMap.values()) { + for (Gui gui : Main.guiHashMap.values()) { if (Bukkit.getPluginManager().getPermission("commandgui.command." + gui.Command_Command) == null) { Bukkit.getPluginManager().addPermission(new Permission("commandgui.command." + gui.Command_Command)); } - for (Slot slot : gui.GUI_Slots) { - if (Bukkit.getPluginManager().getPermission("commandgui." + gui.Command_Command + ".slot." + (slot.slot + 1)) == null) { - Bukkit.getPluginManager().addPermission(new Permission("commandgui." + gui.Command_Command + ".slot." + (slot.slot + 1))); + for (Slot slot : gui.slots) { + if (Bukkit.getPluginManager().getPermission(slot.permissionToUse) == null) { + Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToUse)); + } + if (Bukkit.getPluginManager().getPermission(slot.permissionToSee) == null) { + Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToSee)); } } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/YML.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/YML.java index 94a49e4..bbfe10a 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/YML.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/YML.java @@ -11,7 +11,7 @@ import java.io.IOException; public class YML { - private static Plugin plugin = Main.plugin; + private static final Plugin plugin = Main.plugin; public static File storage = new File(Main.getPath(), "Storage/gui-item.yml"); public static YamlConfiguration yamlConfigurationStorage = YamlConfiguration.loadConfiguration(storage); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Util.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Util.java index a6f2674..787f243 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Util.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Util.java @@ -1,6 +1,7 @@ package de.jatitv.commandguiv2; public class Util { + private static Integer configVersion = 5; private static double requiredT2CodeLibVersion = 10.3; private static String Prefix = "§8[§4C§9GUI§8]"; private static Integer SpigotID = 90671; @@ -31,4 +32,8 @@ public class Util { public static String getDiscord() { return Discord; } + + public static Integer getConfigVersion() { + return configVersion; + } } 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 a79aebf..12e4e5f 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 @@ -5,7 +5,7 @@ import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; 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.config.DefaultGUICreate; +import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; @@ -81,7 +81,7 @@ public class CGuiAPI { public static void createDefaultGUI(CommandSender sender) { if (sender.hasPermission("commandgui.admin")) { - DefaultGUICreate.configCreate(); + CreateGUI.configCreate(); sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml")); } else sender.sendMessage(SelectMessages.NoPermissionForCommand .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); -- 2.34.1 From b0ff52084787a5dc7cc42718c8a3cb8dd72b4653 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 07:11:30 +0200 Subject: [PATCH 06/16] new Config --- .../new/Functions/SupportDiscord.yml | 74 ++++++++ Config Update V5/new/Functions/UseItem.yml | 69 ++++++++ Config Update V5/new/GUIs/default.yml | 28 +++ Config Update V5/new/config.yml | 121 +++++++++++++ .../new/languages/english_messages.yml | 55 ++++++ .../new/languages/german_messages.yml | 58 +++++++ .../new/languages/norwegian_messages.yml | 54 ++++++ Config Update V5/old/GUIs/default.yml | 159 ++++++++++++++++++ Config Update V5/old/config.yml | 121 +++++++++++++ .../old/languages/english_messages.yml | 55 ++++++ .../old/languages/german_messages.yml | 58 +++++++ .../old/languages/norwegian_messages.yml | 54 ++++++ 12 files changed, 906 insertions(+) create mode 100644 Config Update V5/new/Functions/SupportDiscord.yml create mode 100644 Config Update V5/new/Functions/UseItem.yml create mode 100644 Config Update V5/new/GUIs/default.yml create mode 100644 Config Update V5/new/config.yml create mode 100644 Config Update V5/new/languages/english_messages.yml create mode 100644 Config Update V5/new/languages/german_messages.yml create mode 100644 Config Update V5/new/languages/norwegian_messages.yml create mode 100644 Config Update V5/old/GUIs/default.yml create mode 100644 Config Update V5/old/config.yml create mode 100644 Config Update V5/old/languages/english_messages.yml create mode 100644 Config Update V5/old/languages/german_messages.yml create mode 100644 Config Update V5/old/languages/norwegian_messages.yml diff --git a/Config Update V5/new/Functions/SupportDiscord.yml b/Config Update V5/new/Functions/SupportDiscord.yml new file mode 100644 index 0000000..5b81465 --- /dev/null +++ b/Config Update V5/new/Functions/SupportDiscord.yml @@ -0,0 +1,74 @@ +Slot: + Function: + 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: §7http://dc.t2code.net' + CustomSound: + Enable: false + NoSound: false + Sound: '' + Cost: + Enable: false + Price: 0.0 + Command: + Enable: false + BungeeCommand: false + CommandAsConsole: false + Command: [] + ServerChange: + Enable: false + Server: '' + OpenGUI: + Enable: false + GUI: '' + Toggle: + Permission: + Enable: false + Permission: '' + UseItem: + Enable: false + Message: + Enable: true + Message: + - '&6You can find more information on Discord: &ehttp://dc.t2code.net' + SetConfig: + Enable: false + File: + Path: '' + Option: + Path: '' + Premat: String + Value: + LeftClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + RightClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + PluginReload: + Enable: false + Command: '' \ No newline at end of file diff --git a/Config Update V5/new/Functions/UseItem.yml b/Config Update V5/new/Functions/UseItem.yml new file mode 100644 index 0000000..40521f1 --- /dev/null +++ b/Config Update V5/new/Functions/UseItem.yml @@ -0,0 +1,69 @@ +Slot: + Functions: + Item: + Empty: false + Amount: 1 + PlayerHead: + Enable: false + Base64: + Enable: false + Base64Value: '' + PlayerWhoHasOpenedTheGUI: false + PlayerName: '' + Material: '' + Name: '&6Toggle UseItem' + Lore: + - '&bYou currently have the UseItem set to: %commandgui_useitem%' + CustomSound: + Enable: false + NoSound: false + Sound: '' + Cost: + Enable: false + Price: 0.0 + Command: + Enable: false + BungeeCommand: false + CommandAsConsole: false + Command: [] + ServerChange: + Enable: false + Server: '' + OpenGUI: + Enable: false + GUI: '' + Toggle: + Permission: + Enable: false + Permission: '' + UseItem: + Enable: true + Message: + Enable: true + Message: + - '&bYour UseItem was set to: %commandgui_useitem%&b.' + Permission: + Required: false + SetConfig: + Enable: false + File: + Path: '' + Option: + Path: '' + Premat: String + Value: + LeftClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + RightClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + PluginReload: + Enable: false + Command: '' diff --git a/Config Update V5/new/GUIs/default.yml b/Config Update V5/new/GUIs/default.yml new file mode 100644 index 0000000..9e4a6e7 --- /dev/null +++ b/Config Update V5/new/GUIs/default.yml @@ -0,0 +1,28 @@ +GUI: + Enable: true + Lines: 1 + Name: '&5default &9GUI' + FillItem: + Enable: true + Item: BLACK_STAINED_GLASS_PANE +Command: + Alias: true + Permission: + Required: true +Slots: + SupportDiscord: + Slot: 4 + Enable: true + Function: SupportDiscord + Permission: + Required: false + See: '' + Use: '' + UseItem: + Slot: 6 + Enable: true + Function: UseItem + Permission: + Required: false + See: '' + Use: '' diff --git a/Config Update V5/new/config.yml b/Config Update V5/new/config.yml new file mode 100644 index 0000000..5ef9e45 --- /dev/null +++ b/Config Update V5/new/config.yml @@ -0,0 +1,121 @@ +ConfigVersion: 4 +Plugin: + UpdateCheckOnJoin: true + Debug: false + HelpAlias: true + language: english + Currency: $ + DefaultGUI: default +Storage: + Type: YML + MySQL: + IP: localhost + Port: 3306 + Database: database + User: root + Password: password + SSL: false +BungeeCord: + Enable: false + ThisServer: server +UseItem: + Enable: true + AllowToggle: true + AllowSetSlot: true + BlockMoveAndDrop: true + OpenGUI: default + Permission: + NeededToUse: true + KeepAtCommandClear: true + InventorySlot: + Slot: 1 + SlotEnforce: false + FreeSlot: false + Item: + Material: paper + PlayerHead: + Enable: false + Base64: + Enable: false + Base64Value: '' + PlayerWhoHasOpenedTheGUI: false + Playername: '' + Name: '&bDefault &6GUI' + Lore: + - '&eThis is an example GUI' + Join: + GiveOnEveryJoin: true + GiveOnlyOnFirstJoin: false + Cursor: + ToGUIItem: + OnLogin: + Enable: true + Spigot: + OnOnlyFirstLogin: true + Bungee: + OnServerChange: false +Advanced: + UseItem: + GameMode: + Change: + Enable: true + DelayInTicks: 1 + Protection: + Enable: false + RemoveItemWhenItIsDisabled: false + Mode: blacklist + List: + - CREATIVE + - Spectator + World: + Change: + Enable: true + DelayInTicks: 1 + Protection: + Enable: false + RemoveItemWhenItIsDisabled: false + Mode: blacklist + List: + - World1 + - World2 +Toggle: + Items: + OnOrYes: + Item: + Base64: + Enable: false + Base64Value: '' + Material: GREEN_WOOL + OffOrNo: + Item: + Base64: + Enable: false + Base64Value: '' + Material: RED_WOOL + Permission: + Commands: + 'True': luckperms user [player] permission set [perm] true + 'False': luckperms user [player] permission set [perm] false +Placeholder: + 'True': '&2true' + 'False': '&4false' +Sound: + Enable: true + 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 diff --git a/Config Update V5/new/languages/english_messages.yml b/Config Update V5/new/languages/english_messages.yml new file mode 100644 index 0000000..7f03281 --- /dev/null +++ b/Config Update V5/new/languages/english_messages.yml @@ -0,0 +1,55 @@ +Plugin: + VaultNotSetUp: '[prefix] &4Vault / Economy not set up!' + SoundNotFound: '[prefix] &4The sound &6[sound] &4was not found! Please check the + settings.' + OnlyForPlayer: '[prefix] &cThis command is for players only!' + DefaultGUI: + create: '[prefix] &2DefaultGUI was created. You can find it in the directory: + &e[directory]&2!' + Reload: + Start: '[prefix] &6Plugin is reloaded...' + End: '[prefix] &2Plugin was successfully reloaded.' +NoPermission: + ForCommandGUI: '[prefix] &cYou do not have permission for &4Command&9GUI&c!' + ForCommand: '[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!' + ForUseItem: '[prefix] &cYou lack the permission &6[perm] &cto use the item for the + GUI: &6[gui].' + ForItem: '[prefix] &cFor &b[item] &cyou lack the permission &6[perm]&c!' +UseItem: + UseItem_ON: '[prefix] &2You have activated the GUI item.' + UseItem_OFF: '[prefix] &2You have disabled the GUI item.' + Change_Slot: '[prefix] &2You have changed the GUI item to slot: &6[slot]&2.' + SlotNotEmpty: '[prefix] &6The slot &e[slot] &6is currently occupied!' + SlotAlreadySet: '[prefix] &6The slot §e[slot] §6is already set!' + ItemSlot_wrongValue: '[prefix] &cThe specified slot must be between 1 and 9!' + DisabledInGameMode: '[prefix] &cThe UseItem is disabled in this GameMode!' + DisabledInWorld: '[prefix] &cThe UseItem is disabled in this World!' +Cost: + Buy_msg: '[prefix] &2You bought [itemname] &2for &6[price]&2.' + No_money: '[prefix] &cYou don''t have enough money!' + NoInventorySpace: '[prefix] &cYou have no room in your inventory!' +ServerChange: + onServerChange: '[prefix] &2You will be connected to the server &e[server]§2.' +GUI: + GUInotFound: '[prefix] &cThe GUI chosen by the does not exist.' + GUIisDisabled: '[prefix] &cThe GUI [gui] &cis currently Disabled!' +Give: + Sender: '[prefix] &2You have given &6[player] &2an [item] &2!' + Receiver: '[prefix] &2You got &2, [item] &2from &6[sender]!' +Player: + PlayerNotFond: '[prefix] &cThe player &6[player] &cwas not found or is not online!' + PlayerNoInventorySpace: '[prefix] &6[player] &chas no free space in his inventory!' +Help: + CGUI: '&8''''&b/commandgui &8| &b/cgui&8'''' &eOpen the default GUI &7(&r[gui]&7)&e.' + Help: '&8''''&b/commandguihelp&8'''' &eOpen this help.' + Info: '&8''''&b/commandgui admin info&8'''' &eCall the info from &4Command&9GUI + &e.' + Open: '&8''''&b/commandgui [gui]&8'''' &eOpen the GUI: &6[guiname]&e.' + Give: '&8''''&b/commandgui admin give &7&8'''' &eGive a player the GUI item.' + CreateDefaultGUI: '&8''''&b/commandgui admin createdefaultgui&8'''' &eCreate a default + GUI &7([directory])&e.' + Reload: '&8''''&b/commandgui admin reload&8'''' &eReload the plugin.' + UseItem_On: '&8''''&b/gui-item on&8'''' &eActivate the GUIItem for you.' + UseItem_Off: '&8''''&b/gui-item off&8'''' &eDisable the GUIItem for yourself.' + UseItem_Slot: '&8''''&b/gui-item slot [slot]&8'''' &eSet the slot for GUIItem for + you.' diff --git a/Config Update V5/new/languages/german_messages.yml b/Config Update V5/new/languages/german_messages.yml new file mode 100644 index 0000000..5831fad --- /dev/null +++ b/Config Update V5/new/languages/german_messages.yml @@ -0,0 +1,58 @@ +Plugin: + VaultNotSetUp: '[prefix] &4Vault / Economy nicht eingerichtet!' + SoundNotFound: '[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte [ue]berpr[ue]fe + die Einstellungen.' + OnlyForPlayer: '[prefix] &cDieser Command ist nur f[ue]r Spieler!' + DefaultGUI: + create: '[prefix] &2DefaultGUI wurde erstellt. Du findst sie im Verzeichnis: &e[directory]&2!' + Reload: + Start: '[prefix] &6Plugin wird neu geladen...' + End: '[prefix] &2Plugin wurde erfolgreich neu geladen.' +NoPermission: + ForCommandGUI: '[prefix] &cDu hast keine Permission f[ue]r &4Command&9GUI&c!' + ForCommand: '[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!' + ForUseItem: '[prefix] &cDir fehlt die Permission &6[perm] &cum das Item f[ue]r die + GUI: &6[gui] &cnutzen zu k[oe]nnen.' + ForItem: '[prefix] &cF[ue]r &b[item] &cfehlt dir die Permission &6[perm]&c!' +UseItem: + UseItem_ON: '[prefix] &2Du hast das GUI-Item aktiviert.' + UseItem_OFF: '[prefix] &2Du hast das GUI-Item deaktiviert.' + Change_Slot: '[prefix] &2Du hast das GUI-Item auf Slot &6[slot] &2umgestellt.' + SlotNotEmpty: '[prefix] &6Der Slot §e[slot] §6ist derzeit belegt!.' + SlotAlreadySet: '[prefix] &6Der Slot §e[slot] §6ist bereits eingestellt!' + ItemSlot_wrongValue: '[prefix] &cDer angegebene Slot muss sich zwischen 1 und 9 + befinden!' + DisabledInGameMode: '[prefix] &cDas UseItem ist in diesem GameMode deaktiviert!' + DisabledInWorld: '[prefix] &cDas UseItem ist in dieser Welt deaktiviert!' +Cost: + Buy_msg: '[prefix] &2Du hast dir [itemname] &2f[ue]r &6[price] &2gekauft.' + No_money: '[prefix] &cDu hast nicht gen[ue]gend Geld!' + NoInventorySpace: '[prefix] &cDu hast keinen Platz in deinem Inventar!' +ServerChange: + onServerChange: '[prefix] &2Du wirst auf den Server §e[server] §2verbunden.' +GUI: + GUInotFound: '[prefix] &cDie von die gew[ae]hlte GUI gibt es nicht.' + GUIisDisabled: '[prefix] &cDie GUI [gui] &cist derzeit Deaktiviert!' +Give: + Sender: '[prefix] &2Du hast &6[player] &2ein [item] &2gegeben!' + Receiver: '[prefix] &2Du hast von &6[sender] &2, [item] &2bekommen!' +Player: + PlayerNotFond: '[prefix] &cDer Spieler &6[player] &cwurde nicht gefunden oder ist + nicht Online!' + PlayerNoInventorySpace: '[prefix] &6[player] &chat keinen freien Platz in seinem + Inventar!' +Help: + CGUI: '&8''''&b/commandgui &8| &b/cgui&8'''' &e[OE]ffne die default GUI &7(&r[gui]&7)&e.' + Help: '&8''''&b/commandguihelp&8'''' &e[OE]ffne diese help.' + Info: '&8''''&b/commandgui admin info&8'''' &eRufe die Infos von &4Command&9GUI + &eauf.' + Open: '&8''''&b/commandgui [gui]&8'''' &e[OE]ffne die GUI: &6[guiname]&e.' + Give: '&8''''&b/commandgui admin give &7&8'''' &eGebe einem Spieler das + GUI-Item.' + CreateDefaultGUI: '&8''''&b/commandgui admin createdefaultgui&8'''' &eLasse eine + default GUI erstellen &7([directory])&e.' + Reload: '&8''''&b/commandgui admin reload&8'''' &eLade das Plugin neu.' + UseItem_On: '&8''''&b/gui-item on&8'''' &eAktiviere f[ue]r dich das GUIItem.' + UseItem_Off: '&8''''&b/gui-item off&8'''' &eDeaktiviere f[ue]r dich das GUIItem.' + UseItem_Slot: '&8''''&b/gui-item slot [slot]&8'''' &eSetze den Slot für GUIItem + für Sie einstellen.' diff --git a/Config Update V5/new/languages/norwegian_messages.yml b/Config Update V5/new/languages/norwegian_messages.yml new file mode 100644 index 0000000..eb44615 --- /dev/null +++ b/Config Update V5/new/languages/norwegian_messages.yml @@ -0,0 +1,54 @@ +Plugin: + VaultNotSetUp: '[prefix] &4Vault / Økonomi har ikke blitt satt opp!' + SoundNotFound: '[prefix] &4Lyden &6[sound] &4ble ikke bli funnet! Vennligst sjekk + innstillingene.' + OnlyForPlayer: '[prefix] &cDenne kommandoen er for spillere kun!' + DefaultGUI: + create: '[prefix] &2DefaultGUI har blitt laget. Du kan finne den i mappen: &e[directory]&2!' + Reload: + Start: '[prefix] &6Pluginet blir relastet...' + End: '[prefix] &2Pluginet har blitt lastet inn på nytt.' +NoPermission: + ForCommandGUI: '[prefix] &cDu har ikke tilgang til &4Command&9GUI&c!' + ForCommand: '[prefix] &cFor &b[cmd] &cmangler du tillatelsen &6[perm]&c!' + ForUseItem: '[prefix] &cDu mangler tillatelsen &6[perm] &cfor å bruke gjenstanden + i GUI: &6[gui].' + ForItem: '[prefix] &cFor &b[item] &cmangler du tillatelsen &6[perm]&c!' +UseItem: + UseItem_ON: '[prefix] &2You have activated the GUI item.' + UseItem_OFF: '[prefix] &2You have disabled the GUI item.' + Change_Slot: '[prefix] &2You have changed the GUI item to slot: &6[slot]&2.' + SlotNotEmpty: '[prefix] &6Plassen &e[slot] &6er opptatt for øyeblikket!' + SlotAlreadySet: '[prefix] &6Plassen §e[slot] §6er allerede satt!' + ItemSlot_wrongValue: '[prefix] &cDen spesifiserte plassen må være mellom 1 og 9!' + DisabledInGameMode: '[prefix] &cBrukselementet er deaktivert i denne spillmodusen!!' + DisabledInWorld: '[prefix] &cUseItem er deaktivert i denne verden!' +Cost: + Buy_msg: '[prefix] &2Du kjøpte [itemname] &2for &6[price]&2.' + No_money: '[prefix] &cDu har ikke nok penger!' + NoInventorySpace: '[prefix] &cDu har ikke nok plass i inventaret ditt!' +ServerChange: + onServerChange: '[prefix] &2Du vil bli tilkoblet serveren &e[server]&2.' +GUI: + GUInotFound: '[prefix] &cGUIen som ble spesifisert finnes ikke.' + GUIisDisabled: '[prefix] &cGUIen [gui] &cer slått av for øyeblikket!' +Give: + Sender: '[prefix] &2Du har gitt &6[player] &2en [item]&2!' + Receiver: '[prefix] &2Du fikk &2, [item] &2fra &6[sender]!' +Player: + PlayerNotFond: '[prefix] &cSpilleren &6[player] &cble ikke funnet eller er ikke + pålogget!' + PlayerNoInventorySpace: '[prefix] &6[player] &char ikke nok plass i inventaret sitt!' +Help: + CGUI: '&8''''&b/commandgui &8| &b/cgui&8'''' &eÅpne default GUIen &7(&r[gui]&7)&e.' + Help: '&8''''&b/commandguihelp&8'''' &eSender denne hjelpe meldingen.' + Info: '&8''''&b/commandgui admin info&8'''' &eKall informasjon fra &4Command&9GUI&e.' + Open: '&8''''&b/commandgui [gui]&8'''' &eÅpne GUIen: &6[guiname]&e.' + Give: '&8''''&b/commandgui admin give &7&8'''' &eGi en spiller GUI gjenstanden.' + CreateDefaultGUI: '&8''''&b/commandgui admin createdefaultgui&8'''' &eLag en normalverdi + GUI &7([directory])&e.' + Reload: '&8''''&b/commandgui admin reload&8'''' &eLast inn pluginet på nytt.' + UseItem_On: '&8''''&b/gui-item on&8'''' &eAktiverer en GUI gjenstand for deg.' + UseItem_Off: '&8''''&b/gui-item off&8'''' &eDeaktiverer en GUI gjenstand for deg.' + UseItem_Slot: '&8''''&b/gui-item slot [slot]&8'''' &eSett sporet for GUIItem for + deg.' diff --git a/Config Update V5/old/GUIs/default.yml b/Config Update V5/old/GUIs/default.yml new file mode 100644 index 0000000..9095465 --- /dev/null +++ b/Config Update V5/old/GUIs/default.yml @@ -0,0 +1,159 @@ +GUI: + Enable: true + Lines: 1 + Name: '&5default &9GUI' + FillItem: + Enable: true + Item: BLACK_STAINED_GLASS_PANE +Command: + Alias: true + Permission: + Required: true +Slots: + SupportDiscord: + Slot: 4 + 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: §7http://dc.t2code.net' + CustomSound: + Enable: false + NoSound: false + Sound: '' + Cost: + Enable: false + Price: 0.0 + Command: + Enable: false + BungeeCommand: false + CommandAsConsole: false + Command: [] + ServerChange: + Enable: false + Server: '' + OpenGUI: + Enable: false + GUI: '' + Toggle: + Permission: + Enable: false + Permission: '' + UseItem: + Enable: false + Message: + Enable: true + Message: + - '&6You can find more information on Discord: &ehttp://dc.t2code.net' + Permission: + Required: false + SetConfig: + Enable: false + File: + Path: '' + Option: + Path: '' + Premat: String + Value: + LeftClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + RightClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + PluginReload: + Enable: false + Command: '' + UseItem: + Slot: 6 + Enable: true + Item: + Empty: false + Amount: 1 + PlayerHead: + Enable: false + Base64: + Enable: false + Base64Value: '' + PlayerWhoHasOpenedTheGUI: false + PlayerName: '' + Material: '' + Name: '&6Toggle UseItem' + Lore: + - '&bYou currently have the UseItem set to: %commandgui_useitem%' + CustomSound: + Enable: false + NoSound: false + Sound: '' + Cost: + Enable: false + Price: 0.0 + Command: + Enable: false + BungeeCommand: false + CommandAsConsole: false + Command: [] + ServerChange: + Enable: false + Server: '' + OpenGUI: + Enable: false + GUI: '' + Toggle: + Permission: + Enable: false + Permission: '' + UseItem: + Enable: true + Message: + Enable: true + Message: + - '&bYour UseItem was set to: %commandgui_useitem%&b.' + Permission: + Required: false + SetConfig: + Enable: false + File: + Path: '' + Option: + Path: '' + Premat: String + Value: + LeftClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + RightClick: + String: '' + Boolean: false + Integer: 0 + Double: 0.0 + List: [] + PluginReload: + Enable: false + Command: '' diff --git a/Config Update V5/old/config.yml b/Config Update V5/old/config.yml new file mode 100644 index 0000000..5ef9e45 --- /dev/null +++ b/Config Update V5/old/config.yml @@ -0,0 +1,121 @@ +ConfigVersion: 4 +Plugin: + UpdateCheckOnJoin: true + Debug: false + HelpAlias: true + language: english + Currency: $ + DefaultGUI: default +Storage: + Type: YML + MySQL: + IP: localhost + Port: 3306 + Database: database + User: root + Password: password + SSL: false +BungeeCord: + Enable: false + ThisServer: server +UseItem: + Enable: true + AllowToggle: true + AllowSetSlot: true + BlockMoveAndDrop: true + OpenGUI: default + Permission: + NeededToUse: true + KeepAtCommandClear: true + InventorySlot: + Slot: 1 + SlotEnforce: false + FreeSlot: false + Item: + Material: paper + PlayerHead: + Enable: false + Base64: + Enable: false + Base64Value: '' + PlayerWhoHasOpenedTheGUI: false + Playername: '' + Name: '&bDefault &6GUI' + Lore: + - '&eThis is an example GUI' + Join: + GiveOnEveryJoin: true + GiveOnlyOnFirstJoin: false + Cursor: + ToGUIItem: + OnLogin: + Enable: true + Spigot: + OnOnlyFirstLogin: true + Bungee: + OnServerChange: false +Advanced: + UseItem: + GameMode: + Change: + Enable: true + DelayInTicks: 1 + Protection: + Enable: false + RemoveItemWhenItIsDisabled: false + Mode: blacklist + List: + - CREATIVE + - Spectator + World: + Change: + Enable: true + DelayInTicks: 1 + Protection: + Enable: false + RemoveItemWhenItIsDisabled: false + Mode: blacklist + List: + - World1 + - World2 +Toggle: + Items: + OnOrYes: + Item: + Base64: + Enable: false + Base64Value: '' + Material: GREEN_WOOL + OffOrNo: + Item: + Base64: + Enable: false + Base64Value: '' + Material: RED_WOOL + Permission: + Commands: + 'True': luckperms user [player] permission set [perm] true + 'False': luckperms user [player] permission set [perm] false +Placeholder: + 'True': '&2true' + 'False': '&4false' +Sound: + Enable: true + 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 diff --git a/Config Update V5/old/languages/english_messages.yml b/Config Update V5/old/languages/english_messages.yml new file mode 100644 index 0000000..7f03281 --- /dev/null +++ b/Config Update V5/old/languages/english_messages.yml @@ -0,0 +1,55 @@ +Plugin: + VaultNotSetUp: '[prefix] &4Vault / Economy not set up!' + SoundNotFound: '[prefix] &4The sound &6[sound] &4was not found! Please check the + settings.' + OnlyForPlayer: '[prefix] &cThis command is for players only!' + DefaultGUI: + create: '[prefix] &2DefaultGUI was created. You can find it in the directory: + &e[directory]&2!' + Reload: + Start: '[prefix] &6Plugin is reloaded...' + End: '[prefix] &2Plugin was successfully reloaded.' +NoPermission: + ForCommandGUI: '[prefix] &cYou do not have permission for &4Command&9GUI&c!' + ForCommand: '[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!' + ForUseItem: '[prefix] &cYou lack the permission &6[perm] &cto use the item for the + GUI: &6[gui].' + ForItem: '[prefix] &cFor &b[item] &cyou lack the permission &6[perm]&c!' +UseItem: + UseItem_ON: '[prefix] &2You have activated the GUI item.' + UseItem_OFF: '[prefix] &2You have disabled the GUI item.' + Change_Slot: '[prefix] &2You have changed the GUI item to slot: &6[slot]&2.' + SlotNotEmpty: '[prefix] &6The slot &e[slot] &6is currently occupied!' + SlotAlreadySet: '[prefix] &6The slot §e[slot] §6is already set!' + ItemSlot_wrongValue: '[prefix] &cThe specified slot must be between 1 and 9!' + DisabledInGameMode: '[prefix] &cThe UseItem is disabled in this GameMode!' + DisabledInWorld: '[prefix] &cThe UseItem is disabled in this World!' +Cost: + Buy_msg: '[prefix] &2You bought [itemname] &2for &6[price]&2.' + No_money: '[prefix] &cYou don''t have enough money!' + NoInventorySpace: '[prefix] &cYou have no room in your inventory!' +ServerChange: + onServerChange: '[prefix] &2You will be connected to the server &e[server]§2.' +GUI: + GUInotFound: '[prefix] &cThe GUI chosen by the does not exist.' + GUIisDisabled: '[prefix] &cThe GUI [gui] &cis currently Disabled!' +Give: + Sender: '[prefix] &2You have given &6[player] &2an [item] &2!' + Receiver: '[prefix] &2You got &2, [item] &2from &6[sender]!' +Player: + PlayerNotFond: '[prefix] &cThe player &6[player] &cwas not found or is not online!' + PlayerNoInventorySpace: '[prefix] &6[player] &chas no free space in his inventory!' +Help: + CGUI: '&8''''&b/commandgui &8| &b/cgui&8'''' &eOpen the default GUI &7(&r[gui]&7)&e.' + Help: '&8''''&b/commandguihelp&8'''' &eOpen this help.' + Info: '&8''''&b/commandgui admin info&8'''' &eCall the info from &4Command&9GUI + &e.' + Open: '&8''''&b/commandgui [gui]&8'''' &eOpen the GUI: &6[guiname]&e.' + Give: '&8''''&b/commandgui admin give &7&8'''' &eGive a player the GUI item.' + CreateDefaultGUI: '&8''''&b/commandgui admin createdefaultgui&8'''' &eCreate a default + GUI &7([directory])&e.' + Reload: '&8''''&b/commandgui admin reload&8'''' &eReload the plugin.' + UseItem_On: '&8''''&b/gui-item on&8'''' &eActivate the GUIItem for you.' + UseItem_Off: '&8''''&b/gui-item off&8'''' &eDisable the GUIItem for yourself.' + UseItem_Slot: '&8''''&b/gui-item slot [slot]&8'''' &eSet the slot for GUIItem for + you.' diff --git a/Config Update V5/old/languages/german_messages.yml b/Config Update V5/old/languages/german_messages.yml new file mode 100644 index 0000000..5831fad --- /dev/null +++ b/Config Update V5/old/languages/german_messages.yml @@ -0,0 +1,58 @@ +Plugin: + VaultNotSetUp: '[prefix] &4Vault / Economy nicht eingerichtet!' + SoundNotFound: '[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte [ue]berpr[ue]fe + die Einstellungen.' + OnlyForPlayer: '[prefix] &cDieser Command ist nur f[ue]r Spieler!' + DefaultGUI: + create: '[prefix] &2DefaultGUI wurde erstellt. Du findst sie im Verzeichnis: &e[directory]&2!' + Reload: + Start: '[prefix] &6Plugin wird neu geladen...' + End: '[prefix] &2Plugin wurde erfolgreich neu geladen.' +NoPermission: + ForCommandGUI: '[prefix] &cDu hast keine Permission f[ue]r &4Command&9GUI&c!' + ForCommand: '[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!' + ForUseItem: '[prefix] &cDir fehlt die Permission &6[perm] &cum das Item f[ue]r die + GUI: &6[gui] &cnutzen zu k[oe]nnen.' + ForItem: '[prefix] &cF[ue]r &b[item] &cfehlt dir die Permission &6[perm]&c!' +UseItem: + UseItem_ON: '[prefix] &2Du hast das GUI-Item aktiviert.' + UseItem_OFF: '[prefix] &2Du hast das GUI-Item deaktiviert.' + Change_Slot: '[prefix] &2Du hast das GUI-Item auf Slot &6[slot] &2umgestellt.' + SlotNotEmpty: '[prefix] &6Der Slot §e[slot] §6ist derzeit belegt!.' + SlotAlreadySet: '[prefix] &6Der Slot §e[slot] §6ist bereits eingestellt!' + ItemSlot_wrongValue: '[prefix] &cDer angegebene Slot muss sich zwischen 1 und 9 + befinden!' + DisabledInGameMode: '[prefix] &cDas UseItem ist in diesem GameMode deaktiviert!' + DisabledInWorld: '[prefix] &cDas UseItem ist in dieser Welt deaktiviert!' +Cost: + Buy_msg: '[prefix] &2Du hast dir [itemname] &2f[ue]r &6[price] &2gekauft.' + No_money: '[prefix] &cDu hast nicht gen[ue]gend Geld!' + NoInventorySpace: '[prefix] &cDu hast keinen Platz in deinem Inventar!' +ServerChange: + onServerChange: '[prefix] &2Du wirst auf den Server §e[server] §2verbunden.' +GUI: + GUInotFound: '[prefix] &cDie von die gew[ae]hlte GUI gibt es nicht.' + GUIisDisabled: '[prefix] &cDie GUI [gui] &cist derzeit Deaktiviert!' +Give: + Sender: '[prefix] &2Du hast &6[player] &2ein [item] &2gegeben!' + Receiver: '[prefix] &2Du hast von &6[sender] &2, [item] &2bekommen!' +Player: + PlayerNotFond: '[prefix] &cDer Spieler &6[player] &cwurde nicht gefunden oder ist + nicht Online!' + PlayerNoInventorySpace: '[prefix] &6[player] &chat keinen freien Platz in seinem + Inventar!' +Help: + CGUI: '&8''''&b/commandgui &8| &b/cgui&8'''' &e[OE]ffne die default GUI &7(&r[gui]&7)&e.' + Help: '&8''''&b/commandguihelp&8'''' &e[OE]ffne diese help.' + Info: '&8''''&b/commandgui admin info&8'''' &eRufe die Infos von &4Command&9GUI + &eauf.' + Open: '&8''''&b/commandgui [gui]&8'''' &e[OE]ffne die GUI: &6[guiname]&e.' + Give: '&8''''&b/commandgui admin give &7&8'''' &eGebe einem Spieler das + GUI-Item.' + CreateDefaultGUI: '&8''''&b/commandgui admin createdefaultgui&8'''' &eLasse eine + default GUI erstellen &7([directory])&e.' + Reload: '&8''''&b/commandgui admin reload&8'''' &eLade das Plugin neu.' + UseItem_On: '&8''''&b/gui-item on&8'''' &eAktiviere f[ue]r dich das GUIItem.' + UseItem_Off: '&8''''&b/gui-item off&8'''' &eDeaktiviere f[ue]r dich das GUIItem.' + UseItem_Slot: '&8''''&b/gui-item slot [slot]&8'''' &eSetze den Slot für GUIItem + für Sie einstellen.' diff --git a/Config Update V5/old/languages/norwegian_messages.yml b/Config Update V5/old/languages/norwegian_messages.yml new file mode 100644 index 0000000..eb44615 --- /dev/null +++ b/Config Update V5/old/languages/norwegian_messages.yml @@ -0,0 +1,54 @@ +Plugin: + VaultNotSetUp: '[prefix] &4Vault / Økonomi har ikke blitt satt opp!' + SoundNotFound: '[prefix] &4Lyden &6[sound] &4ble ikke bli funnet! Vennligst sjekk + innstillingene.' + OnlyForPlayer: '[prefix] &cDenne kommandoen er for spillere kun!' + DefaultGUI: + create: '[prefix] &2DefaultGUI har blitt laget. Du kan finne den i mappen: &e[directory]&2!' + Reload: + Start: '[prefix] &6Pluginet blir relastet...' + End: '[prefix] &2Pluginet har blitt lastet inn på nytt.' +NoPermission: + ForCommandGUI: '[prefix] &cDu har ikke tilgang til &4Command&9GUI&c!' + ForCommand: '[prefix] &cFor &b[cmd] &cmangler du tillatelsen &6[perm]&c!' + ForUseItem: '[prefix] &cDu mangler tillatelsen &6[perm] &cfor å bruke gjenstanden + i GUI: &6[gui].' + ForItem: '[prefix] &cFor &b[item] &cmangler du tillatelsen &6[perm]&c!' +UseItem: + UseItem_ON: '[prefix] &2You have activated the GUI item.' + UseItem_OFF: '[prefix] &2You have disabled the GUI item.' + Change_Slot: '[prefix] &2You have changed the GUI item to slot: &6[slot]&2.' + SlotNotEmpty: '[prefix] &6Plassen &e[slot] &6er opptatt for øyeblikket!' + SlotAlreadySet: '[prefix] &6Plassen §e[slot] §6er allerede satt!' + ItemSlot_wrongValue: '[prefix] &cDen spesifiserte plassen må være mellom 1 og 9!' + DisabledInGameMode: '[prefix] &cBrukselementet er deaktivert i denne spillmodusen!!' + DisabledInWorld: '[prefix] &cUseItem er deaktivert i denne verden!' +Cost: + Buy_msg: '[prefix] &2Du kjøpte [itemname] &2for &6[price]&2.' + No_money: '[prefix] &cDu har ikke nok penger!' + NoInventorySpace: '[prefix] &cDu har ikke nok plass i inventaret ditt!' +ServerChange: + onServerChange: '[prefix] &2Du vil bli tilkoblet serveren &e[server]&2.' +GUI: + GUInotFound: '[prefix] &cGUIen som ble spesifisert finnes ikke.' + GUIisDisabled: '[prefix] &cGUIen [gui] &cer slått av for øyeblikket!' +Give: + Sender: '[prefix] &2Du har gitt &6[player] &2en [item]&2!' + Receiver: '[prefix] &2Du fikk &2, [item] &2fra &6[sender]!' +Player: + PlayerNotFond: '[prefix] &cSpilleren &6[player] &cble ikke funnet eller er ikke + pålogget!' + PlayerNoInventorySpace: '[prefix] &6[player] &char ikke nok plass i inventaret sitt!' +Help: + CGUI: '&8''''&b/commandgui &8| &b/cgui&8'''' &eÅpne default GUIen &7(&r[gui]&7)&e.' + Help: '&8''''&b/commandguihelp&8'''' &eSender denne hjelpe meldingen.' + Info: '&8''''&b/commandgui admin info&8'''' &eKall informasjon fra &4Command&9GUI&e.' + Open: '&8''''&b/commandgui [gui]&8'''' &eÅpne GUIen: &6[guiname]&e.' + Give: '&8''''&b/commandgui admin give &7&8'''' &eGi en spiller GUI gjenstanden.' + CreateDefaultGUI: '&8''''&b/commandgui admin createdefaultgui&8'''' &eLag en normalverdi + GUI &7([directory])&e.' + Reload: '&8''''&b/commandgui admin reload&8'''' &eLast inn pluginet på nytt.' + UseItem_On: '&8''''&b/gui-item on&8'''' &eAktiverer en GUI gjenstand for deg.' + UseItem_Off: '&8''''&b/gui-item off&8'''' &eDeaktiverer en GUI gjenstand for deg.' + UseItem_Slot: '&8''''&b/gui-item slot [slot]&8'''' &eSett sporet for GUIItem for + deg.' -- 2.34.1 From 8e90aee0ca2f4a2025f94cc9c5048eb4263e90dd Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 08:32:07 +0200 Subject: [PATCH 07/16] 2.7.0_Snapshot-2 | small change Fix: the sound was not played when CostumSound was off in the function Change: placeholder in slot permissions changed from '[guiname]' to '[function]'. --- CommandGUI V2/pom.xml | 2 +- .../jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java | 2 +- .../Spigot/Listener/UseItem_Listener/Events.java | 3 --- .../commandguiv2/Spigot/cmdManagement/Commands.java | 6 ------ .../Spigot/cmdManagement/register/RegisterCommand.java | 3 --- .../config/configConverter/ConfigConverterUnderV5.java | 4 ++-- .../jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java | 8 ++++---- .../java/de/jatitv/commandguiv2/Spigot/gui/OpenGUI.java | 3 +++ .../de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java | 6 ++++-- 9 files changed, 15 insertions(+), 22 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index dac2e8e..cc1b140 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.7.0_Snapshot-1 + 2.7.0_Snapshot-2 jar CommandGUI 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 d0d0dc0..419a162 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 @@ -234,7 +234,7 @@ public class GUI_Listener implements Listener { player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); } } - } + } else player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); } private static void togglePerm(Function slot, Player player) { 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 7906ce2..0a3b85f 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 @@ -202,9 +202,6 @@ public class Events implements Listener { } if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) { OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI); - if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { - p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); - } } else { p.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") .replace("[gui]", SelectConfig.UseItem_OpenGUI)); 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 0dc832a..751538b 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 @@ -219,9 +219,6 @@ public class Commands { if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, SelectConfig.DefaultGUI); - if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { - player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); - } } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui") .replace("[perm]", "commandgui.command")); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name)); @@ -234,9 +231,6 @@ public class Commands { if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, arg); - if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { - player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); - } } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.Command_Command) .replace("[perm]", "commandgui.command." + arg.toLowerCase())); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.Command_Command)); 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 9f5cb9b..e66bb03 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 @@ -27,9 +27,6 @@ public class RegisterCommand extends Command { if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, alias); - if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { - player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); - } } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias) .replace("[perm]", "commandgui.command." + alias)); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name)); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java index f8f5375..14f3988 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/configConverter/ConfigConverterUnderV5.java @@ -152,8 +152,8 @@ public class ConfigConverterUnderV5 { set("Slots." + key + ".Enable", slotEnable, yamlConfiguration); set("Slots." + key + ".Function", function, yamlConfiguration); set("Slots." + key + ".Permission.Required", permRequired, yamlConfiguration); - set("Slots." + key + ".Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration); - set("Slots." + key + ".Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration); + set("Slots." + key + ".Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration); + set("Slots." + key + ".Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration); } private static void set(String path, String value, YamlConfiguration config) { diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java index 4832a79..78fcf7c 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/gui/CreateGUI.java @@ -33,15 +33,15 @@ public class CreateGUI { set("Slots.SupportDiscord.Enable", true, yamlConfiguration); set("Slots.SupportDiscord.Function", "SupportDiscord", yamlConfiguration); set("Slots.SupportDiscord.Permission.Required", false, yamlConfiguration); - set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration); - set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration); + set("Slots.SupportDiscord.Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration); + set("Slots.SupportDiscord.Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration); set("Slots.UseItem.Slot", 6, yamlConfiguration); set("Slots.UseItem.Enable", true, yamlConfiguration); set("Slots.UseItem.Function", "UseItem", yamlConfiguration); set("Slots.UseItem.Permission.Required", false, yamlConfiguration); - set("Slots.UseItem.Permission.See", "commandgui.gui.[guiname].slot.[slot].see", yamlConfiguration); - set("Slots.UseItem.Permission.Use", "commandgui.gui.[guiname].slot.[slot].use", yamlConfiguration); + set("Slots.UseItem.Permission.See", "commandgui.gui.[function].slot.[slot].see", yamlConfiguration); + set("Slots.UseItem.Permission.Use", "commandgui.gui.[function].slot.[slot].use", yamlConfiguration); try { 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 d3679d5..b7d444d 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 @@ -121,6 +121,9 @@ public class OpenGUI { } } + if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { + player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); + } player.openInventory(inventory); send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name))); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java index 8cddb0d..14be303 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java @@ -62,8 +62,10 @@ public class Obj_Select { String permUse = yamlConfiguration_gui.getString("Slots." + key + ".Permission.Use"); Slot slot = new Slot(slotNumber, enable, function, permRequired, - Objects.requireNonNull(permSee).replace("[guiname]", guiFileName).replace("[slot]", String.valueOf(slotNumber)) - .replace("[slotname]", key), permUse); + Objects.requireNonNull(permSee).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber)) + .replace("[slotname]", key.toLowerCase()), + Objects.requireNonNull(permUse).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber)) + .replace("[slotname]", key.toLowerCase())); slots.add(slot); } Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, -- 2.34.1 From 520df8dc97b5752add85585a813daae5e5c53132 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 09:22:56 +0200 Subject: [PATCH 08/16] 2.7.0_Snapshot-3 | Perm Update Removed permissiond regestration from plugin.yml and regestred via code. - The Slot See and Use Permissions are now included in OP and commandgui.admin --- CommandGUI V2/pom.xml | 2 +- .../Spigot/cmdManagement/Help.java | 3 - .../Spigot/system/RegisterPermissions.java | 72 ++++++++++++-- CommandGUI V2/src/main/resources/plugin.yml | 96 +++++++++---------- 4 files changed, 111 insertions(+), 62 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index cc1b140..2956aaa 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.7.0_Snapshot-2 + 2.7.0_Snapshot-3 jar CommandGUI 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 1483836..e89c908 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 @@ -31,9 +31,6 @@ public class Help { if (sender.hasPermission("commandgui.command.info")) { send.sender(sender, Prefix + " " + SelectMessages.HelpInfo); } - // if (sender.hasPermission("commandgui.command.give")) { - // send.sender(sender, Prefix + " " + Select_msg.HelpGive); - // } if (sender.hasPermission("commandgui.admin")) { send.sender(sender, Prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath()+ "\\GUIs\\default.yml")); send.sender(sender, Prefix + " " + SelectMessages.HelpReload); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java index e7bfed2..57e4fd1 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java @@ -4,22 +4,76 @@ import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; +import net.t2code.lib.Spigot.Lib.register.Register; import org.bukkit.Bukkit; import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.Plugin; public class RegisterPermissions { + private static final Plugin plugin = Main.plugin; + + public static final String key = "commandgui."; + public static final String command = key + "command"; + public static final String info = key + "command.info"; + public static final String bypass = key + "bypass"; + public static final String useitemToggle = key + "useitem.toggle"; + public static final String useitem = key + "useitem"; + public static final String getGuiItemAtLogin = key + "get.guiitem.at.login"; + public static final String updatemsg = key + "updatemsgupdatemsg"; + + public static final String player = key + "player"; + public static final String admin = key + "admin"; + + public static final PermissionDefault op = PermissionDefault.OP; + public static final PermissionDefault notOp = PermissionDefault.NOT_OP; + public static void onPermRegister() { + Register.permission(command, op, plugin); + Register.permissionDescription(command, "Required permission to open GUIs via command", plugin); + + Register.permission(getGuiItemAtLogin, op, plugin); + Register.permissionDescription(getGuiItemAtLogin, "Only players with this permission will receive the GUI item", plugin); + + Register.permission(useitem, op, plugin); + Register.permissionDescription(useitem, "Required permission to use the GUI Item", plugin); + + Register.permission(useitemToggle, op, plugin); + Register.permissionDescription(useitemToggle, "Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)", plugin); + + Register.permission(updatemsg, op, plugin); + Register.permissionDescription(updatemsg, "Players with this permission get the update message when joining if an update is available", plugin); + + Register.permission(bypass, op, plugin); + Register.permissionDescription(bypass, "Bypass to open disabled GUIs", plugin); + + Register.permission(info, notOp, plugin); + Register.permissionDescription(info, "Permission to view CommandGUI info", plugin); + + Register.permission(player, op, command, true, plugin); + Register.permission(player, op, getGuiItemAtLogin, true, plugin); + Register.permission(player, op, useitem, true, plugin); + Register.permission(player, op, useitemToggle, true, plugin); + Register.permissionDescription(player, "All permissions from CommandGUI for Player", plugin); + + Register.permission(admin, op, command, true, plugin); + Register.permission(admin, op, getGuiItemAtLogin, true, plugin); + Register.permission(admin, op, useitem, true, plugin); + Register.permission(admin, op, useitemToggle, true, plugin); + Register.permission(admin, op, updatemsg, true, plugin); + Register.permission(admin, op, bypass, true, plugin); + Register.permission(admin, op, info, true, plugin); + Register.permissionDescription(admin, "All permissions from CommandGUI", plugin); + + for (Gui gui : Main.guiHashMap.values()) { - if (Bukkit.getPluginManager().getPermission("commandgui.command." + gui.Command_Command) == null) { - Bukkit.getPluginManager().addPermission(new Permission("commandgui.command." + gui.Command_Command)); - } + Register.permission("commandgui.command." + gui.Command_Command, op, plugin); + Register.permission(admin, op, "commandgui.command." + gui.Command_Command, true, plugin); for (Slot slot : gui.slots) { - if (Bukkit.getPluginManager().getPermission(slot.permissionToUse) == null) { - Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToUse)); - } - if (Bukkit.getPluginManager().getPermission(slot.permissionToSee) == null) { - Bukkit.getPluginManager().addPermission(new Permission(slot.permissionToSee)); - } + Register.permission(slot.permissionToUse, op, plugin); + Register.permission(admin, op, slot.permissionToUse, true, plugin); + Register.permission(slot.permissionToSee, op, plugin); + Register.permission(admin, op, slot.permissionToSee, true, plugin); } } } diff --git a/CommandGUI V2/src/main/resources/plugin.yml b/CommandGUI V2/src/main/resources/plugin.yml index 90ebe99..3459066 100644 --- a/CommandGUI V2/src/main/resources/plugin.yml +++ b/CommandGUI V2/src/main/resources/plugin.yml @@ -19,56 +19,54 @@ commands: commandguihelp: description: CommandGUI Help aliases: [cguihelp, guihelp] - # commandguiadmin: - # aliases: [cguiadmin, cguia] commandgui-item: aliases: [gui-item] -permissions: - commandgui.admin: - description: All permissions from CommandGUI - default: op - children: - commandgui.updatemsg: true - commandgui.command: true - commandgui.get.guiitem.at.login: true - commandgui.useitem: true - commandgui.useitem.toggle: true - commandgui.bypass: true - commandgui.command.info: true - commandgui.command.give: true - - commandgui.player: - description: All permissions from CommandGUI - default: op - children: - commandgui.command: true - commandgui.get.guiitem.at.login: true - commandgui.useitem: true - commandgui.useitem.toggle: true - - commandgui.updatemsg: - description: Players with this permission get the update message when joining if an update is available - default: op - commandgui.command: - description: Required permission to open GUIs via command - default: op - commandgui.get.guiitem.at.login: - description: Only players with this permission will receive the GUI item - default: op - commandgui.useitem: - description: Required permission to use the GUI Item - default: op - commandgui.useitem.toggle: - description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true) - default: op - commandgui.bypass: - description: Bypass to open disabled GUIs - default: op - commandgui.command.info: - description: Permission to view CommandGUI info - default: not op - commandgui.command.give: - description: Kommend in V2.1.0 - default: op \ No newline at end of file +#permissions: +# commandgui.admin: +# description: All permissions from CommandGUI +# default: op +# children: +# commandgui.command: true +# commandgui.get.guiitem.at.login: true +# commandgui.useitem: true +# commandgui.useitem.toggle: true +# commandgui.updatemsg: true +# commandgui.bypass: true +# commandgui.command.info: true +# commandgui.command.give: true +# +# commandgui.player: +# description: All permissions from CommandGUI +# default: op +# children: +# commandgui.command: true +# commandgui.get.guiitem.at.login: true +# commandgui.useitem: true +# commandgui.useitem.toggle: true +# +# commandgui.updatemsg: +# description: Players with this permission get the update message when joining if an update is available +# default: op +# commandgui.command: +# description: Required permission to open GUIs via command +# default: op +# commandgui.get.guiitem.at.login: +# description: Only players with this permission will receive the GUI item +# default: op +# commandgui.useitem: +# description: Required permission to use the GUI Item +# default: op +# commandgui.useitem.toggle: +# description: Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true) +# default: op +# commandgui.bypass: +# description: Bypass to open disabled GUIs +# default: op +# commandgui.command.info: +# description: Permission to view CommandGUI info +# default: not op +# commandgui.command.give: +# description: Kommend in V2.1.0 +# default: op \ No newline at end of file -- 2.34.1 From 7993dca126797237592575241dd3429fd97a78cd Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 09:32:18 +0200 Subject: [PATCH 09/16] refresh perms by reload --- .../jatitv/commandguiv2/Spigot/cmdManagement/Commands.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 751538b..4de55f9 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 @@ -11,6 +11,7 @@ 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.RegisterPermissions; import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; @@ -77,6 +78,11 @@ public class Commands { } catch (Exception e) { e.printStackTrace(); } + try { + RegisterPermissions.onPermRegister(); + } catch (Exception e) { + e.printStackTrace(); + } if (SelectConfig.Bungee) { Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee"); -- 2.34.1 From 3bd0662273a4f1354ac344d1b4877b6be2240fd5 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 09:40:15 +0200 Subject: [PATCH 10/16] fix use and see perm --- .../de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java index 14be303..6a5b70f 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java @@ -62,10 +62,10 @@ public class Obj_Select { String permUse = yamlConfiguration_gui.getString("Slots." + key + ".Permission.Use"); Slot slot = new Slot(slotNumber, enable, function, permRequired, - Objects.requireNonNull(permSee).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber)) + Objects.requireNonNull(permSee).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber + 1)) .replace("[slotname]", key.toLowerCase()), - Objects.requireNonNull(permUse).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber)) - .replace("[slotname]", key.toLowerCase())); + Objects.requireNonNull(permUse).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber + 1)) + .replace("[slotname]", key.toLowerCase())); slots.add(slot); } Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, -- 2.34.1 From c5bc880ab11ed9da1ddfe93594249ef6f53e08a2 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 19 Apr 2022 18:03:44 +0200 Subject: [PATCH 11/16] Add SQLITE & Bugfix Add: SQLITE as storage medium Change: The MYSQL connection has been slightly optimized Fix: The command 'gui-item slot ' dat not set the item to the right place? --- CommandGUI V2/pom.xml | 2 +- .../Spigot/Listener/GUI_Listener.java | 52 +++++-- .../Listener/UseItem_Listener/Events.java | 2 +- .../Spigot/cmdManagement/Commands.java | 7 +- .../register/RegisterCommand.java | 2 +- .../Spigot/config/config/ConfigCreate.java | 2 +- .../Spigot/config/config/SelectConfig.java | 5 +- .../commandguiv2/Spigot/gui/OpenGUI.java | 12 +- .../commandguiv2/Spigot/system/Load.java | 28 +++- .../commandguiv2/Spigot/system/Metrics.java | 1 - .../Spigot/system/database/SQLITE.java | 135 ++++++++++++++++++ .../system/database/Select_Database.java | 121 +++++++++++----- .../Spigot/system/database/StorageType.java | 7 + 13 files changed, 309 insertions(+), 67 deletions(-) create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java create mode 100644 CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/StorageType.java diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 2956aaa..79fda5a 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.7.0_Snapshot-3 + 2.7.0_Snapshot-5 jar CommandGUI 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 419a162..5b8d602 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 @@ -30,6 +30,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.io.File; import java.io.IOException; +import java.util.Objects; public class GUI_Listener implements Listener { @@ -53,15 +54,16 @@ public class GUI_Listener implements Listener { if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() || e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() || e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) { - if (slot.permission || !player.hasPermission(slot.permissionToUse)) { + if (slot.permission && !player.hasPermission(slot.permissionToUse)) { player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name)) .replace("[perm]", slot.permissionToUse)); continue; } if (!slot.enable) continue; - if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, function.name))) continue; + send.debugmsg(Main.plugin, function.name); if (function.cost_Enable) { if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) { + if (!Vault.buy(prefix, player, function.price)) { new BukkitRunnable() { @Override @@ -78,7 +80,9 @@ public class GUI_Listener implements Listener { execute(function, slot, player, e, gui); } } - } else execute(function, slot, player, e, gui); + } else { + execute(function, slot, player, e, gui); + } } } } @@ -86,8 +90,8 @@ public class GUI_Listener implements Listener { } private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) { - if (function.togglePermission) togglePerm(function, player); - if (function.toggleUseItem) toggleUseItem(player); + if (function.togglePermission) togglePerm(function, gui, player); + if (function.toggleUseItem) toggleUseItem(player, gui); if (function.command_Enable) command(function, player); if (function.openGUI_Enable) openGUI(function, player); if (function.message_Enable) message(function, player); @@ -131,7 +135,7 @@ public class GUI_Listener implements Listener { new BukkitRunnable() { @Override public void run() { - OpenGUI.openGUI(player, slot.openGUI); + OpenGUI.openGUI(player, slot.openGUI, true); } }.runTaskLater(plugin, 1L); } @@ -227,7 +231,6 @@ public class GUI_Listener implements Listener { if (!function.customSound_NoSound) { try { player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1); - } catch (Exception e1) { send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound)); @@ -237,16 +240,39 @@ public class GUI_Listener implements Listener { } else player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); } - private static void togglePerm(Function slot, Player player) { - if (player.hasPermission(slot.togglePermissionPerm)) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm)); + private static void togglePerm(Function function, Gui gui, Player player) { + if (player.hasPermission(function.togglePermissionPerm)) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermFalse.replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + OpenGUI.openGUI(player, gui.Command_Command, false); + } + }.runTaskLater(plugin, 4L); } else - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", slot.togglePermissionPerm)); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.togglePermTrue.replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + OpenGUI.openGUI(player, gui.Command_Command, false); + } + }.runTaskLater(plugin, 4L); } - private static void toggleUseItem(Player player) { + private static void toggleUseItem(Player player, Gui gui) { if (Events.useItemHashMap.get(player)) { Commands.itemOff(player); - } else Commands.itemOn(player); + } else { + Commands.itemOn(player); + } + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + OpenGUI.openGUI(player, gui.Command_Command, false); + } + }.runTaskLater(plugin, 2L); } } \ 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 0a3b85f..8a9cb3f 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 @@ -201,7 +201,7 @@ public class Events implements Listener { } } if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) { - OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI); + OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI, true); } else { p.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") .replace("[gui]", SelectConfig.UseItem_OpenGUI)); 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 4de55f9..3ff09a8 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 @@ -186,7 +186,7 @@ public class Commands { send.player(player, SelectMessages.ItemSlot_wrongValue); return; } - ItemStack itm1 = player.getInventory().getItem(setSlot - 1); + ItemStack itm1 = player.getInventory().getItem(setSlot + 1); if (itm1 != null) { if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) { if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { @@ -212,6 +212,7 @@ public class Commands { } } Select_Database.setSlot(player, setSlot); + Events.useItemSlotHashMap.replace(player,setSlot); if (Events.useItemHashMap.get(player)) { Give_UseItem.onGive(player); } @@ -224,7 +225,7 @@ public class Commands { Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, SelectConfig.DefaultGUI); + OpenGUI.openGUI(player, SelectConfig.DefaultGUI, true); } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui") .replace("[perm]", "commandgui.command")); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name)); @@ -236,7 +237,7 @@ public class Commands { Gui gui = Main.guiHashMap.get(arg); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, arg); + OpenGUI.openGUI(player, arg, true); } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.Command_Command) .replace("[perm]", "commandgui.command." + arg.toLowerCase())); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.Command_Command)); 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 e66bb03..e9f36de 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 @@ -26,7 +26,7 @@ public class RegisterCommand extends Command { Gui gui = Main.guiHashMap.get(alias); if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { - OpenGUI.openGUI(player, alias); + OpenGUI.openGUI(player, alias, true); } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias) .replace("[perm]", "commandgui.command." + alias)); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name)); 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 5f285d1..1962125 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 @@ -34,7 +34,7 @@ public class ConfigCreate { Config.set("Plugin.Currency", "$", yamlConfiguration); Config.set("Plugin.DefaultGUI", "default", yamlConfiguration); - Config.set("Storage.Type", "YML", yamlConfiguration); + Config.set("Storage.Type", "SQLITE", yamlConfiguration); Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration); Config.set("Storage.MySQL.Port", 3306, yamlConfiguration); Config.set("Storage.MySQL.Database", "database", 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 659ad25..e724c8e 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 @@ -4,6 +4,7 @@ import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.MySQL; +import de.jatitv.commandguiv2.Spigot.system.database.StorageType; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; @@ -29,7 +30,7 @@ public class SelectConfig { public static String Currency; public static List mainCommands; - public static String Storage; + public static StorageType Storage; public static Boolean Bungee; public static String thisServer; @@ -139,7 +140,7 @@ public class SelectConfig { Currency = yamlConfiguration.getString("Plugin.Currency"); DefaultGUI = yamlConfiguration.getString("Plugin.DefaultGUI"); - Storage = yamlConfiguration.getString("Storage.Type").toUpperCase(); + Storage = StorageType.valueOf(yamlConfiguration.getString("Storage.Type").toUpperCase()); MySQL.ip = yamlConfiguration.getString("Storage.MySQL.IP"); MySQL.port = yamlConfiguration.getInt("Storage.MySQL.Port"); 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 b7d444d..96f3979 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 @@ -26,7 +26,7 @@ public class OpenGUI { private static Plugin plugin = Main.plugin; private static String prefix = Util.getPrefix(); - public static void openGUI(Player player, String guiString) { + public static void openGUI(Player player, String guiString, Boolean sound) { Gui gui = Main.guiHashMap.get(guiString); Long long_ = Long.valueOf(System.currentTimeMillis()); switch (guiString) { @@ -76,7 +76,9 @@ public class OpenGUI { } for (Slot slot : gui.slots) { Function function = Main.functionHashMap.get(slot.function); - if (slot.permission || !player.hasPermission(slot.permissionToSee)) continue; + if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue; + if (slot.slot < 0 || slot.slot > gui.GUI_Lines * 9) continue; + if (slot.enable) { if (function.empty) { ItemStack air = new ItemStack(Material.AIR); @@ -121,8 +123,10 @@ public class OpenGUI { } } - if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { - player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); + if (sound) { + if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) { + player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1); + } } player.openInventory(inventory); send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); 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 1846917..39a5873 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 @@ -17,6 +17,9 @@ import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.objects.Obj_Select; import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.system.database.SQLITE; +import de.jatitv.commandguiv2.Spigot.system.database.StorageType; +import de.jatitv.commandguiv2.Spigot.system.database.YML; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; @@ -26,6 +29,7 @@ import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import java.io.*; +import java.sql.SQLException; import java.util.List; public class Load { @@ -108,7 +112,8 @@ public class Load { } send.console(prefix + " §8-------------------------------"); - if (SelectConfig.Storage.equals("MYSQL")) { + switch (SelectConfig.Storage) { + case MYSQL: MySQL.main(); send.console(prefix + " §2Storage medium §6MySQL §2is used."); try { @@ -126,9 +131,26 @@ public class Load { } catch (Exception e) { e.printStackTrace(); } - - } else { + break; + case YML: send.console(prefix + " §2Storage medium §6YML §2is used."); + break; + default: + case SQLITE: + try { + SQLITE.main(); + send.console(prefix + " §2Storage medium §6SQLITE §2is used."); + SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + + "UUID TEXT NOT NULL," + + "Name TEXT NOT NULL," + + "Status INTEGER NOT NULL DEFAULT 1," + + "Slot INTEGER," + + "PRIMARY KEY(UUID)" + + ");"); + } catch (SQLException e) { + e.printStackTrace(); + } + break; } if (Main.PaPi) { send.console(prefix + " §2PlaceholderAPI successfully connected!"); 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 f6f62c3..b66b828 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 @@ -35,7 +35,6 @@ public class Metrics { int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin! Metrics metrics = new Metrics(Main.plugin, pluginId); metrics.addCustomChart(new Metrics.SimplePie("updatecheckonjoin", () -> String.valueOf(SelectConfig.UpdateCheckOnJoin))); - metrics.addCustomChart(new Metrics.SimplePie("storage_type_mysql", () -> SelectConfig.Storage)); } private final Plugin plugin; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java new file mode 100644 index 0000000..1564893 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java @@ -0,0 +1,135 @@ +package de.jatitv.commandguiv2.Spigot.system.database; + +import de.jatitv.commandguiv2.Spigot.Main; +import de.jatitv.commandguiv2.Util; +import net.t2code.lib.Spigot.Lib.messages.send; +import org.bukkit.Bukkit; + +import java.io.File; +import java.sql.*; +import java.util.ArrayList; +import java.util.HashMap; + +public class SQLITE { + protected static String url; + private static Connection con; + + public static void main() throws SQLException { + long long_ = System.currentTimeMillis(); + File directory = new File(Main.getPath() + "/Storage"); + if (!directory.exists()) { + directory.mkdir(); + } + url = "jdbc:sqlite:" + Main.plugin.getDataFolder() + "/Storage/data.db"; + con = DriverManager.getConnection(url); + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Datenbank erfolgreich verbunden." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + DatabaseMetaData dbmd = con.getMetaData(); + } + + public static void query(String query) { + + send.debug(Main.plugin, query); + try { + Statement stmt = con.createStatement(); + stmt.execute(query); + stmt.close(); + } catch (SQLException e) { + System.err.println(e.getMessage()); + } + } + + public static void query(ArrayList queryList) { + try { + Statement stmt = con.createStatement(); + for (String query : queryList) { + send.debug(Main.plugin, query); + stmt.addBatch(query); + } + stmt.executeBatch(); + stmt.close(); + } catch (SQLException e) { + System.err.println(e.getMessage()); + } + } + + + public static HashMap> selectAll(String query) { + send.debug(Main.plugin, query); + HashMap> Result = new HashMap<>(); + try { + Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery(query); + int columns = rs.getMetaData().getColumnCount(); + while (rs.next()) { + ArrayList columnList = new ArrayList<>(); + for (int i = 1; i <= columns; i++) { + columnList.add(rs.getString(i)); + } + Result.put(rs.getString(1), columnList); + } + rs.close(); + stmt.close(); + } catch (SQLException ex) { + System.err.println(ex.getMessage()); + } + return Result; + } + + public static String select(String query) { + send.debug(Main.plugin, query); + String Ausgabe = ""; + try { + Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery(query); + while (rs.next()) { + Ausgabe = String.valueOf(rs.getString(1)); + } + rs.close(); + stmt.close(); + } catch (SQLException ex) { + System.err.println(ex.getMessage()); + } + return Ausgabe; + } + + public static int count(String query) { + send.debug(Main.plugin, query); + int count = 0; + try { + Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery(query); + while (rs.next()) { + count++; + } + rs.close(); + stmt.close(); + } catch (SQLException ex) { + System.err.println(ex.getMessage()); + } + return count; + } + + public static ArrayList selectRow(String query) { + send.debug(Main.plugin, query); + ArrayList Result = new ArrayList<>(); + try { + Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery(query); + int columns = rs.getMetaData().getColumnCount(); + while (rs.next()) { + for (int i = 1; i <= columns; i++) { + Result.add(rs.getString(i)); + } + } + rs.close(); + stmt.close(); + } catch (SQLException ex) { + System.err.println(ex.getMessage()); + } + return Result; + } + + public static void close() throws SQLException { + if (con != null) con.close(); + } +} 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 8b838a7..aee094a 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 @@ -7,65 +7,112 @@ import org.bukkit.entity.Player; public class Select_Database { public static void nameCheck(Player player) { - if (SelectConfig.Storage.equals("MYSQL")) { - MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); - } + switch (SelectConfig.Storage){ + case MYSQL: + MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); + break; + case YML: + + break; + case SQLITE: + default: + SQLITE.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); + break; } + +} + public static void setSlot(Player player, Integer slot) { - if (SelectConfig.Storage.equals("MYSQL")) { - MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() - + "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';"); - } else { - YML.setGuiitemSlot(player, slot); + switch (SelectConfig.Storage) { + case MYSQL: + MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + + "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';"); + break; + case YML: + YML.setGuiitemSlot(player, slot); + break; + case SQLITE: + default: + SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + + "','" + slot + "') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';"); + break; } } public static void setItemStatusTrue(Player player) { Events.useItemHashMap.replace(player, true); - if (SelectConfig.Storage.equals("MYSQL")) { - MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() - + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';"); - } else { - YML.setGuiitemOn(player); + switch (SelectConfig.Storage) { + case MYSQL: + MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';"); + break; + case YML: + YML.setGuiitemOn(player); + break; + case SQLITE: + default: + SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + + "') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '1';"); + break; } } public static void setItemStatusFalse(Player player) { Events.useItemHashMap.replace(player, false); - if (SelectConfig.Storage.equals("MYSQL")) { - - MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() - + "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';"); - } else { - YML.setGuiitemOff(player); + switch (SelectConfig.Storage) { + case MYSQL: + MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + + "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';"); + break; + case YML: + YML.setGuiitemOff(player); + break; + case SQLITE: + default: + SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + + "', '0') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '0';"); + break; } } public static Boolean selectItemStatus(Player player) { - if (SelectConfig.Storage.equals("MYSQL")) { - if (MySQL.count("SELECT * FROM `gui-item` WHERE BINARY UUID='" + player.getUniqueId() + "'") > 0) { - if (MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';").equals("1")) { + switch (SelectConfig.Storage) { + case MYSQL: + String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); + if(result == null || result.equals("")){ return true; - } else return false; - } else { - return true; - } - } else { - return YML.selectGuiitemOn(player); + } + return result.equals("1"); + case YML: + return YML.selectGuiitemOn(player); + case SQLITE: + default: + String result2 = SQLITE.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); + if(result2 == null || result2.equals("")){ + return true; + } + return result2.equals("1"); } } public static Integer selectSlot(Player player) { - if (SelectConfig.Storage.equals("MYSQL")) { - if (MySQL.count("SELECT * FROM `gui-item` WHERE BINARY UUID='" + player.getUniqueId() + "'") > 0) { - if (MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';") != "null") { - return Integer.valueOf(MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';")); - } else return null; - } else return null; - - } else { - return YML.selectSlot(player); + switch (SelectConfig.Storage) { + case MYSQL: + String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); + if(result == null || result.equals("")|| result.equals("null")){ + return null; + } + return Integer.parseInt(result); + case YML: + return YML.selectSlot(player); + case SQLITE: + default: + String result2 = SQLITE.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); + if(result2 == null || result2.equals("") || result2.equals("null")){ + return null; + } + return Integer.parseInt(result2); } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/StorageType.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/StorageType.java new file mode 100644 index 0000000..ee77759 --- /dev/null +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/StorageType.java @@ -0,0 +1,7 @@ +package de.jatitv.commandguiv2.Spigot.system.database; + +public enum StorageType { + MYSQL, + SQLITE, + YML +} -- 2.34.1 From cfd07b01f2a7f2d001be75ab4074b7583dec29f3 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 21 Apr 2022 01:58:54 +0200 Subject: [PATCH 12/16] 2.7.0_Snapshot-6 | Fix Fixes: - If there was a function in the GUI that did not exist, then an error occurred in the console and the GUI could not be opened, this was fixed. - If you changed the slot of the UseItem, the Protection (RemoveItemWhenItIsDisabled) was ignored and you got the item. --- CommandGUI V2/pom.xml | 2 +- .../{GUI_Listener.java => GUIListener.java} | 16 ++- .../Spigot/Listener/ItemChange.java | 55 +-------- .../Spigot/Listener/PluginEvent.java | 4 +- .../Listener/UseItem_Listener/Events.java | 51 ++++----- ...vents_from1_10.java => EventsFrom110.java} | 2 +- .../Spigot/cmdManagement/Commands.java | 83 +++++--------- .../Spigot/cmdManagement/Help.java | 6 +- .../cmdManagement/register/AliasRegister.java | 2 +- .../register/RegisterCommand.java | 7 +- .../Spigot/config/config/SelectConfig.java | 8 +- .../commandguiv2/Spigot/gui/GuiBuilder.java | 6 +- .../commandguiv2/Spigot/gui/OpenGUI.java | 28 +++-- .../Spigot/objects/Obj_Select.java | 44 ++++---- .../Spigot/objects/functions/Function.java | 6 +- .../commandguiv2/Spigot/objects/guis/Gui.java | 36 +++--- .../commandguiv2/Spigot/system/Load.java | 104 ++++++++++-------- .../commandguiv2/Spigot/system/Metrics.java | 9 ++ .../Spigot/system/RegisterPermissions.java | 7 +- .../{Give_UseItem.java => UseItem.java} | 64 +++++++++-- .../Spigot/system/database/MySQL.java | 4 +- .../Spigot/system/database/SQLITE.java | 2 +- ...lect_Database.java => SelectDatabase.java} | 24 ++-- .../de/jatitv/commandguiv2/api/CGuiAPI.java | 8 +- 24 files changed, 294 insertions(+), 284 deletions(-) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/{GUI_Listener.java => GUIListener.java} (95%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/{Events_from1_10.java => EventsFrom110.java} (97%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/{Give_UseItem.java => UseItem.java} (58%) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/{Select_Database.java => SelectDatabase.java} (92%) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 79fda5a..4f53991 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.7.0_Snapshot-5 + 2.7.0_Snapshot-6 jar CommandGUI 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/GUIListener.java similarity index 95% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java index 5b8d602..67fb9ae 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/GUIListener.java @@ -30,9 +30,8 @@ import org.bukkit.scheduler.BukkitRunnable; import java.io.File; import java.io.IOException; -import java.util.Objects; -public class GUI_Listener implements Listener { +public class GUIListener implements Listener { private static String prefix = Util.getPrefix(); public static String GUICode; @@ -45,8 +44,8 @@ public class GUI_Listener implements Listener { if (e.getInventory() == null) return; if (e.getCurrentItem() == null) return; for (Gui gui : Main.guiHashMap.values()) { - if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name)) - || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) { + if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.guiName)) + || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.guiName)))) { e.setCancelled(true); for (Slot slot : gui.slots) { Function function = Main.functionHashMap.get(slot.function); @@ -60,7 +59,6 @@ public class GUI_Listener implements Listener { continue; } if (!slot.enable) continue; - send.debugmsg(Main.plugin, function.name); if (function.cost_Enable) { if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) { @@ -233,7 +231,7 @@ public class GUI_Listener implements Listener { player.playSound(player.getLocation(), Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1); } catch (Exception e1) { send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) - .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound)); + .replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.guiName) + "§r §6Slot: §e" + slot.slot + " §6CustomSound: §9" + function.customSound_Sound)); player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); } } @@ -247,7 +245,7 @@ public class GUI_Listener implements Listener { @Override public void run() { player.closeInventory(); - OpenGUI.openGUI(player, gui.Command_Command, false); + OpenGUI.openGUI(player, gui.key, false); } }.runTaskLater(plugin, 4L); } else @@ -256,7 +254,7 @@ public class GUI_Listener implements Listener { @Override public void run() { player.closeInventory(); - OpenGUI.openGUI(player, gui.Command_Command, false); + OpenGUI.openGUI(player, gui.key, false); } }.runTaskLater(plugin, 4L); } @@ -271,7 +269,7 @@ public class GUI_Listener implements Listener { @Override public void run() { player.closeInventory(); - OpenGUI.openGUI(player, gui.Command_Command, false); + OpenGUI.openGUI(player, gui.key, false); } }.runTaskLater(plugin, 2L); } 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 9f7f751..1b9e68f 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,14 +2,10 @@ package de.jatitv.commandguiv2.Spigot.Listener; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; -import de.jatitv.commandguiv2.Spigot.system.Give_UseItem; +import de.jatitv.commandguiv2.Spigot.system.UseItem; 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; import org.bukkit.scheduler.BukkitRunnable; public class ItemChange { @@ -28,37 +24,15 @@ public class ItemChange { if (!SelectConfig.UseItem_Enable) { return; } - if (SelectConfig.UseItemGameModeProtection) { - if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { - if (SelectConfig.UseItemGameModeRemoveItemWhenItIsDisabled) removeItem(player); - send.debug(Main.plugin,"GameMode disabled: " +player.getName() +" " +player.getGameMode().toString()); - return; - } - if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { - if (SelectConfig.UseItemGameModeRemoveItemWhenItIsDisabled) removeItem(player); - send.debug(Main.plugin,"GameMode disabled: " +player.getName() +" " +player.getGameMode().toString()); - return; - } - } - if (SelectConfig.UseItemWorldProtection) { - if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { - if (SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled)removeItem(player); - send.debug(Main.plugin,"World disabled: " +player.getName() +" " +player.getWorld().toString()); - return; - } - if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { - if (SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled)removeItem(player); - send.debug(Main.plugin,"World disabled: " +player.getName() +" " +player.getWorld().toString()); - return; - } - } + UseItem.removeItem(player); + if (UseItem.protection(player, false)) return; if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) { if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) { if (!player.hasPlayedBefore()) { new BukkitRunnable() { @Override public void run() { - Give_UseItem.onGive(player); + UseItem.giveUseItem(player); if (setCursor) { setCursor(player, slot); } @@ -79,11 +53,10 @@ public class ItemChange { new BukkitRunnable() { @Override public void run() { - removeItem(player); if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) { if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) { send.debug(Main.plugin,"Give: " +player.getName()); - Give_UseItem.onGive(player); + UseItem.giveUseItem(player); if (setCursor) { setCursor(player, slot); } @@ -96,7 +69,7 @@ public class ItemChange { } } if (empty) { - Give_UseItem.onGiveADD(player); + UseItem.addUseItem(player); } } } @@ -140,20 +113,4 @@ public class ItemChange { 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 ee662f0..9e3dae0 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 @@ -4,7 +4,7 @@ package de.jatitv.commandguiv2.Spigot.Listener; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; -import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.Bukkit; @@ -22,7 +22,7 @@ public class PluginEvent implements Listener { @EventHandler public void onJoinEvent(PlayerLoginEvent event) { Player player = event.getPlayer(); - Select_Database.nameCheck(player); + SelectDatabase.nameCheck(player); UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord()); } 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 8a9cb3f..a76c60b 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 @@ -6,7 +6,8 @@ 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.Spigot.system.database.Select_Database; +import de.jatitv.commandguiv2.Spigot.system.UseItem; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.api.CGuiAPI; import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.messages.send; @@ -37,11 +38,11 @@ public class Events implements Listener { public static HashMap useItemSlotHashMap = new HashMap<>(); @EventHandler public void onJoin(PlayerJoinEvent e) { - if (Select_Database.selectItemStatus(e.getPlayer())){ + if (SelectDatabase.selectItemStatus(e.getPlayer())){ useItemHashMap.put(e.getPlayer(), true); } else useItemHashMap.put(e.getPlayer(), false); - useItemSlotHashMap.put(e.getPlayer(),Select_Database.selectSlot(e.getPlayer())); + useItemSlotHashMap.put(e.getPlayer(), SelectDatabase.selectSlot(e.getPlayer())); if (CGuiAPI.JoinDisable) { send.debug(Main.plugin,"JoinDisable"); @@ -66,18 +67,7 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onDeathDrop(PlayerDeathEvent e) { Player player = e.getEntity().getPlayer(); - 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; - } - } - } - } + UseItem.removeItem(player); if (!e.getDrops().isEmpty()) { Iterator var3 = (new ArrayList(e.getDrops())).iterator(); while (var3.hasNext()) { @@ -166,44 +156,45 @@ public class Events implements Listener { } } - private static void openGUI(PlayerInteractEvent e, Player p) { + private static void openGUI(PlayerInteractEvent e, Player player) { e.setCancelled(true); - if (p.isSneaking()) { - Commands.info(p); + if (player.isSneaking()) { + Commands.info(player); return; } if (!legacy()) { - if (!topInventoryIsEmpty(p)) return; + if (!topInventoryIsEmpty(player)) return; } + if (UseItem.protection(player, true)) return; if (SelectConfig.UseItemGameModeProtection) { - if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(p.getGameMode().toString())) { + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { e.setCancelled(true); - send.player(p, SelectMessages.UseItemDisabledInGameMode); + send.player(player, SelectMessages.UseItemDisabledInGameMode); return; } - if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(p.getGameMode().toString())) { + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { e.setCancelled(true); - send.player(p, SelectMessages.UseItemDisabledInGameMode); + send.player(player, SelectMessages.UseItemDisabledInGameMode); return; } } if (SelectConfig.UseItemWorldProtection) { - if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(p.getWorld().getName())) { + if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { e.setCancelled(true); - send.player(p, SelectMessages.UseItemDisabledInWorld); + send.player(player, SelectMessages.UseItemDisabledInWorld); return; } - if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(p.getWorld().getName())) { + if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { e.setCancelled(true); - send.player(p, SelectMessages.UseItemDisabledInWorld); + send.player(player, SelectMessages.UseItemDisabledInWorld); return; } } - if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) { - OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI, true); + if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) { + OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true); } else { - p.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") + player.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") .replace("[gui]", SelectConfig.UseItem_OpenGUI)); } } 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/EventsFrom110.java similarity index 97% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/Events_from1_10.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/UseItem_Listener/EventsFrom110.java index 313609d..f853b76 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/EventsFrom110.java @@ -8,7 +8,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.*; -public class Events_from1_10 implements Listener { +public class EventsFrom110 implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onHandSwap(PlayerSwapHandItemsEvent e) { 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 3ff09a8..ce24e27 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,13 +6,13 @@ import de.jatitv.commandguiv2.Spigot.objects.Obj_Select; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; 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.UseItem; 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.RegisterPermissions; -import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.messages.send; @@ -23,6 +23,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.Objects; + public class Commands { public static void info(CommandSender sender) { if (sender instanceof Player) { @@ -65,8 +67,12 @@ public class Commands { CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); ConfigCreate.configCreate(); SelectConfig.onSelect(); - Main.plugin.reloadConfig(); + Main.plugin.reloadConfig(); + if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) { + if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!"); + send.console("You have changed the storage medium! To apply this change, you must restart the server!"); + } LanguagesCreate.langCreate(); Obj_Select.onSelect(); @@ -97,7 +103,7 @@ public class Commands { public static void give(CommandSender sender, Player target) { if (Bukkit.getPlayer(target.getName()) != null) { - Give_UseItem.onGive(target); + UseItem.giveUseItem(target); send.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.UseItem_Name)); send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.UseItem_Name)); if (SelectConfig.Sound_Give_Enable && SelectConfig.Sound_Enable) { @@ -113,18 +119,7 @@ public class Commands { } public static void itemOn(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; - } - } - } - } + UseItem.removeItem(player); Integer slot = null; if (SelectConfig.UseItem_InventorySlotEnforce) { slot = SelectConfig.UseItem_InventorySlot; @@ -137,8 +132,8 @@ public class Commands { } send.debug(Main.plugin, String.valueOf(slot)); if (player.getInventory().getItem(slot - 1) == null) { - Select_Database.setItemStatusTrue(player); - Give_UseItem.onGive(player); + SelectDatabase.setItemStatusTrue(player); + UseItem.giveUseItem(player); } else { boolean empty = false; for (int i = 0; i < 9; i++) { @@ -148,8 +143,8 @@ public class Commands { } } if (empty) { - Select_Database.setItemStatusTrue(player); - Give_UseItem.onGiveADD(player); + SelectDatabase.setItemStatusTrue(player); + UseItem.addUseItem(player); send.player(player, SelectMessages.ItemON); } else { player.sendMessage(SelectMessages.NoInventorySpace); @@ -161,19 +156,8 @@ public class Commands { } public static void itemOff(Player player) { - Select_Database.setItemStatusFalse(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(); - send.player(player, SelectMessages.ItemOFF); - } - } - } - } + SelectDatabase.setItemStatusFalse(player); + UseItem.removeItem(player); } public static void onSetSlot(Player player, Integer setSlot) { @@ -199,22 +183,11 @@ public class Commands { send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString())); 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; - } - } - } - } - Select_Database.setSlot(player, setSlot); - Events.useItemSlotHashMap.replace(player,setSlot); + UseItem.removeItem(player); + SelectDatabase.setSlot(player, setSlot); + Events.useItemSlotHashMap.replace(player, setSlot); if (Events.useItemHashMap.get(player)) { - Give_UseItem.onGive(player); + UseItem.giveUseItem(player); } send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString())); } else player.sendMessage(Util.getPrefix() + " §4Function disabled"); @@ -223,24 +196,24 @@ public class Commands { public static void gui(Player player) { if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) { Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); - if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { - if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { + if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { + if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, SelectConfig.DefaultGUI, true); } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui") .replace("[perm]", "commandgui.command")); - } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name)); + } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName)); } } public static void gui(Player player, String arg) { if (Main.guiHashMap.containsKey(arg)) { Gui gui = Main.guiHashMap.get(arg); - if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { - if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) { + if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { + if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, arg, true); - } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.Command_Command) + } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key) .replace("[perm]", "commandgui.command." + arg.toLowerCase())); - } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.Command_Command)); + } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.key)); } else player.sendMessage(SelectMessages.GUInotFound); } } 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 e89c908..e461801 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 @@ -15,10 +15,10 @@ public class Help { send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----"); if (sender.hasPermission("commandgui.command")) { Gui gui = Main.guiHashMap.get(SelectConfig.DefaultGUI); - send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.GUI_Name))); + send.sender(sender, Prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix,gui.guiName))); for (String alias : Main.allAliases) { - if (Main.guiHashMap.get(alias).GUI_Enable || sender.hasPermission("commandgui.bypass")) { - send.sender(sender, Prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix,Main.guiHashMap.get(alias).GUI_Name))); + if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) { + send.sender(sender, Prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix,Main.guiHashMap.get(alias).guiName))); } } send.sender(sender, Prefix + " " + SelectMessages.HelpHelp); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java index 03058fd..3c90792 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/cmdManagement/register/AliasRegister.java @@ -23,7 +23,7 @@ public class AliasRegister { } for (String alias : Main.allAliases) { if (Main.guiHashMap.get(alias) != null) { - if (Main.guiHashMap.get(alias).Command_Alias_Enable) { + if (Main.guiHashMap.get(alias).commandAliasEnable) { try { final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); 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 e9f36de..28d6bb5 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,7 +4,6 @@ package de.jatitv.commandguiv2.Spigot.cmdManagement.register; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.gui.OpenGUI; -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; @@ -24,12 +23,12 @@ public class RegisterCommand extends Command { if (sender instanceof Player) { Player player = (Player) sender; Gui gui = Main.guiHashMap.get(alias); - if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { - if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { + if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { + if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { OpenGUI.openGUI(player, alias, true); } else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias) .replace("[perm]", "commandgui.command." + alias)); - } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name)); + } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName)); } else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!"); return true; } 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 e724c8e..5fe88fc 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 @@ -4,6 +4,7 @@ import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Spigot.system.database.MySQL; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Spigot.system.database.StorageType; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.messages.send; @@ -30,7 +31,8 @@ public class SelectConfig { public static String Currency; public static List mainCommands; - public static StorageType Storage; + public static String storage; + public static Boolean Bungee; public static String thisServer; @@ -129,7 +131,6 @@ public class SelectConfig { } } - if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) { DisableUpdateChecker = false; } else DisableUpdateChecker = yamlConfiguration.getBoolean("Plugin.DisableUpdateChecker"); @@ -139,8 +140,7 @@ public class SelectConfig { language = yamlConfiguration.getString("Plugin.language"); Currency = yamlConfiguration.getString("Plugin.Currency"); DefaultGUI = yamlConfiguration.getString("Plugin.DefaultGUI"); - - Storage = StorageType.valueOf(yamlConfiguration.getString("Storage.Type").toUpperCase()); + storage = yamlConfiguration.getString("Storage.Type").toUpperCase(); MySQL.ip = yamlConfiguration.getString("Storage.MySQL.IP"); MySQL.port = yamlConfiguration.getInt("Storage.MySQL.Port"); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java index 4886a33..419cc36 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/gui/GuiBuilder.java @@ -109,13 +109,13 @@ public class GuiBuilder { public static void fillItem(Inventory inventory, Gui gui) { ItemStack glass; if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item)); - } else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_"))); + glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.guiFillItemItem)); + } else glass = new ItemStack(Material.valueOf(gui.guiFillItemItem.toUpperCase().replace(".", "_"))); ItemMeta itemMetaglass = glass.getItemMeta(); itemMetaglass.setDisplayName(" "); glass.setItemMeta(itemMetaglass); glass.setAmount(1); - for (int i = 0; i < 9 * gui.GUI_Lines; i++) { + for (int i = 0; i < 9 * gui.guiLines; i++) { inventory.setItem(i, glass); } } 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 96f3979..771338b 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 @@ -1,6 +1,6 @@ package de.jatitv.commandguiv2.Spigot.gui; -import de.jatitv.commandguiv2.Spigot.Listener.GUI_Listener; +import de.jatitv.commandguiv2.Spigot.Listener.GUIListener; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.objects.functions.Function; @@ -63,21 +63,25 @@ public class OpenGUI { } if (MCVersion.minecraft1_13) { - GUI_Listener.GUICode = ""; - } else GUI_Listener.GUICode = "§6§8§9§r"; - if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) { + GUIListener.GUICode = ""; + } else GUIListener.GUICode = "§6§8§9§r"; + if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { Inventory inventory; if (Main.PaPi) { - inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name))); - } else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name))); + inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, player, GUIListener.GUICode + gui.guiName))); + } else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, GUIListener.GUICode + gui.guiName))); - if (gui.GUI_FillItem_Enable) { + if (gui.guiFillItemEnable) { GuiBuilder.fillItem(inventory, gui); } for (Slot slot : gui.slots) { Function function = Main.functionHashMap.get(slot.function); + if (function == null) { + send.error(Main.plugin, "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!"); + continue; + } if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue; - if (slot.slot < 0 || slot.slot > gui.GUI_Lines * 9) continue; + if (slot.slot < 0 || slot.slot > gui.guiLines * 9) continue; if (slot.enable) { if (function.empty) { @@ -100,9 +104,9 @@ public class OpenGUI { if (function.playerHead_Enable) { if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { send.player(player, prefix + "§c Playerheads are only available from version §61.13§c! §7- §bGUI: §6" + - Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name)); + Replace.replace(prefix, gui.guiName).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name)); send.error(plugin, "Playerheads are only available from version 1.13!"); - send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.GUI_Name).toString() + " §bSlot: §6" + + send.console(prefix + " §bGUI: §6" + Replace.replace(prefix, gui.guiName).toString() + " §bSlot: §6" + (slot.slot + 1) + " §7- " + Replace.replace(prefix, function.name)); } else { if (function.base64_Enable) { @@ -129,8 +133,8 @@ public class OpenGUI { } } player.openInventory(inventory); - send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); - } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name))); + send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.guiName))); } private static void toggleOn(Function function, Integer slot, Player player, Inventory inventory) { diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java index 6a5b70f..2c302b4 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/Obj_Select.java @@ -5,6 +5,7 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; +import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import org.bukkit.configuration.file.YamlConfiguration; @@ -16,8 +17,8 @@ import java.util.Objects; public class Obj_Select { public static void onSelect() { - onSelectGui(); onSelectFunction(); + onSelectGui(); } public static void onSelectGui() { @@ -29,9 +30,9 @@ public class Obj_Select { for (File config_gui : fileArray) { String sub = config_gui.getName().substring(config_gui.getName().length() - 4); if (sub.equals(".yml")) { - Main.allAliases.add(config_gui.getName().replace(".yml", "")); + String key = config_gui.getName().replace(".yml", ""); + Main.allAliases.add(key); YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config_gui); - String guiFileName = config_gui.getName().replace(".yml", ""); Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable"); Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines"); @@ -53,27 +54,31 @@ public class Obj_Select { Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required"); ArrayList slots = new ArrayList<>(); - for (String key : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) { - Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + key + ".Slot") - 1; - Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + key + ".Enable"); - String function = yamlConfiguration_gui.getString("Slots." + key + ".Function"); - Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + key + ".Permission.Required"); - String permSee = yamlConfiguration_gui.getString("Slots." + key + ".Permission.See"); - String permUse = yamlConfiguration_gui.getString("Slots." + key + ".Permission.Use"); + for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) { + 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"); + Function functionCheck = Main.functionHashMap.get(function); + if (functionCheck == null) { + send.error(Main.plugin, "The Function " + function + " in the GUI " + key + " does not exist!"); + } + Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required"); + String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See"); + String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use"); Slot slot = new Slot(slotNumber, enable, function, permRequired, - Objects.requireNonNull(permSee).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber + 1)) - .replace("[slotname]", key.toLowerCase()), - Objects.requireNonNull(permUse).replace("[function]", guiFileName).replace("[slot]", String.valueOf(slotNumber + 1)) - .replace("[slotname]", key.toLowerCase())); + Objects.requireNonNull(permSee).replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1)) + .replace("[slotname]", slotKey.toLowerCase()), + Objects.requireNonNull(permUse).replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1)) + .replace("[slotname]", slotKey.toLowerCase())); slots.add(slot); } Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, - config_gui.getName().replace(".yml", ""), commandAliasEnable, commandPermission, slots); + key, commandAliasEnable, commandPermission, slots); - Main.guiHashMap.put(guiFileName, gui); + Main.guiHashMap.put(key, gui); CmdExecuter_GUITab.arg1.put(config_gui.getName() - .replace(".yml", ""), "commandgui.gui." + config_gui.getName().replace(".yml", "")); + .replace(".yml", ""), "commandgui.gui." + key); try { yamlConfiguration_gui.save(config_gui); @@ -94,6 +99,7 @@ public class Obj_Select { if (sub.equals(".yml")) { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + String key = config.getName().replace(".yml", ""); Boolean empty = yamlConfiguration.getBoolean("Slots.Function.Item.Empty"); Integer itemAmount = yamlConfiguration.getInt("Slots.Function.Item.Amount"); Boolean playerHead_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Enable"); @@ -145,13 +151,13 @@ public class Obj_Select { String pluginReloadCommand = yamlConfiguration.getString("Slots.Function.SetConfig.PluginReload.Command"); - Function function = new Function(empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore, + Function function = new Function(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore, customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, price, command_Enable, command_BungeeCommand, commandAsConsole, command, serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, message, setConfigEnable, configFilePath, configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft, configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, configListValueRight, pluginReloadEnable, pluginReloadCommand); - Main.functionHashMap.put(config.getName().replace(".yml", ""), function); + Main.functionHashMap.put(key, function); try { yamlConfiguration.save(config); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java index 5801910..54b8ec9 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/functions/Function.java @@ -4,6 +4,7 @@ import java.util.List; public class Function { + public String key; public Boolean empty; public Integer itemAmount; public Boolean playerHead_Enable; @@ -54,7 +55,8 @@ public class Function { public Boolean pluginReloadEnable; public String pluginReloadCommand; - public Function(Boolean empty, + public Function(String key, + Boolean empty, Integer itemAmount, Boolean playerHead_Enable, Boolean base64Value_Enable, @@ -101,6 +103,7 @@ public class Function { Boolean pluginReloadEnable, String pluginReloadCommand) { + this.key = key; this.empty = empty; this.itemAmount = itemAmount; this.playerHead_Enable = playerHead_Enable; @@ -152,6 +155,5 @@ public class Function { this.pluginReloadCommand = pluginReloadCommand; - } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java index b2369fc..a3ddaaa 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/objects/guis/Gui.java @@ -5,28 +5,28 @@ import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import java.util.ArrayList; public class Gui { - public Boolean GUI_Enable; - public Integer GUI_Lines; - public String GUI_Name; - public Boolean GUI_FillItem_Enable; - public String GUI_FillItem_Item; + public Boolean guiEnable; + public Integer guiLines; + public String guiName; + public Boolean guiFillItemEnable; + public String guiFillItemItem; - public String Command_Command; - public Boolean Command_Alias_Enable; - public Boolean Command_Permission_Enable; + public String key; + public Boolean commandAliasEnable; + public Boolean commandPermissionEnable; public ArrayList slots; - public Gui(Boolean GUI_Enable, Integer GUI_Lines, String GUI_Name, Boolean GUI_FillItem_Enable, String GUI_FillItem_Item, - String Command_Command, Boolean Command_Alias_Enable, Boolean Command_Permission_Enable, ArrayList slots){ - this.GUI_Enable = GUI_Enable; - this.GUI_Lines = GUI_Lines; - this.GUI_Name = GUI_Name; - this.GUI_FillItem_Enable = GUI_FillItem_Enable; - this.GUI_FillItem_Item = GUI_FillItem_Item; - this.Command_Command = Command_Command; - this.Command_Alias_Enable = Command_Alias_Enable; - this.Command_Permission_Enable = Command_Permission_Enable; + public Gui(Boolean guiEnable, Integer guiLines, String guiName, Boolean guiFillitemEnable, String guiFillitemItem, + String commandCommand, Boolean commandAliasEnable, Boolean commandPermissionEnable, ArrayList slots){ + this.guiEnable = guiEnable; + this.guiLines = guiLines; + this.guiName = guiName; + this.guiFillItemEnable = guiFillitemEnable; + this.guiFillItemItem = guiFillitemItem; + this.key = commandCommand; + this.commandAliasEnable = commandAliasEnable; + this.commandPermissionEnable = commandPermissionEnable; this.slots = slots; } } 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 39a5873..1d0837a 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 @@ -1,7 +1,7 @@ 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.Listener.GUIListener; +import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.EventsFrom110; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help; @@ -18,8 +18,8 @@ import de.jatitv.commandguiv2.Spigot.objects.Obj_Select; import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.system.database.SQLITE; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Spigot.system.database.StorageType; -import de.jatitv.commandguiv2.Spigot.system.database.YML; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; @@ -112,46 +112,9 @@ public class Load { } send.console(prefix + " §8-------------------------------"); - switch (SelectConfig.Storage) { - case MYSQL: - MySQL.main(); - send.console(prefix + " §2Storage medium §6MySQL §2is used."); - try { - MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + - " `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," + - " `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," + - " `Status` INT(1) NOT NULL DEFAULT '1'," + - " `Slot` INT(1) NULL DEFAULT NULL," + - " UNIQUE INDEX `UUID` (`UUID`)" + - ")" + - "COLLATE='utf8mb4_general_ci'" + - "ENGINE=InnoDB" + - ";"); - MySQL.query("ALTER TABLE `gui-item` ADD COLUMN IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;"); - } catch (Exception e) { - e.printStackTrace(); - } - break; - case YML: - send.console(prefix + " §2Storage medium §6YML §2is used."); - break; - default: - case SQLITE: - try { - SQLITE.main(); - send.console(prefix + " §2Storage medium §6SQLITE §2is used."); - SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + - "UUID TEXT NOT NULL," + - "Name TEXT NOT NULL," + - "Status INTEGER NOT NULL DEFAULT 1," + - "Slot INTEGER," + - "PRIMARY KEY(UUID)" + - ");"); - } catch (SQLException e) { - e.printStackTrace(); - } - break; - } + loadStorage(prefix); + send.console(prefix + " §8-------------------------------"); + if (Main.PaPi) { send.console(prefix + " §2PlaceholderAPI successfully connected!"); } else { @@ -179,13 +142,13 @@ public class Load { e.printStackTrace(); } - Bukkit.getServer().getPluginManager().registerEvents(new GUI_Listener(), plugin); + Bukkit.getServer().getPluginManager().registerEvents(new GUIListener(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new PluginEvent(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new Events(), Main.plugin); if (!MCVersion.minecraft1_8 && !MCVersion.minecraft1_9) { - Bukkit.getServer().getPluginManager().registerEvents(new Events_from1_10(), plugin); + Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin); } UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord); @@ -193,4 +156,55 @@ public class Load { Main.addonLoad(); T2CodeTemplate.onLoadFooter(prefix, long_); } + + private static void loadStorage(String prefix) { + try { + SelectDatabase.setStorage(StorageType.valueOf(SelectConfig.storage)); + } catch (Exception ignored) { + send.error(Main.plugin, "The storage medium " + SelectConfig.storage + " is not supported!"); + send.error(Main.plugin, "Storage medium " + StorageType.SQLITE + " is used."); + SelectDatabase.setStorage(StorageType.SQLITE); + } + + switch (SelectDatabase.getStorage()) { + case MYSQL: + send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used."); + MySQL.main(); + try { + MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + + " `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," + + " `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," + + " `Status` INT(1) NOT NULL DEFAULT '1'," + + " `Slot` INT(1) NULL DEFAULT NULL," + + " UNIQUE INDEX `UUID` (`UUID`)" + + ")" + + "COLLATE='utf8mb4_general_ci'" + + "ENGINE=InnoDB" + + ";"); + MySQL.query("ALTER TABLE `gui-item` ADD COLUMN IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;"); + } catch (Exception e) { + e.printStackTrace(); + } + break; + case YML: + send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used."); + break; + default: + case SQLITE: + send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used."); + try { + SQLITE.main(); + SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" + + "UUID TEXT NOT NULL," + + "Name TEXT NOT NULL," + + "Status INTEGER NOT NULL DEFAULT 1," + + "Slot INTEGER," + + "PRIMARY KEY(UUID)" + + ");"); + } catch (SQLException e) { + e.printStackTrace(); + } + break; + } + } } 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 b66b828..7929618 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 @@ -5,6 +5,8 @@ package de.jatitv.commandguiv2.Spigot.system; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; +import de.jatitv.commandguiv2.Spigot.system.database.StorageType; import de.jatitv.commandguiv2.Util; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -35,6 +37,13 @@ public class Metrics { int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin! Metrics metrics = new Metrics(Main.plugin, pluginId); metrics.addCustomChart(new Metrics.SimplePie("updatecheckonjoin", () -> String.valueOf(SelectConfig.UpdateCheckOnJoin))); + metrics.addCustomChart(new DrilldownPie("storage_type_mysql", () -> { + Map> map = new HashMap<>(); + String storage = SelectDatabase.getStorage().toString(); + Map entry = new HashMap<>(); + entry.put(storage, 1); map.put(storage, entry); + return map; + })); } private final Plugin plugin; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java index 57e4fd1..a67fd41 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java @@ -2,11 +2,8 @@ package de.jatitv.commandguiv2.Spigot.system; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; -import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import net.t2code.lib.Spigot.Lib.register.Register; -import org.bukkit.Bukkit; -import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.Plugin; @@ -67,8 +64,8 @@ public class RegisterPermissions { for (Gui gui : Main.guiHashMap.values()) { - Register.permission("commandgui.command." + gui.Command_Command, op, plugin); - Register.permission(admin, op, "commandgui.command." + gui.Command_Command, true, plugin); + Register.permission("commandgui.command." + gui.key, op, plugin); + Register.permission(admin, op, "commandgui.command." + gui.key, true, plugin); for (Slot slot : gui.slots) { Register.permission(slot.permissionToUse, op, plugin); Register.permission(admin, op, slot.permissionToUse, true, plugin); 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/UseItem.java similarity index 58% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Give_UseItem.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/UseItem.java index 5b389ff..57692fe 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/UseItem.java @@ -5,7 +5,7 @@ import com.mojang.authlib.properties.Property; import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; -import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; +import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; import net.t2code.lib.Spigot.Lib.messages.send; @@ -20,15 +20,16 @@ import org.bukkit.inventory.meta.SkullMeta; import java.lang.reflect.Field; import java.util.UUID; -public class Give_UseItem { +public class UseItem { - public static void onGive(Player player) { + public static void giveUseItem(Player player) { Integer slot; - if (SelectConfig.UseItem_InventorySlotEnforce){ + if (protection(player, false)) return; + if (SelectConfig.UseItem_InventorySlotEnforce) { slot = SelectConfig.UseItem_InventorySlot; } else { - if (Events.useItemSlotHashMap.get(player)== null) { + if (Events.useItemSlotHashMap.get(player) == null) { slot = SelectConfig.UseItem_InventorySlot; } else { slot = Events.useItemSlotHashMap.get(player); @@ -37,12 +38,13 @@ public class Give_UseItem { if (SelectConfig.UseItem_InventorySlot_FreeSlot) { player.getInventory().addItem(itemStack(player)); } else { - send.debug(Main.plugin,"setUseItem: " + player.getName() + " Slot: "+ Integer.parseInt(String.valueOf(slot-1))); + send.debug(Main.plugin, "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1))); player.getInventory().setItem(slot - 1, itemStack(player)); } } - public static void onGiveADD(Player player) { + public static void addUseItem(Player player) { + if (protection(player, false)) return; if (SelectConfig.UseItem_InventorySlot_FreeSlot) { player.getInventory().addItem(itemStack(player)); } else player.getInventory().addItem(itemStack(player)); @@ -96,4 +98,52 @@ public class Give_UseItem { } return item; } + + public static boolean protection(Player player, Boolean interact) { + if (SelectConfig.UseItemGameModeProtection) { + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { + if (interact) { + send.player(player, SelectMessages.UseItemDisabledInGameMode); + } else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player); + return true; + } + if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { + if (interact) { + send.player(player, SelectMessages.UseItemDisabledInGameMode); + } else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player); + return true; + } + } + if (SelectConfig.UseItemWorldProtection) { + if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { + if (interact) { + send.player(player, SelectMessages.UseItemDisabledInWorld); + } else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player); + return true; + } + if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { + if (interact) { + send.player(player, SelectMessages.UseItemDisabledInWorld); + } else if (!SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled) removeItem(player); + return true; + } + } + return false; + } + + public static void removeItem(Player player) { + send.debug(Main.plugin, "World disabled: " + player.getName() + " " + player.getWorld().toString()); + 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/system/database/MySQL.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java index 49ddaf3..27dd43b 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/MySQL.java @@ -35,9 +35,9 @@ public class MySQL { config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); ds = new HikariDataSource(config); - send.console(Main.prefix + " §2MySQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + send.console(Main.prefix + " §2MYSQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } catch (Exception ex) { - send.console(Main.prefix + " §4MySQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + send.console(Main.prefix + " §4MYSQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); send.error(Main.plugin, ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms"); } //Bukkit.getConsoleSender().sendMessage((System.currentTimeMillis() - long_) + "ms"); diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java index 1564893..401ad9b 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SQLITE.java @@ -22,7 +22,7 @@ public class SQLITE { } url = "jdbc:sqlite:" + Main.plugin.getDataFolder() + "/Storage/data.db"; con = DriverManager.getConnection(url); - Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Datenbank erfolgreich verbunden." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2SQLITE successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); DatabaseMetaData dbmd = con.getMetaData(); } 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/SelectDatabase.java similarity index 92% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/Select_Database.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SelectDatabase.java index aee094a..3da6206 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/SelectDatabase.java @@ -4,10 +4,20 @@ import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import org.bukkit.entity.Player; -public class Select_Database { +public class SelectDatabase { + + private static StorageType Storage; + + public static StorageType getStorage() { + return Storage; + } + + public static void setStorage(StorageType storage) { + Storage = storage; + } public static void nameCheck(Player player) { - switch (SelectConfig.Storage){ + switch (Storage){ case MYSQL: MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); break; @@ -24,7 +34,7 @@ public class Select_Database { } public static void setSlot(Player player, Integer slot) { - switch (SelectConfig.Storage) { + switch (Storage) { case MYSQL: MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Slot`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + "','" + slot + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Slot` = '" + slot + "';"); @@ -42,7 +52,7 @@ public class Select_Database { public static void setItemStatusTrue(Player player) { Events.useItemHashMap.replace(player, true); - switch (SelectConfig.Storage) { + switch (Storage) { case MYSQL: MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '1';"); @@ -60,7 +70,7 @@ public class Select_Database { public static void setItemStatusFalse(Player player) { Events.useItemHashMap.replace(player, false); - switch (SelectConfig.Storage) { + switch (Storage) { case MYSQL: MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() + "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';"); @@ -77,7 +87,7 @@ public class Select_Database { } public static Boolean selectItemStatus(Player player) { - switch (SelectConfig.Storage) { + switch (Storage) { case MYSQL: String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); if(result == null || result.equals("")){ @@ -97,7 +107,7 @@ public class Select_Database { } public static Integer selectSlot(Player player) { - switch (SelectConfig.Storage) { + switch (Storage) { case MYSQL: String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); if(result == null || result.equals("")|| result.equals("null")){ 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 12e4e5f..38afa67 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 @@ -8,7 +8,7 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.Help; import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; -import de.jatitv.commandguiv2.Spigot.system.database.Select_Database; +import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -52,12 +52,12 @@ public class CGuiAPI { public static void setPlayerItemEnable(Player player, Boolean value) { if (value) { - Select_Database.setItemStatusTrue(player); - } else Select_Database.setItemStatusFalse(player); + SelectDatabase.setItemStatusTrue(player); + } else SelectDatabase.setItemStatusFalse(player); } public static void setPlayerItemSlot(Player player, Integer value) { - Select_Database.setSlot(player, value); + SelectDatabase.setSlot(player, value); } public static void openDefaultGUI(Player player) { -- 2.34.1 From fc98f931e20cd18c4d55b78248d9bfb202b872c1 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 21 Apr 2022 02:19:27 +0200 Subject: [PATCH 13/16] Bugfix Bugfix: If you did not have the permission to see a function and still clicked on the slot, then an error occurred --- .../commandguiv2/Spigot/Listener/GUIListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java index 67fb9ae..18ab254 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java @@ -50,14 +50,14 @@ public class GUIListener implements Listener { for (Slot slot : gui.slots) { Function function = Main.functionHashMap.get(slot.function); if (e.getSlot() != slot.slot) continue; + if (slot.permission && !player.hasPermission(slot.permissionToUse)) { + player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name)) + .replace("[perm]", slot.permissionToUse)); + continue; + } if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() || e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() || e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) { - if (slot.permission && !player.hasPermission(slot.permissionToUse)) { - player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name)) - .replace("[perm]", slot.permissionToUse)); - continue; - } if (!slot.enable) continue; if (function.cost_Enable) { if (function.command_Enable || function.message_Enable || function.openGUI_Enable || function.serverChange) { -- 2.34.1 From 35a9930017b866ad50e17aa53535d0c53594a784 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 21 Apr 2022 02:38:43 +0200 Subject: [PATCH 14/16] error fix --- .../java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java index 18ab254..7aac6c1 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUIListener.java @@ -50,6 +50,7 @@ public class GUIListener implements Listener { for (Slot slot : gui.slots) { Function function = Main.functionHashMap.get(slot.function); if (e.getSlot() != slot.slot) continue; + if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue; if (slot.permission && !player.hasPermission(slot.permissionToUse)) { player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name)) .replace("[perm]", slot.permissionToUse)); -- 2.34.1 From f3feddd3177d8e5114d4beb0ec77911936648297 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Fri, 22 Apr 2022 19:05:34 +0200 Subject: [PATCH 15/16] api changes & clean code --- CommandGUI V2/pom.xml | 13 ++++++------- .../Spigot/cmdManagement/Commands.java | 4 ++-- .../Spigot/config/config/SelectConfig.java | 2 -- .../commandguiv2/Spigot/system/Load.java | 3 +-- ...gisterPermissions.java => Permissions.java} | 2 +- .../Spigot/system/database/SelectDatabase.java | 18 ++++++++---------- .../de/jatitv/commandguiv2/api/CGuiAPI.java | 15 +++++++-------- 7 files changed, 25 insertions(+), 32 deletions(-) rename CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/{RegisterPermissions.java => Permissions.java} (99%) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 4f53991..0742b61 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -69,7 +69,6 @@ placeholderapi http://repo.extendedclip.com/content/repositories/placeholderapi/ - @@ -113,12 +112,6 @@ HikariCP 4.0.3 - - me.clip - placeholderapi - 2.11.1 - provided - org.slf4j slf4j-jdk14 @@ -129,5 +122,11 @@ slf4j-api 1.7.22 + + me.clip + placeholderapi + 2.11.1 + provided + 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 ce24e27..2f9525c 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 @@ -11,7 +11,7 @@ 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.RegisterPermissions; +import de.jatitv.commandguiv2.Spigot.system.Permissions; import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import de.jatitv.commandguiv2.Util; import net.t2code.lib.Spigot.Lib.items.ItemVersion; @@ -85,7 +85,7 @@ public class Commands { e.printStackTrace(); } try { - RegisterPermissions.onPermRegister(); + Permissions.onPermRegister(); } catch (Exception e) { e.printStackTrace(); } 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 5fe88fc..15858dd 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 @@ -29,11 +29,9 @@ public class SelectConfig { public static Boolean HelpAlias; public static String language; public static String Currency; - public static List mainCommands; public static String storage; - public static Boolean Bungee; public static String thisServer; 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 1d0837a..2d6ad1f 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 @@ -46,7 +46,6 @@ public class Load { send.console(prefix + " §8-------------------------------"); - if (!new File(Main.getPath(), "config.yml").exists()) { try { CreateGUI.configCreate(); @@ -122,7 +121,7 @@ public class Load { } try { - RegisterPermissions.onPermRegister(); + Permissions.onPermRegister(); } catch (Exception e) { e.printStackTrace(); } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Permissions.java similarity index 99% rename from CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java rename to CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Permissions.java index a67fd41..0f853c7 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/RegisterPermissions.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Permissions.java @@ -7,7 +7,7 @@ import net.t2code.lib.Spigot.Lib.register.Register; import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.Plugin; -public class RegisterPermissions { +public class Permissions { private static final Plugin plugin = Main.plugin; public static final String key = "commandgui."; diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SelectDatabase.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SelectDatabase.java index 3da6206..b2b9d5f 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SelectDatabase.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/database/SelectDatabase.java @@ -17,7 +17,7 @@ public class SelectDatabase { } public static void nameCheck(Player player) { - switch (Storage){ + switch (Storage) { case MYSQL: MySQL.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); break; @@ -26,13 +26,11 @@ public class SelectDatabase { break; case SQLITE: default: - SQLITE.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); - break; + SQLITE.query("UPDATE `gui-item` SET Name='" + player.getName() + "' WHERE UUID='" + player.getUniqueId() + "';"); + break; + } } - -} - public static void setSlot(Player player, Integer slot) { switch (Storage) { case MYSQL: @@ -90,7 +88,7 @@ public class SelectDatabase { switch (Storage) { case MYSQL: String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); - if(result == null || result.equals("")){ + if (result == null || result.equals("")) { return true; } return result.equals("1"); @@ -99,7 +97,7 @@ public class SelectDatabase { case SQLITE: default: String result2 = SQLITE.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); - if(result2 == null || result2.equals("")){ + if (result2 == null || result2.equals("")) { return true; } return result2.equals("1"); @@ -110,7 +108,7 @@ public class SelectDatabase { switch (Storage) { case MYSQL: String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); - if(result == null || result.equals("")|| result.equals("null")){ + if (result == null || result.equals("") || result.equals("null")) { return null; } return Integer.parseInt(result); @@ -119,7 +117,7 @@ public class SelectDatabase { case SQLITE: default: String result2 = SQLITE.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); - if(result2 == null || result2.equals("") || result2.equals("null")){ + if (result2 == null || result2.equals("") || result2.equals("null")) { return null; } return Integer.parseInt(result2); 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 38afa67..2d8a4e7 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 @@ -8,6 +8,7 @@ import de.jatitv.commandguiv2.Spigot.cmdManagement.Help; import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI; import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig; import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages; +import de.jatitv.commandguiv2.Spigot.system.Permissions; import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase; import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.command.CommandSender; @@ -73,26 +74,24 @@ public class CGuiAPI { } public static void sendPluginInfo(CommandSender sender) { - if (sender.hasPermission("commandgui.command.info")) { + if (sender.hasPermission(Permissions.info)) { Commands.info(sender); } else sender.sendMessage(SelectMessages.NoPermissionForCommand - .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.command.info")); + .replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.info)); } public static void createDefaultGUI(CommandSender sender) { - if (sender.hasPermission("commandgui.admin")) { + if (sender.hasPermission(Permissions.admin)) { CreateGUI.configCreate(); sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml")); } else sender.sendMessage(SelectMessages.NoPermissionForCommand - .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); + .replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin)); } public static void reload(CommandSender sender) { - if (sender.hasPermission("commandgui.admin")) { + if (sender.hasPermission(Permissions.admin)) { Commands.reload(sender); } else sender.sendMessage(SelectMessages.NoPermissionForCommand - .replace("[cmd]", "/commandgui admin").replace("[perm]", "commandgui.admin")); + .replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin)); } - - } -- 2.34.1 From b6347c8fad7d685602e4763b5fc51d5bc2996e6c Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 28 Apr 2022 19:40:41 +0200 Subject: [PATCH 16/16] 2.7.0 --- CommandGUI V2/pom.xml | 6 ++--- .../Listener/UseItem_Listener/Events.java | 22 +++++++++++++------ .../Spigot/config/config/ConfigCreate.java | 3 --- .../Spigot/config/config/SelectConfig.java | 12 +++++----- .../commandguiv2/Spigot/system/Metrics.java | 1 - 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index 0742b61..9960bf5 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.7.0_Snapshot-6 + 2.7.0 jar CommandGUI @@ -67,7 +67,7 @@ placeholderapi - http://repo.extendedclip.com/content/repositories/placeholderapi/ + https://repo.extendedclip.com/content/repositories/placeholderapi/ @@ -85,7 +85,7 @@ net.t2code T2CodeLib - 11.4 + 11.6 net.t2code 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 a76c60b..49492b1 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,23 +36,24 @@ public class Events implements Listener { public static HashMap useItemHashMap = new HashMap<>(); public static HashMap useItemSlotHashMap = new HashMap<>(); + @EventHandler public void onJoin(PlayerJoinEvent e) { - if (SelectDatabase.selectItemStatus(e.getPlayer())){ + if (SelectDatabase.selectItemStatus(e.getPlayer())) { useItemHashMap.put(e.getPlayer(), true); } else useItemHashMap.put(e.getPlayer(), false); useItemSlotHashMap.put(e.getPlayer(), SelectDatabase.selectSlot(e.getPlayer())); if (CGuiAPI.JoinDisable) { - send.debug(Main.plugin,"JoinDisable"); + send.debug(Main.plugin, "JoinDisable"); return; } if (e.getPlayer().hasPermission("commandgui.get.guiitem.at.login")) { new BukkitRunnable() { @Override public void run() { - send.debug(Main.plugin,"itemChange: " + e.getPlayer().getName()); + send.debug(Main.plugin, "itemChange: " + e.getPlayer().getName()); ItemChange.itemChange(e.getPlayer(), true); } }.runTaskLater(Main.plugin, 20L * 1); @@ -159,14 +160,17 @@ public class Events implements Listener { private static void openGUI(PlayerInteractEvent e, Player player) { e.setCancelled(true); - if (player.isSneaking()) { + if (SelectConfig.disableInfoBySneak && player.isSneaking()) { Commands.info(player); return; } + if (!legacy()) { if (!topInventoryIsEmpty(player)) return; } + if (UseItem.protection(player, true)) return; + if (SelectConfig.UseItemGameModeProtection) { if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) { e.setCancelled(true); @@ -179,6 +183,7 @@ public class Events implements Listener { return; } } + if (SelectConfig.UseItemWorldProtection) { if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) { e.setCancelled(true); @@ -191,6 +196,7 @@ public class Events implements Listener { return; } } + if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) { OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true); } else { @@ -213,6 +219,7 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onItemMove(InventoryDragEvent e) { if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; + if (e.getWhoClicked() instanceof Player) { Player p = (Player) e.getWhoClicked(); if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName() @@ -234,7 +241,6 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemMove(InventoryClickEvent e) { if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; - Player player = (Player) e.getWhoClicked(); if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName() && e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { @@ -244,13 +250,13 @@ public class Events implements Listener { && e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { e.setCancelled(true); - } } @EventHandler(priority = EventPriority.HIGHEST) public void onItemMove(InventoryPickupItemEvent e) { if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; + if (e.getItem() != null && e.getItem().getItemStack() != null) { ItemStack item = e.getItem().getItemStack(); if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() @@ -263,6 +269,7 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onPlace(BlockPlaceEvent e) { if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; + if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName() && e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { e.setCancelled(true); @@ -272,6 +279,7 @@ public class Events implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onDrop(PlayerDropItemEvent e) { if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; + if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) { ItemStack item = e.getItemDrop().getItemStack(); if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() @@ -282,7 +290,7 @@ public class Events implements Listener { } private static boolean legacy() { - if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15|| NMSVersion.v1_16_R1) { + if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) { return true; } else return 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 1962125..c7fe49d 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 @@ -26,8 +26,6 @@ public class ConfigCreate { if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration); - - Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration); Config.set("Plugin.Debug", false, yamlConfiguration); Config.set("Plugin.HelpAlias", true, yamlConfiguration); Config.set("Plugin.language", "english", yamlConfiguration); @@ -102,7 +100,6 @@ public class ConfigCreate { Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration); Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration); - Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration); Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration); Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), 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 15858dd..f9c2d25 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 @@ -22,9 +22,6 @@ public class SelectConfig { private static final File config = new File(Main.getPath(), "config.yml"); private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - - public static Boolean DisableUpdateChecker; - public static Boolean UpdateCheckOnJoin; public static Boolean Debug; public static Boolean HelpAlias; public static String language; @@ -64,6 +61,8 @@ public class SelectConfig { public static String UseItemWorldMode; public static List UseItemWorldList; + public static Boolean disableInfoBySneak; + public static Boolean UseItem_InventorySlot_FreeSlot; public static Integer UseItem_InventorySlot; public static Boolean UseItem_InventorySlotEnforce; @@ -129,10 +128,6 @@ public class SelectConfig { } } - if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) { - DisableUpdateChecker = false; - } else DisableUpdateChecker = yamlConfiguration.getBoolean("Plugin.DisableUpdateChecker"); - UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin"); Debug = yamlConfiguration.getBoolean("Plugin.Debug"); HelpAlias = yamlConfiguration.getBoolean("Plugin.HelpAlias"); language = yamlConfiguration.getString("Plugin.language"); @@ -194,6 +189,9 @@ public class SelectConfig { UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode"); UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List"); + if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null){ + disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak"); + } toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable"); toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value"); 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 7929618..f272735 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 @@ -36,7 +36,6 @@ public class Metrics { public static void Bstats() { int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin! Metrics metrics = new Metrics(Main.plugin, pluginId); - metrics.addCustomChart(new Metrics.SimplePie("updatecheckonjoin", () -> String.valueOf(SelectConfig.UpdateCheckOnJoin))); metrics.addCustomChart(new DrilldownPie("storage_type_mysql", () -> { Map> map = new HashMap<>(); String storage = SelectDatabase.getStorage().toString(); -- 2.34.1