Solved Name tag colors scoreboard team

Discussion in 'Spigot Plugin Development' started by Extremelyd1, Jun 3, 2020.

  1. Is it not possible anymore to color peoples name tags by setting the prefix of their scoreboard team to be a ChatColor? How else is it possible to color peoples name tags, only with NMS packets?
  2. Yeah, it is possible, as I understood you. With a Scoreboard make teams and add a color to that team as prefix. When you want, add the player to that team and I think that he'll have the color name tags.
    • Agree Agree x 1
  3. Well I thought the same, the following does not work:
    While the following *does* work:
    Team#setPrefix("§4RED ");
    And will yield the prefix as shown, after which the player name is displayed in white again.
    Which led me to believe that this might not be possible anymore.

    Note that we are talking about version 1.15.2.
  4. You can change player names above head only using the playerinfodata packet, I don't think it affects the chat, but you can change the color of the name above head only if that is what you are looking to achieve. I use it here when I change the player name and it is color code supported, and it is also in this thread

    Code (Java):

    protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Play.Server.PLAYER_INFO) {

            public void onPacketSending(PacketEvent event) {
            if (event.getPacket().getPlayerInfoAction().read(0) != EnumWrappers.PlayerInfoAction.ADD_PLAYER) {

            PlayerInfoData pid = event.getPacket().getPlayerInfoDataLists().read(0).get(0); //get the original packet to set the skin later        
    String finalName = ChatColor.GOLD + pid.getProfile().getName();
            PlayerInfoData newPid = new PlayerInfoData(pid.getProfile().withName(finalName), pid.getLatency(),
                pid.getGameMode(), WrappedChatComponent.fromText(name));

            newPid.getProfile().getProperties().putAll(pid.getProfile().getProperties()); //Set the skin of the new PlayerInfoData to the original skin from the original PlayerInfoData

            event.getPacket().getPlayerInfoDataLists().write(0, Collections.singletonList(newPid)); //Overwrite the packet

    Code (Java):

    public void onJoin(PlayerJoinEvent e) {

        Player p = e.getPlayer();
        PlayerInfoData pid = new PlayerInfoData(WrappedGameProfile.fromPlayer(p), 1,
            EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("whatever_string"));

        WrapperPlayServerPlayerInfo wpspi = new WrapperPlayServerPlayerInfo();
        for (Player o : Bukkit.getOnlinePlayers()) {
            if (o.equals(p)) {

        new BukkitRunnable() {

            public void run() {


            for (Player o : Bukkit.getOnlinePlayers()) {
                if (o.equals(p)) {
        }.runTaskLater(main, 1L);
    In case the player's name is the maximum length, you would need to set part of the player's name in the prefix slot.

    It requires ProtocolLib, and doesn't affect the name for commands or anything like auto tab. I'm just throwing options out there, but there is probably a much better way of doing this. And just be aware there may be issues if the player's name is the max length, in which case you will have to separate it into prefixes, name tag, and suffix
  5. Thanks for you detailed answer! This helps a lot.
  6. Just be careful because the player's name can be the max length so you might get errors
  7. #7 KingAlterIV, Jun 7, 2020
    Last edited: Jun 7, 2020
  8. Apparently the Team#setColor method does in fact color the name tags of players the given color. I cannot seem to recall this method existed in previous versions. But for future reference, this is a nice heads-up.