I literally cannot find the problem, I don't seem to find any problems in the code but; If someone makes an item in the GUI I've setup, when they click the item it just opens up the second page I've made. The command attached to the item doesn't execute either. Here's the code; Code (Move your mouse to reveal the content) Code (open) Code (close) Code: @SuppressWarnings("deprecation") private void openPage1(Player player) { Inventory inv = Bukkit.createInventory(null, 54, ChatColor.RED+"Punishments"+ChatColor.DARK_GRAY+" » Page 1"); for(int a = 1; a < 49; a++) { if (!plugin.getConfig().contains("Page1.Slot"+a)) continue; String SAName = plugin.getConfig().getString("Page1.Slot"+a+".Name").replaceAll("#target", map.get(player.getUniqueId())).replaceAll("#punisher", map2.get(player.getUniqueId())).replaceAll("&", "§"); String SACMDLore = plugin.getConfig().getString("Page1.Slot"+a+".Command").replaceAll("#target", map.get(player.getUniqueId())); String SAPermission = plugin.getConfig().getString("Page1.Slot"+a+".Permission"); ItemStack SAItem = new ItemStack (Material.getMaterial(plugin.getConfig().getString("Page1.Slot"+a+".Item"))); ItemMeta SAMeta = SAItem.getItemMeta(); if (!plugin.getConfig().contains("Page1.Slot"+a)); ArrayList<String> SALore = new ArrayList<String>(); SALore.add(" "); SALore.add(ChatColor.RED+"Command:"); SALore.add(ChatColor.GRAY+"/"+SACMDLore); if (!player.hasPermission(SAPermission) && !player.hasPermission("sb.use.*")) { SALore.add(" "); SALore.add(ChatColor.WHITE+"Permission: "+ChatColor.RED+"false"); } if (player.hasPermission(SAPermission) || player.hasPermission("sb.use.*")) { SALore.add(" "); SALore.add(ChatColor.WHITE+"Permission: "+ChatColor.GREEN+"true"); } SAMeta.setDisplayName(SAName); SAMeta.setLore(SALore); SAItem.setItemMeta(SAMeta); inv.setItem(a -1, SAItem); } for(int b = 51; b < 54; b++) { if (!plugin.getConfig().contains("Page1.Slot"+b)) continue; String SBName = plugin.getConfig().getString("Page1.Slot"+b+".Name").replaceAll("#target", map.get(player.getUniqueId())).replaceAll("#punisher", map2.get(player.getUniqueId())).replaceAll("&", "§"); String SBCMDLore = plugin.getConfig().getString("Page1.Slot"+b+".Command").replaceAll("#target", map.get(player.getUniqueId())); String SBPermission = plugin.getConfig().getString("Page1.Slot"+b+".Permission"); ItemStack SBItem = new ItemStack (Material.getMaterial(plugin.getConfig().getString("Page1.Slot"+b+".Item"))); ItemMeta SBMeta = SBItem.getItemMeta(); if (!plugin.getConfig().contains("Page1.Slot"+b)); ArrayList<String> SBLore = new ArrayList<String>(); SBLore.add(" "); SBLore.add(ChatColor.RED+"Command:"); SBLore.add(ChatColor.GRAY+"/"+SBCMDLore); if (!player.hasPermission(SBPermission) && !player.hasPermission("sb.use.*")) { SBLore.add(" "); SBLore.add(ChatColor.WHITE+"Permission: "+ChatColor.RED+"false"); } if (player.hasPermission(SBPermission) || player.hasPermission("sb.use.*")) { SBLore.add(" "); SBLore.add(ChatColor.WHITE+"Permission: "+ChatColor.GREEN+"true"); } SBMeta.setDisplayName(SBName); SBMeta.setLore(SBLore); SBItem.setItemMeta(SBMeta); inv.setItem(b -1, SBItem); } Player target = Bukkit.getPlayer(map.get(player.getUniqueId())); int x = target.getLocation().getBlockX(); int y = target.getLocation().getBlockY(); int z = target.getLocation().getBlockZ(); ItemStack SStats = new ItemStack (Material.getMaterial(plugin.getConfig().getString("Stats"))); ItemMeta SStatsMeta = SStats.getItemMeta(); if(plugin.getConfig().getBoolean("AdvancedStats") == true) { ArrayList<String> SStatsLore = new ArrayList<String>(); SStatsLore.add(" "); SStatsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName()); SStatsLore.add(" "); SStatsLore.add(ChatColor.RED+"UUID "+ChatColor.GRAY+"» "+target.getUniqueId()); SStatsLore.add(ChatColor.RED+"IP "+ChatColor.GRAY+"» "+target.getAddress().getAddress().getHostAddress()); SStatsLore.add(ChatColor.RED+"World "+ChatColor.GRAY+"» "+target.getWorld().getName()); SStatsLore.add(ChatColor.RED+"Location "+ChatColor.GRAY+"» X="+x+" Y="+y+" Z="+z); SStatsLore.add(ChatColor.RED+"Gamemode "+ChatColor.GRAY+"» "+target.getGameMode()); SStatsLore.add(ChatColor.RED+"Health "+ChatColor.GRAY+"» ❤"+target.getHealth()+"/20.0"); SStatsLore.add(ChatColor.RED+"Food "+ChatColor.GRAY+"» "+target.getFoodLevel()+"/20"); SStatsLore.add(ChatColor.RED+"Exp "+ChatColor.GRAY+"» "+target.getTotalExperience()); SStatsLore.add(ChatColor.RED+"Hand Item "+ChatColor.GRAY+"» "+ChatColor.GRAY+target.getItemInHand().getType()); SStatsMeta.setLore(SStatsLore); } if(plugin.getConfig().getBoolean("AdvancedStats") == false) { ArrayList<String> SStatsLore = new ArrayList<String>(); SStatsLore.add(" "); SStatsLore.add(ChatColor.RED+"Name "+ChatColor.GRAY+"» "+target.getName()); SStatsMeta.setLore(SStatsLore); } SStatsMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Stats"); SStats.setItemMeta(SStatsMeta); ItemStack SPages = new ItemStack (Material.getMaterial(plugin.getConfig().getString("Pages"))); ItemMeta SPagesMeta = SPages.getItemMeta(); SPagesMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Next page"); SPages.setItemMeta(SPagesMeta); ItemStack SOptions = new ItemStack (Material.getMaterial(plugin.getConfig().getString("Options"))); ItemMeta SOptionsMeta = SOptions.getItemMeta(); SOptionsMeta.setDisplayName(ChatColor.GRAY+"» "+ChatColor.RED+"Options"); SOptions.setItemMeta(SOptionsMeta); inv.setItem(48, SOptions); inv.setItem(49, SStats); inv.setItem(53, SPages); player.openInventory(inv); } @EventHandler public void onInventoryClickPage1(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); if(!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Punishments » Page 1")) return; event.setCancelled(true); if(event.getCurrentItem()==null || event.getCurrentItem().getType()==Material.AIR || !event.getCurrentItem().hasItemMeta() || event.getSlot() == 49) { player.sendMessage(String.format("%s[%sSuch %sBans%s] %sYou cannot do anything with this Item!", ChatColor.DARK_GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.DARK_GRAY, ChatColor.RED)); player.closeInventory(); return; } else if(event.getSlot() == 53 && player.hasPermission("sb.use.page2") || player.hasPermission("sb.use.*")) { openPage2(player); return; } if(event.getSlot() == 53 && !player.hasPermission("sb.use.page2") || !player.hasPermission("sb.use.*")) { player.sendMessage(String.format("%s[%sSuch %sBans%s] %sYou are not allowed to use this Item!", ChatColor.DARK_GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.DARK_GRAY, ChatColor.RED)); player.closeInventory(); return; } if(event.getSlot() == 48 && player.hasPermission("sb.use.optionspage") || player.hasPermission("sb.use.*")) { openOptionsPage(player); return; } if(event.getSlot() == 48 && !player.hasPermission("sb.use.optionspage") || !player.hasPermission("sb.use.*")) { player.sendMessage(String.format("%s[%sSuch %sBans%s] %sYou are not allowed to use this Item!", ChatColor.DARK_GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.DARK_GRAY, ChatColor.RED)); player.closeInventory(); return; } List<String> plist = this.getConfig().getStringList("PunishmentLog"); this.getConfig().set("PunishmentLog", plist); String SAPermission = plugin.getConfig().getString("Page1.Slot"+(event.getSlot()+1)+".Permission"); if (!player.hasPermission(SAPermission)) { player.sendMessage(String.format("%s[%sSuch %sBans%s] %sYou are not allowed to use this Item!", ChatColor.DARK_GRAY, ChatColor.RED, ChatColor.GRAY, ChatColor.DARK_GRAY, ChatColor.RED)); player.closeInventory(); return; } else { if (player.hasPermission(SAPermission) || player.hasPermission("sb.use.*")) if(plugin.getConfig().contains("Page1.Slot"+(event.getSlot()+1)+".Command")){ String SACommand = plugin.getConfig().getString("Page1.Slot"+(event.getSlot()+1)+".Command").replaceAll("%target%", map.get(player.getUniqueId())); player.performCommand(SACommand); plist.add("============== ["+date+"] ====================="); plist.add("Punisher >> "+player.getName()); plist.add("Target >> "+map.get(player.getUniqueId())); plist.add("Command >> /"+SACommand); plist.add("=============================================="); plist.add(""); saveConfig(); }}} As long as there is one item they have created, when they click on it, it just brings you to the next page and doesn't do what it should do. Also, the custom permission (they can choose for every item) doesn't seem to be working either.. Here's the config; Code: # SuchBansGUI by yPedx # Version v5.0.2 # ------------------------------------------------------------------ # Variables: # #target <-- The target # #punisher <-- The one punishing # ------------------------------------------------------------------ # Commands and permissions can be found at spigot download page. # Plugin not working properly? Create an issue at github.com/yPedx/SuchBans/issues # ------------------------------------------------------------------ # Create / remove any Items you want. # REQUIRED FORMAT: # Slot#: <-- # = 1-54 # Name: <-- What name should the item have? // Color codes are supported # Command: <-- What command should it execute? // Do not include a / # Item: <-- What item should it be? // Block IDs not supported. Example use; DIAMOND_BLOCK # Permission: <-- Custom permission for your item // Must have 2 parts! Example: like.this # ------------------------------------------------------------------ # Use AdvancedStats? AdvancedStats: true # What Item should be used for; Stats: SIGN Pages: BOOK Back: BARRIER Options: NETHER_STAR Page1: Slot4: Name: "Sick" Command: 'kick #target' Item: TNT Permission: custom.perm Page2: OptionsPage: # Punishment log PunishmentLog:
@yPedx Be care with event.getSlot(), it's not unique. You should use event.getRawSlot(). When you open a custom inventory, getSlot can return the same number if you click on the custom inventory or on your own inventory.
Ah, just went off pc so can't check if it fixes the problem I'll check tomorrow. @Caderape2 EDIT: I seem to have found the problem.. And I understand why now :/ What I did, was change; Code: if(event.getRawSlot() == 53 && player.hasPermission("sb.use.page2") || player.hasPermission("sb.use.*")) { to this; Code: if(event.getRawSlot() == 53 && player.hasPermission("sb.use.page2")) { [/CODE] Cause appearently if they have sb.use.* this will be fired anyway.
Yep, that's like saying Code: (event.getRawSlot() == 53 && player.hasPermission("sb.use.page2")) || player.hasPermission("sb.use.*") So it would work if they either have sb.use.*, or if the slot is 53 and they have sb.use.page2