Solved Issue : Hide player in PlayerList only

Discussion in 'Spigot Plugin Development' started by cricri_21, Jul 20, 2020.

  1. After more than 12 hours of research and testing, i just can't see how to hide a player in the playerList only.

    Here something that works :
    Code (Java):
    EntityPlayer craftPlayer = ((CraftPlayer)p).getHandle();
                PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, craftPlayer);
                Chat.plugin().getServer().getOnlinePlayers().forEach((player) -> {
                    if(!player.isOp()) {
    with "PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER" or "PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER" if I want to add or remove a player in playerList.

    But there is issue but this code... When the hiddenlist player dissapears from the sight of every other players, he becomes entirely vanished. It includes the GameMode spectator -> creative, the dead, the great distance, and so on.

    Example :
    Nothing done :

    I perform the command that vanishes cricri_21 (display name : Crilian) in the playerlist :

    Now, I just press F3+N twice (shortcut to go in spectator then creative), so cricri_21 is in creative absolutly visible.. But "test" cannot see him both in the playerlist and in game.

    It makes the command totally unusable. I searched if there were some command, but with no java doc in nms, it's really hard.

    I then turned to ProtocolLib :

    This is a code that i can't run. I have the same exception than him :

    1. I do not know if it would work without entirely vanish that hiddenlist player...
    2. I think the format of createPacketConstructor has recently changed for PacketType.Play.Server.PLAYER_INFO... Or I just did a mistake.
    This should work, but i can't find exact arguments type to put. I searched in the java doc and source code (,

    Can someone know if there is a simple correction to add in nms to cancel this dirty vanish or how to run the HidePlayerList ?

    Do I have to run "HidePlayerList.register()" ?
    #1 cricri_21, Jul 20, 2020
    Last edited: Jul 21, 2020
  2. SteelPhoenix


    The issue is that when the player becomes visible again (by respawning, coming out of spectator, getting within render distance), the server sends a named entity spawn packet. As far as the client is concerned there is no player with the given entity id (because it is removed from the tab list) so it just ignores the packet.
    You can get around this by listening to the spawn entity packet and then manually adding the player back to the tab list, sending all required spawn packets and removing the player again.
    • Like Like x 1
  3. Thanks for the fast response !

    It was the last solution i wanted to set up but nevermind i will turn into that...

    I have now a question : What does "listening to the spawn entity packet" mean ? Is this a loop, or when a player hidden from player list do something (like sneaking for example) it shows packets then hide it again, or is this another packet to bring, like "
    PacketPlayOutPlayerInfo.EnumPlayerInfoAction.SOMETHING" ? (I'm sorry, i have never used packets so far :( )

    EDIT :
    Alright, I spend some times to get it :
    1. Load the PacketListener to the ProtocolManager :
    2. 'yourclasshere' extends '' and I just overrided 'onPacketSending'. With the PacketEvent I just did what SteelPhoenix said : add the player back then remove him again.
    #3 cricri_21, Jul 20, 2020
    Last edited: Jul 31, 2020