1.16.x Remove name from player list (tab)

Discussion in 'Spigot Plugin Development' started by HitCoder, Oct 17, 2020.

  1. Hi Spigot dev forums

    This is probably a dumb question but it's something I cannot wrap my head around.

    For context: I run a server for my own little friend group, and me and one of my friends wants to do a prank involving pretending to be Herobrine, but hiding the name and disabling join messages etc.
    Obviously everyone would figure it's a prank but the idea is that everyone would find it super funny even with not being in on it.

    That aside, I have the join messages being switched off for Herobrine working, and I have the name tag hidden, the code is a shoddy mess as it's not really a serious plugin and it's more of a joke, but the only thing I can't get my head around is doing something about the user name in the list of players.

    I stumbled across this thread on the bukkit forums which is from 2012, and i tried using the code from the example plugin with the latest 1.16 ProtocolLib to achieve what I wanted, but the name is not removed from the list. I attempted implementing it where when the username "Herobrine" is hard-coded into the plugin, which didn't work. I also tried setting the join listener to add the user to the list of players this example uses which also didn't work.

    After this I decided "okay let's try a messier approach", and attempted to make it so that when the user "Herobrine" joins the world, it changes his name in the player list to copy someone else's player list name who is already on the server, so that if anybody notices a duplicated name it could just be passed off as "a glitch" or similar. This isn't really optimal though and is probably more of a last resort for it.

    I was also hoping to provide a /vanish command or similar to herobrine and added essentials to achieve this but essentials broke a bunch of my permissions and i didn't have the energy to fix them, in addition to trying supervanish but that broadcasts a fake join and leave message upon using the command, and forking it gave me a bunch of random code errors that I couldn't figure out why they were there, so that was out of the question.

    Sorry this post is kind of big, especially for a joke, I just don't understand why i've had difficulty getting this to work. The plugins i have installed are: BlockLocker, CoreProtect, DiscordSRV, DropHeads, Dynmap, GSit, Hat, LuckPerms, ProtocolLib, SkinsRestorer, Spark, Tradeshop

    So TL;DR I wanna know if it's possible at all to just outright remove a name from the player list or if it just doesn't work any more lol
  2. Pretty sure tab list checks can see. I could be wrong, stopped trying to hide years ago. Fear me I have a ban hammer :p
    There are multiple 'vanish' plugins available, find one that works for your purposes ;) Have fun pranking your friends, I always do ;)
  3. Maybe PacketPlayOutPlayerInfo is what you need, but I haven't tested, I'm not sure it would work
  4. is use
    Code (Java):
    connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc));
    for my npcs which are EntityPlayer's
  5. Since this is under the plugin development forum, I'm going to assume you want to code this. If not, check out SuperVanish.

    when running the command /hideme (or /vanish, or whatever you want to call it), make a for loop that loops through all online players and hides the executor (Preferably in a variable like this: Player player = (Player) sender;) from all of the online players, like such:

    Code (Java):
    for (Player onlinePlayers : Bukkit.getOnlinePlayers()) {
    For changing the player's name in the player list, do this:

    Code (Java):
  6. Thanks, I found out that SuperVanish actually had a setting to disable the fake join and leave messages so I'm using that so that "herobrine" can hide from sight if necessary. I have 2 other friends in on it and one of them will be my partner in crime so we can cover for each other :p

    To my knowledge if you completely remove the player and it's a real player it doesn't render them at all, sadly.

    I ended up using supervanish paired with my own plugin so that when herobrine is visible his name is not. my plugin just dupes a name which we can shrug off as "a glitch" and it's all working fine. I don't think it's possible to hide the name from the list without making the player just completely disappear from rendering sadly.

    In case any person passing by is interested how it works, here's the code that I have. - Oh also I implemented a side thing for varied join messages because my friends noticed something odd with join messages because i messed something up (accidentally forgot to make the colour yellow and forgot to switch "joined" to "left" on the leave event and people noticed), so I came up with "oh I'm trying to learn how to make spigot plugins because i'm curious what I can achieve with a plugin" LOL

    Code (Java):

    public class HerobrinePrank extends JavaPlugin {
        // Fired when plugin is first enabled
        private HidePlayerList playerList;
        public void onEnable() {
            // create the listener
            getServer().getPluginManager().registerEvents(new HerobrineJoinListener(), this);
        // Fired when plugin is disabled
        public void onDisable() {
            // debug message
            System.out.println("test plugin was disabled");
    Code (Java):

    public class HerobrineJoinListener implements Listener{
        // join messages :)
        String joinMessages[] = new String[] {
                "<name>, you're late!",
                "No need to fear, <name> is here! - did you bring the pizza?",
                "<name>'s back",
                "<name> joined the game...",
                "<name> is here for revenge!",
                "Whoa <name>, you got the whole squad laughing.",
                "<name> joined! poggers!",
                "<name> joined the game",
                "Hi <name>",
                "Erm... Hello there... <name>..."
        // leave messages :(
        String leaveMessages[] = new String[] {
                "<name> is gone now...",
                "<name>... no... please come back...",
                "<name>... isn't... here... any more...",
                "<name> is cancelled",
                "<name> left the game",
                "<name> left...",
                "Bye <name>",
                "Goodbye <name>...",
                "Erm... Yeah... <name> left..."
        // when a player joins, copy name of first player in player list
        public void onPlayerJoin(PlayerJoinEvent event)
            Player p = event.getPlayer(); //Player to hide name

            Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
            Team team = board.registerNewTeam("pl");
            team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
            String n = "";
            // using an iterator just in case only herobrine is in the game so that it doesn't just crash and because i'm lazy
            for(Player p2 : Bukkit.getServer().getOnlinePlayers()) {
                if (!p2.getName().toLowerCase().equals("herobrine")) {
                    n = p2.getName();
            // set up join message but only print it if the player is NOT herobrine
            if (!event.getPlayer().getName().equals("Herobrine")) {
                int r = new Random().nextInt(joinMessages.length);
                event.setJoinMessage(ChatColor.YELLOW+joinMessages[r].replace("<name>", p.getName()));
            }else {
                // if the player is herobrine then change his name
        // when the player leaves send a leave message unless it's herobrine
        public void onPlayerLeave(PlayerQuitEvent event) {
            Player p = event.getPlayer();
            if (!p.getName().equals("Herobrine")) {
                int r = new Random().nextInt(leaveMessages.length);
                event.setQuitMessage(ChatColor.YELLOW+leaveMessages[r].replace("<name>", p.getName()));
    sorry if the join and leave messages are weird it's just the sense of humour me and my friends have ;P

    anyway thanks for the help y'all I appreciate it, if anyone has any solution for removing names from the player list tho without terminating the rendering of the player on the other clients then do let me know. otherwise thank you all and hope you all have a nice day <3
    #6 HitCoder, Oct 18, 2020
    Last edited: Oct 18, 2020