1.17.x How to add EntityPlayer to the Team of Scoreboard?

Discussion in 'Spigot Plugin Development' started by Dawid, Jun 28, 2021.

Thread Status:
Not open for further replies.
  1. Hi, I need help with adding a fake EntityPlayer to the Team of Scoreboard.
    I know I should use a packets, but I don't know which packet I need to use right now :p
    In main I need make this to sort my tab list.
    If someone will help me it will save me a lot of time.

    Thanks in advance ;)
    #1 Dawid, Jun 28, 2021
    Last edited: Jun 28, 2021
  2. Is this about the tablist or the scoreboard sidebar?
    And could you be a bit more specific about the goal here?
  3. It is about tablist (Pressing TAB).
    I create a custom tablist with fixed players, but I specially don't know how to sort it. I have name of players in random slots of tablist.
  4. upload_2021-6-29_1-25-34.png

    You mean something like this?
  5. Code (Java):
    public void addNameToTabList(Player player, String displayName, int slot) throws NoSuchMethodException {
        GameProfile profile = new GameProfile(UUID.randomUUID(), getSlotName(slot));
        int ping = 1;
        EnumGamemode gamemode = EnumGamemode.b;
        IChatBaseComponent name = CraftChatMessage.fromString(displayName)[0];
        PacketPlayOutPlayerInfo.PlayerInfoData playerInfoData = new PacketPlayOutPlayerInfo.PlayerInfoData(profile, ping, gamemode, name);
        PacketDataSerializer data = new PacketDataSerializer(Unpooled.buffer());
        PacketPlayOutPlayerInfo.EnumPlayerInfoAction action = PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a;
        List<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
        Method method = action.getDeclaringClass().getDeclaredMethod("a", PacketDataSerializer.class, PacketPlayOutPlayerInfo.PlayerInfoData.class);
        data.a(list, (a,b)-> {
            try {
                method.invoke(action, a, b);
            } catch (IllegalAccessException | InvocationTargetException e) {
        PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(data);

    public String getSlotName(int slot) {
        String name = "00000";
        while (slot > 9) {
            name += "9";
        return name+slot;
    There you go. With this code you can add names at a specific tablist slot.
    But remember, this is just a case of a alphabetic order function.
    Feel free to look through some of my code I have written to create fake players with custom skins.
    Maybe it can provide you important information in your process NPC Util
    • Winner Winner x 1
  6. Thanks a lot, really good job. Perhaps in the future I will connect to your NPC Util;)

    Btw. if I will create in that solution a tablist, how to update that list?
    After using "addNameToTabList(...)" method the tablist will be duplicated :/
    Is the option to send the one packet, to clear player tablist? Or maybe I should update gameprofile and again send packet from "addNameToTabList(...)"?
    #6 Dawid, Jun 29, 2021
    Last edited: Jun 29, 2021
  7. To clear the tablist, you must store every gameprofile when you add it in the first place.
    then you add all the profiles to the same packet but this time with
    Code (Java):
    PacketPlayOutPlayerInfo.EnumPlayerInfoAction action = PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e;
    Which stands for 'REMOVE_PLAYER'. In this packet you only add the gameprofile and the rest you leave null or -1 according see https://wiki.vg/Protocol#Player_Info (4: remove player)
    • Useful Useful x 1
Thread Status:
Not open for further replies.