From 17b1a0568e0f841d7f35f1143aee4e08c524f7fb Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Wed, 6 Apr 2022 20:21:19 +0200 Subject: [PATCH] bugfix If you didn't have the permission to see an item, you could still click on it and get the message that you don't have the permission. This has now been changed so that you only get the message if you can see the item. --- CommandGUI V2/pom.xml | 2 +- .../Spigot/Listener/GUI_Listener.java | 21 ++++++++++--------- .../de/jatitv/commandguiv2/Spigot/Main.java | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CommandGUI V2/pom.xml b/CommandGUI V2/pom.xml index d80906f..457f4f6 100644 --- a/CommandGUI V2/pom.xml +++ b/CommandGUI V2/pom.xml @@ -6,7 +6,7 @@ net.t2code CommandGUI_V2 - 2.6.2_Snapshop-1 + 2.6.2_Snapshot-2 jar CommandGUI diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Listener/GUI_Listener.java index 150f660..0a95d66 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 @@ -46,13 +46,13 @@ public class GUI_Listener implements Listener { e.setCancelled(true); for (Slot slot : gui.GUI_Slots) { if (e.getSlot() != slot.Slot) continue; - 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 (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) { + if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) { + if (!slot.Perm + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)) + || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use") + || 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)) { @@ -63,7 +63,8 @@ public class GUI_Listener implements Listener { } }.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); + 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)); @@ -71,9 +72,9 @@ public class GUI_Listener implements Listener { } } } else execute(slot, player, e, gui); - } - } else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name)) + } else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name)) .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))); + } } } } diff --git a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java index 040854a..741f0a7 100644 --- a/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java +++ b/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/Main.java @@ -69,7 +69,8 @@ public final class Main extends JavaPlugin { if (PluginCheck.plotSquaredGUI()) { PlotSquaredGUI = true; addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI")); - }if (PluginCheck.luckyBox()) { + } + if (PluginCheck.luckyBox()) { LuckyBox = true; addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox")); }