Togging Player Visibility In GUI

Discussion in 'Spigot Plugin Development' started by MaxNatural, May 26, 2016.

  1. 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

        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.sendMessage(Hub.prefix + "Players have been hidden!");
                    } else if(!Options.toggle.contains(player.getUniqueId())){
                        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())) {
                } else if (!toggle.contains(player.getUniqueId())) {
  2. What? Please specify what your problem actually is.
  3. Sorry about that, when I try and toggle it doesn't make everyone vanish.
  4. 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.