diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index a1ed8ea..76ea62d 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,11 @@ net.t2code CommandGUI_V2 +<<<<<<< Updated upstream 2.6.1 +======= + 2.6.10_Snapshot-1 +>>>>>>> Stashed changes jar CommandGUI @@ -65,6 +69,10 @@ T2Code https://repo.t2code.net/repository/T2Code/ + + placeholderapi + http://repo.extendedclip.com/content/repositories/placeholderapi/ + @@ -89,91 +97,16 @@ 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 @@ -182,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 ed003b5..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; @@ -36,6 +38,7 @@ 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)) @@ -139,6 +142,146 @@ public class GUI_Listener implements Listener { 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; + 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 (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); + } + } + } 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))); + } + } + } + } + } + + 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 command(Slot slot, Player player) { + 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 { + 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())); + } + } + } + }.runTaskLater(plugin, 2L); + } + + private static void openGUI(Slot slot, Player player) { + 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); + } + + private static void message(Slot slot, Player player) { + new BukkitRunnable() { + @Override + public void run() { + player.closeInventory(); + } + }.runTaskLater(plugin, 1L); + for (String msg : slot.message) { + if (Main.PaPi) { + 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)); + } else player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix))); + } + } + } + + private static void serverChange(Slot slot, Player player) { + 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); + } + + 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")); @@ -146,6 +289,7 @@ 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); @@ -388,10 +532,81 @@ public class GUI_Listener implements Listener { } } } +======= + 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); + } + + private static void sound(Slot slot, Player player, Object gui) { + 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); +>>>>>>> Stashed changes } } } } + + 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 7f75c33..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,10 +18,10 @@ 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); } } @@ -52,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 @@ -79,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); 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 fd17a5e..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(); @@ -279,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/Objekte/Obj_Select.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Objekte/Obj_Select.java index 55a3761..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"), @@ -99,7 +101,7 @@ public class Obj_Select { 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); 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