Solved Check if a player is hidden

Discussion in 'Plugin Development' started by Thypthon, Dec 27, 2012.

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


    My plugin is build that we have a own /list command on /who, when a mod/admin type /inv on they will be hidden from /who (custom function) and will be
    And stored in a HashSet for the custom function in /who

    When reload the HashSet gets cleard and players in /who will be shown. My problem is to try hide players that are hidden in bukkit inside onEnable. Is there a player.isHidden() function? Can't find anything inside Java Docs. Thanks in advance.
  2. Offline


    The method you are looking for is player.canSee(Player).
  3. Offline


    I have tried some codes with that function. So when I loop all players in onEnable it should be checked this way:
    2. for (Player p : getServer().getOnlinePlayers()) {
    3. if(!p.canSee(???)){
    4. // do stuff
    5. }
    6. }

    My problem is how to get who to check.
    And that who should be the ones that are hidden.
  4. Offline


    I would probably use a for loop inside of a for loop, like so:
    for (Player p : getServer().getOnlinePlayers()) {
        for (Player target : getServer().getOnlinePlayers()){
            if(!p.getName().equalsIgnoreCase(target.getName()) && p.canSee(target)){
                //do stuff
  5. Offline


    Thanks, trying it out.

    It worked, thanks psycowithespn.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page