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.
This commit is contained in:
JaTiTV 2022-04-06 20:21:19 +02:00
parent 1c6e6d6660
commit 17b1a0568e
3 changed files with 14 additions and 12 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId> <artifactId>CommandGUI_V2</artifactId>
<version>2.6.2_Snapshop-1</version> <version>2.6.2_Snapshot-2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandGUI</name> <name>CommandGUI</name>

View File

@ -46,13 +46,13 @@ public class GUI_Listener implements Listener {
e.setCancelled(true); e.setCancelled(true);
for (Slot slot : gui.GUI_Slots) { for (Slot slot : gui.GUI_Slots) {
if (e.getSlot() != slot.Slot) continue; if (e.getSlot() != slot.Slot) continue;
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) {
if (!slot.Perm 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))
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use") || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use")
|| player.hasPermission("commandgui.admin")) { || player.hasPermission("commandgui.admin")) {
if (!slot.Enable) continue; if (!slot.Enable) continue;
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.Name))) 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 (slot.Cost_Enable) { if (slot.Cost_Enable) {
if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) { if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) {
if (!Vault.buy(prefix, player, slot.Price)) { if (!Vault.buy(prefix, player, slot.Price)) {
@ -63,7 +63,8 @@ public class GUI_Listener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
player.sendMessage(SelectMessages.No_money); 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 { } else {
player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name)) player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name))
.replace("[price]", slot.Price + " " + SelectConfig.Currency)); .replace("[price]", slot.Price + " " + SelectConfig.Currency));
@ -71,13 +72,13 @@ public class GUI_Listener implements Listener {
} }
} }
} else execute(slot, player, e, gui); } 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))); .replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)));
} }
} }
} }
} }
}
private static void execute(Slot slot, Player player, InventoryClickEvent e, Object gui) { private static void execute(Slot slot, Player player, InventoryClickEvent e, Object gui) {
if (slot.Command_Enable) command(slot, player); if (slot.Command_Enable) command(slot, player);

View File

@ -69,7 +69,8 @@ public final class Main extends JavaPlugin {
if (PluginCheck.plotSquaredGUI()) { if (PluginCheck.plotSquaredGUI()) {
PlotSquaredGUI = true; PlotSquaredGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI")); addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
}if (PluginCheck.luckyBox()) { }
if (PluginCheck.luckyBox()) {
LuckyBox = true; LuckyBox = true;
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox")); addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
} }