Hide Player

Discussion in 'Spigot Plugin Development' started by FloThePony, May 16, 2015.

Thread Status:
Not open for further replies.
  1. Does
    Code (Text):
    e.getPlayer().hidePlayer(Bukkit.getOnlinePlayers);
    Will that hide players from tab list, being visible and getOnlinePlayers?
    So if I do
    Code (Text):
    if(Bukkit.getOnlinePlayers() == 2) {
    Bukkit.broadcastMessage("There are two players");
    }
    Will it count the hidden player as an online player? If yes, how do I do this?
    Would I have to make an int of the alive players?
     
  2. Bukkit.getOnlinePlayers() neither returns an int nor a player. Furthermore, Player#hidePlayer does not accept a Collection. Why do you expect this?
     
  3. to hide all players:
    Code (Text):
            for (Player toHide : Bukkit.getServer().getOnlinePlayers()) {
                for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                    if (player != toHide) {
                          player.hidePlayer(toHide);
                    }
                }
            }
    This will remove their name from the tab list for every player they are hidden from.
     
    #3 Coltify, May 16, 2015
    Last edited: May 16, 2015
  4. I believe the hidePlayer method only hides the player's visibility, and not from the tab list. It will not hide the player from being returned with the getOnlinePlayers method.
     
  5. Why would one return there? Since you want to hide everyone from everyone else, you'd simply want to continue to the next player in that situation, wouldn't you?
     
  6. hidePlayer will essentially make the server stop sending packets about one specific player to another specific player. They will no longer be visible in the tab list for the target player.
     
    • Like Like x 1
    • Agree Agree x 1
    • Useful Useful x 1
  7. JamesJ

    Supporter

    It removes their name too.
     
  8. That statement just makes it so it doesn't Hide a player from themselves.
     
  9. I knew it stopped sending the packets for the client to render the target player, but I did not know it would stop the player from being on the tab list. Thank you for that information. :)

    @Rocoty just said that above you. :p
     
  10. I get that, but my point is another one. Suppose the online players array contains Player1 and Player2. With your code, it would do

    toHide = p1, player = p1 and because those two satisfy toHide == player, it'd abort and never actually hide anyone.

    Consequently, one would want to replace the return; statement there, instead using a continue to produce the following behavoir

    toHide = p1, player = p1, skip
    toHide = p1, player = p2, hide and so on ...
     
  11. You could just replace the statement with this:
    Code (Text):
    if (player != toHide) {
                        player.hidePlayer(toHide);
                    }
     
  12. Undoubtedly so, my suggestion simply was based on the idea to offer a correction that'd change your code as little as possible ;) The != - version definitely is the most straightforward one, so you'd might want to edit that into your original code-post for those that don't read these comments.
     
    • Agree Agree x 1
  13. What? My if thing worked when I did that...
    And please don't hate, I was just qsking

    damn it m7
    ur not supposed to just give me the code

    Thanks <3

    For DatPixel do you use the new
    Code (Text):
    Bukkit.spawnGirl(player.getLocation);
    Feature?
    For some reason it always returns me
     
    #13 FloThePony, May 16, 2015
    Last edited by a moderator: May 17, 2015
  14. Your if-statement worked when you did...what, exactly? Because I can tell you right here and now that the code you posted will not compile.
     
  15. Oh
    Then I have a terrible memory
    I'm on iPad
    So idk
    Edit: well... I really do have a terrible memory.
     
  16. JamesJ

    Supporter

    Nah m8.
    Code (Text):
    DatPixelCore.spawnGirl(LoveType.STRAIGHT, EyeColor.BLUE, HairColor.BLONDE, "DatPixelGirl", sender.getLocation);
     
  17. k m7
    i could make a
    Code (Text):
    FloThePonyCore.shootBullet(DatPixelCore.DatPixelGirl.getLocation);
    FloThePonyCore.disguiseAs(DatPixelCore.getGirl();
     
     
  18. Nuu, you spoonfed. :(
     
    • Agree Agree x 3
  19. JamesJ

    Supporter

    mk
    u r bad at cuding. jus b queit.
     
  20. get on my levil m7
     
Thread Status:
Not open for further replies.