Hello all! I am trying to make a inventory in which you can toggle player invisibility and other things. This is the code in the event that includes the array list Code (Text): public class Events implements Listener { public Events(Hub hub) { // TODO Auto-generated constructor stub } @EventHandler public void onPlayerVis(PlayerInteractEvent e) { Player player = e.getPlayer(); if (Options.toggle.contains(player.getUniqueId())) { for (Player targetPlayers : Bukkit.getOnlinePlayers()) { if (player.canSee(targetPlayers)) { player.hidePlayer(targetPlayers); player.sendMessage(Hub.prefix + "Players have been hidden!"); } else if(!Options.toggle.contains(player.getUniqueId())){ player.showPlayer(targetPlayers); player.sendMessage(Hub.prefix + "Players are now shown!"); } } } } } This is the code that is in the GUI Code (Text): switch(event.getCurrentItem().getType()) { case EYE_OF_ENDER: if (toggle.contains(player.getUniqueId())) { toggle.remove(player.getUniqueId()); } else if (!toggle.contains(player.getUniqueId())) { toggle.add(player.getUniqueId()); } break; } }
What have you tried? Have you included debug messages? See how far your code gets; conditional statements can be really nasty when there's a lot of them.