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 fa0610f..9801225 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 @@ -160,11 +160,9 @@ public class Events implements Listener { private static void openGUI(PlayerInteractEvent e, Player player) { e.setCancelled(true); - if (!SelectConfig.disableInfoBySneak){ - if ( player.isSneaking()) { - Commands.info(player); - return; - } + if ((!SelectConfig.disableInfoBySneak) && player.isSneaking()) { + Commands.info(player); + return; } if (!legacy()) { @@ -213,7 +211,6 @@ public class Events implements Listener { if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName() && e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { e.setCancelled(true); - } } 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 635f183..fc9999d 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 @@ -65,13 +65,14 @@ public class Commands { CmdExecuter_GUITab.arg1.clear(); CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); - SelectConfig.onSelect(); + SelectConfig.onSelect(); Main.plugin.reloadConfig(); if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) { if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!"); send.console("You have changed the storage medium! To apply this change, you must restart the server!"); } + LanguagesCreate.langCreate(); Obj_Select.onSelect(); @@ -160,36 +161,41 @@ public class Commands { } public static void onSetSlot(Player player, Integer setSlot) { - if (SelectConfig.UseItem_AllowSetSlot) { - if (setSlot < 1) { - send.player(player, SelectMessages.ItemSlot_wrongValue); + if (!SelectConfig.UseItem_AllowSetSlot) { + player.sendMessage(Util.getPrefix() + " §4Function disabled"); + return; + } + + if (setSlot < 1) { + send.player(player, SelectMessages.ItemSlot_wrongValue); + return; + } + if (setSlot > 9) { + send.player(player, SelectMessages.ItemSlot_wrongValue); + return; + } + + if (Events.useItemHashMap.get(player)) { + if (Objects.equals(Events.useItemSlotHashMap.get(player), setSlot)) { + player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString())); return; } - if (setSlot > 9) { - send.player(player, SelectMessages.ItemSlot_wrongValue); - return; - } - ItemStack itm1 = player.getInventory().getItem(setSlot + 1); - if (itm1 != null) { - if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) { - if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { - player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString())); - return; - } - } - } - if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) { - send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString())); - return; - } - UseItem.removeItem(player); - SelectDatabase.setSlot(player, setSlot); - Events.useItemSlotHashMap.replace(player, setSlot); - if (Events.useItemHashMap.get(player)) { - UseItem.giveUseItem(player); - } - send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString())); - } else player.sendMessage(Util.getPrefix() + " §4Function disabled"); + } + + if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) { + send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString())); + return; + } + + UseItem.removeItem(player); + SelectDatabase.setSlot(player, setSlot); + Events.useItemSlotHashMap.replace(player, setSlot); + + if (Events.useItemHashMap.get(player)) { + UseItem.giveUseItem(player); + } + + send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString())); } public static void gui(Player player) { 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 0e6f2a7..df4b13a 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 @@ -19,9 +19,6 @@ import java.util.ArrayList; import java.util.List; public class SelectConfig { - - private static final File config = new File(Main.getPath(), "config.yml"); - private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); public static Boolean Debug; public static Boolean HelpAlias; public static String language; @@ -117,6 +114,9 @@ public class SelectConfig { public static void onSelect() { + File config = new File(Main.getPath(), "config.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) { send.console(Util.getPrefix() + " §4----------------------"); send.console(Util.getPrefix() + " "); @@ -189,7 +189,7 @@ public class SelectConfig { UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode"); UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List"); - if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null){ + if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) { disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak"); } @@ -221,7 +221,6 @@ public class SelectConfig { Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_")); Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable"); Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_")); - setConfigVersion(); } @@ -345,7 +344,9 @@ public class SelectConfig { } - private static void setConfigVersion() { + public static void setConfigVersion() { + File config = new File(Main.getPath(), "config.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); yamlConfiguration.set("ConfigVersion", Util.getConfigVersion()); try { yamlConfiguration.save(config); 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 2d6ad1f..326b345 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 @@ -69,6 +69,8 @@ public class Load { e.printStackTrace(); } + SelectConfig.setConfigVersion(); + if (SelectConfig.Bungee) { if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) { send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");