Hub Player Hider Help

Discussion in 'Spigot Plugin Help' started by ItAintObeezy, May 12, 2015.

  1. Code (Text):
    package com.itaintobeezy.mgpu;

    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin implements Listener {
       
        public void onEnable() {
           
            getServer().getPluginManager().registerEvents(this, this);
           
        }
       
        @EventHandler
        public void onPlayerClick(PlayerInteractEvent e) {
           
            ItemStack playerHider = new ItemStack(Material.WATCH);
           
            ItemMeta playerHiderMeta = playerHider.getItemMeta();
           
            playerHiderMeta.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Hide Players");
           
            playerHider.setItemMeta(playerHiderMeta);
           
            e.getPlayer().getInventory().setItem(1, playerHider);
           
            if ((e.getItem().getType() == Material.WATCH && e.getItem().getItemMeta() == playerHiderMeta)) {
               
                Player player = e.getPlayer();
               
                Server server = player.getServer();
               
                if (e.getAction() == Action.LEFT_CLICK_AIR | e.getAction() == Action.LEFT_CLICK_BLOCK | e.getAction() == Action.RIGHT_CLICK_AIR | e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                   
                    for (Player toBeVanished : server.getOnlinePlayers()) {
                       
                        if (toBeVanished.hasPermission("mghubutils.vanish.exclude")) {
                           
                            Player excludeFromVanish1 = toBeVanished;
                           
                            boolean excludeFromVanish = player.hasPermission("mghubutils.vanish.exclude");
                           
                            if (excludeFromVanish == true && excludeFromVanish1 == toBeVanished) {
                               
                                player.showPlayer(excludeFromVanish1);
                               
                            }
                           
                        } else {
                           
                            player.hidePlayer(toBeVanished);
                           
                        }
                           
                    }
                   
                    player.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "Mine" + ChatColor.GREEN + "" + ChatColor.BOLD + "Galaxy" + ChatColor.GRAY + " " + ChatColor.BOLD + ">>" + ChatColor.GOLD + "Hiding all players");
                       
                }
               
                boolean hasPlayerClicked = e.getAction() == Action.LEFT_CLICK_AIR | e.getAction() == Action.LEFT_CLICK_BLOCK | e.getAction() == Action.RIGHT_CLICK_AIR | e.getAction() == Action.RIGHT_CLICK_BLOCK;
               
                if (e.getAction() == Action.LEFT_CLICK_AIR | e.getAction() == Action.LEFT_CLICK_BLOCK | e.getAction() == Action.RIGHT_CLICK_AIR | e.getAction() == Action.RIGHT_CLICK_BLOCK && hasPlayerClicked == true) {
                   
                    for (Player toBeVanished : e.getPlayer().getServer().getOnlinePlayers()) {
                   
                        player.showPlayer(toBeVanished);
                   
                    }
                   
                   
                   
                }
               
            }
           
        }
       
    }
    So, I want to create a plugin to vanish players in the hub, but exclude ones with the required permission. This is what I have so far. The problem is that the plugin does nothing. If anyone sees an error please let me know! Thanks!