Vanish (easy)

Discussion in 'Plugin Development' started by Tommy Raids, Dec 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Tommy Raids

    Hey guys, recently coded a vanish plugin, somewhat like McPvP's. Anyways, I have the commands/arraylists down and everything, but how would you make it so that, for example: Youtubers can't see mods vanished, Mods can't see admins vanished, and Admins can see any vanished players? I tried using perms but it really just messed it up. :/ (Here's my code so far):

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player p = (Player) sender;
           
            if (cmd.getName().equalsIgnoreCase("vanish")){
                if(!p.hasPermission("les.vanish.mod")){
                    p.sendMessage("Unknown command. Type \"/help\" for help.");
                }
                   
                else if (!hidden.contains(p.getName())) {
                    for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                        if(!p.hasPermission("vanish.see")){
                        pl.hidePlayer(p);
                    }
                    }
                    hidden.add(p.getName());
                    p.sendMessage(ChatColor.LIGHT_PURPLE + "You are now invisible to Youtuber and below.");
                    return true;
                }
                else {
                    for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
                        pl.showPlayer(p);
                    }
                    hidden.remove(p.getName());
                    p.sendMessage(ChatColor.GREEN + "You are now visible.");
                    return true;
                    }
            }
            return false;
     
    }
     
  2. Offline

    moo3oo3oo3

    Packets.
    or player.canSee(arg0) ?
     
    Tommy Raids likes this.
  3. Offline

    Tommy Raids

    Could you give me an example with player.canSee(arg0)?
     
  4. Offline

    moo3oo3oo3

    not sure how it works :p
     
  5. Offline

    Tommy Raids

    Haha, okay xD
    I'll do some research, but thanks :)
     
Thread Status:
Not open for further replies.

Share This Page