Player TabList Add/Remove people

Discussion in 'Plugin Development' started by iZanax, Oct 19, 2012.

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


    How can I remove and add people of the TabList?
    And can this only apply to specific players, So OP's can see all players and regular players not.
    I know there is a fuction called player.setPlayerListName(""), but this still reveal the connection emblem. And this appears to all players even OP's. So how is this possible? to hide/show players in the tablist for specific people?
  2. Since the latest recommended build, there is a PlayerChatTabCompleteEvent, it probably contains what you are looking for.
  3. Offline


    The event u ment is for AutoComplete names when someone press TAB while writing a name.

    The PlayerList with connections and stuff (when pressing TAB).
    That menu I want to adjust for some people.
    So some people has the full list of each online player, but some has only a couple people in the list.
  4. Offline


    I'm not sure if you can directly remove and/or add players, but you can set their tab list name. Like, player.setPlayerListName("1337");

    To "remove", I would have done: player.setPlayerListName("")
    And to "add", player.setPlayerListName(p.getName());

    (No reason to add, if the tab list name has not been modified previously)

    Edit: Sadly this won't remove the connection bar.
  5. Offline


    I did a bit more research. But one problem still remains, what VanishNoPacket seems to accomplish.
    The problem is that I can't hide real players. Only fake players who I add with this:
    (Remove fake players is just same packet with "false") <- no effect on real players

    ((CraftPlayer)p).getHandle().netServerHandler.sendPacket(new Packet201PlayerInfo("TEST"true10));
    // Name(String) , Show(boolean) , Conenction(int)
    So how can I make real players disappear in the Tab PlayerList?
  6. Offline

    dark navi

    If a player is hidden from another player (Player.hide) they will not show up on the list.
  7. Offline


    I don't want to hide players, just make them disappear on the list.

    ((CraftPlayer)p).getHandle().netServerHandler.sendPacket(new Packet201PlayerInfo("TEST", false, 10));
    This works for fake players, but if TEST is someone like a real player on the server, then the player won't get removed of the list. That is the problem i'm dealing with, what should be possible I hope, since other plugins might do this as well.

    This are the points i've found toward the solution, but the last part should be the solution, but it didn't.
    And player.hideplayer(p) will remove the player of the list, but also the player/avatar/skin visibility, so that isn't what I can use.
    So how can I remove a player of the list?
    • PHP:
              Packet201PlayerInfo packet = new Packet201PlayerInfo(playerfalse9999);

      Player pBukkit.getServer().getOnlinePlayers())

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  8. try using the protecall lib to blokck the outgoing packetplayerinfo and use your own handling
  9. Offline


    I've never worked with protical Lib and prefer to be a stand alone plugin, also it would take a lot of time to get into that API.
    And maybe looking into hindeplayer() function and see how they put players out of the list, but whole javadocs are down.
    : (


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  10. Offline



    Can someone help me out, if it's possible to remove real people of the tab playerlist ?
  11. Offline


    As ferrybig mentioned above, this is possible with ProtocolLib.

    While working on a solution, I discovered a bug in ProtocolLib that prevented the packet constructor from working. So you must use the latest version (1.4.2).

    You can download my solution here:

    To use it, simply add HidePlayerList to your project. Then, download and add a reference to ProtocolLib (or use Maven). Finally, ensure that your plugin depends on ProtocolLib in plugin.yml.

    Here's a small test plugin that uses HidePlayerList:
    1. public class HidePlayerMod extends JavaPlugin implements Listener {
    3. private HidePlayerList hidePlayer;
    5. @Override
    6. public void onEnable() {
    7. hidePlayer = new HidePlayerList(this);
    8. hidePlayer.register();
    9. }
    11. @Override
    12. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    14. // Error!
    15. if (args.length != 1) {
    16. sender.sendMessage("Invalid number of arguments!");
    17. return true;
    18. }
    20. Player player = getServer().getPlayer(args[0]);
    22. // Handle invalid player name
    23. if (player == null) {
    24. sender.sendMessage("Unable to find player " + args[0]);
    25. return true;
    26. }
    28. if (label.equalsIgnoreCase("hideplayerlist")) {
    29. if (hidePlayer.hidePlayer(player))
    30. sender.sendMessage("Hiding player " + player.getName());
    31. else
    32. sender.sendMessage("Player " + player.getName() + " was already hidden.");
    34. return true;
    36. } else if (label.equalsIgnoreCase("showplayerlist")) {
    37. if (hidePlayer.showPlayer(player))
    38. sender.sendMessage("Showing player " + player.getName());
    39. else
    40. sender.sendMessage("Player " + player.getName() + " is already visible.");
    42. return true;
    43. }
    45. return false;
    46. }
    48. @Override
    49. public void onDisable() {
    50. hidePlayer.cleanupAll();
    51. }
    52. }
    Jamesthatguy likes this.
  12. Offline


    Thanks a lot for helping Comphenix !

    But I don't get ProticolLib to work in my plugin.
    plugin.yml and add external Jar goes right,
    but from there i don't understand it anymore, and HidePlayerList stays unaccesable.

    Also I notice in your "small test plugin" that u use
    Why can't I use it on real players, and u can like u ment?
  13. Offline


    After adding to your project, change the "package" line at the top to the same as all your other java-files. Or, if you're using Eclipse, use the suggested "quick fix" when you hover over the red squiggly line.

    That's how you create a packet constructor, not a packet. A constructor (otherwise know as factory) is responsible for creating objects, often by accepting a set of parameters.

    It's the line further down that's responsible for creating packets:
    PacketContainer packet = playerListConstructor.createPacket(name, visible, getPlayerPing(player));
    You can also use the small test plugin without having to compile it. Just copy "HidePlayerListMod-1.0.0.jar" in "target" to your plugin-folder, along with ProtocolLib-1.4.2.jar. The command for hiding a player is "hideplayerlist [player name]", while calling "showplayerlist [player name]" will reverse it.
  14. Offline



    I've tested "HidePlayerListMod-1.0.0.jar", but something I need is that if I hide a player "hideplayerlist [player name]", , it should be only effect the sender. So the other player will still see him on the list.

    Also what I don't understand is that.
     Packet201PlayerInfo packet = new Packet201PlayerInfo(playerfalse9999);
    Player pBukkit.getServer().getOnlinePlayers())
    Doesn't work for players. And u use probably this packet (Packet201PlayerInfo) as well. So what makes it that ProticolLib is different to this packet sending that this code here ?
  15. Offline


    Ah, sorry.

    Well, it's not impossible to fix, though. All you need to do is put hiddenPlayers and visiblePlayers in a new class that you then put in a map of players. Then you have to change the for-loop sendListPacket to instead only send a packet to the player you want to "fool".

    The ProtocolLib version intercepts every Packet201PlayerInfo that is sent, and modifies them there.

    But have you tried using player.getPlayerListName(), instead of player.getName()? Your code ought, at least for a bit.
  16. Offline



    Didn't the trick, too bad, made it a lot easier for me.
    Working with ProticolLib will take a lot of time for me, but will make my plugin a lot nicer, so thanks a lot.

    Some other question about possibilities of ProticolLib:
    - Force someone to sneak
    - Force someone to Sneak with sleep animation (Player will lay on the floor, and move slowly, something like prone-ing)
    - Hide NameTag (Sneak but still be able to spring/walk?)
    - Send fake HungerLevel (so they are still able to run at 0 hungerlevel)

    Thanks agian.
  17. Offline


    Yeah, that's possible. There's even a plugin for it.

    I tried, but I don't think it's very likely. The problem is that the client will automatically align the player with the nearest floor, regardless of the player's actual position. It's really buggy - it looks like the player is falling through the floor.

    Perhaps you could use "fake" glass to fool the client into positioning the player above the floor, but that would be pretty ugly.
  18. Offline


    /me kicks ferrybig and Comphenix off the thread
    Just use the packets damnit. Works like a charm, and no more dependecies than needed
  19. Offline


    How to Modify Online players with Packet201?
    When I tried on 1.3.2 nothing happened, only with fake players.
    So yea.. ? How
  20. Offline


    Hey! Where did I go?!

    2. Packet201PlayerInfo packet = new Packet201PlayerInfo("Fireblast709", false, 0);
    3. ((CraftPlayer)t).getHandle().netServerHandler.sendPacket(packet);

    I am playing as an offline player, called 'derpface' (I needed a test subject)
  21. Offline


    You got to be kidding me, all these questions,
    and suddenly it works like u said.
    Hmm thanks anyways.

    Problem was that I was sending the packet directly when someone logs in, and it needed a short delay.
    But thanks a lot. 1 dependence less : )
    *Wishes that one day we can exceed the 16char limit, or Colorformat will be 0 chars (like at TagAPI)*

    Last Question about this topic.
    If I'm going to implement this packet.
    Will sending this packet be a heavy process for the server?
    Because there will be around 200 players and they all need to refresh the whole list if some join/leaves/otherthings.

    So is Packet201 a heavy process for servers when using this packetsending like 200-300 times in 1 tick ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  22. Offline


    Of course! This is pretty much like the difference between intercepting sent packets (TagAPI) or just re-sending them again. Sometimes it's better to intercept the original packets, as it will automatically handle complex setup like initializing armor and potion effects, along with re-initialization - for instance when a player has just teleported. While re-sending will often require you wait a bit, causing players to visibly change tag name for a moment.

    However, in this case the trade-off is exactly the reverse. The setup couldn't be simpler - it's just a single packet that will add or remove a name in the player list, and it's rarely re-initialized by the server.

    You may have to handle vanish plugins though, but there's usually an API in place.

  23. Offline


    in a few tests:
    • worst was 14ms
    • least worst was 6ms
    • packet already sent: 1ms
    based on one player, multiplied by 200. Measured in nanoseconds. So yea, probably not as exact, but its an estimate number. you probably have to send the packet at max 400 times per join (sending every players tag to the newly joined, and the newly joined's tag to all 200 players. Only if they have a tag, ofcourse.

    Nonetheless, yea a pretty heavy task
Thread Status:
Not open for further replies.

Share This Page