Organise the player tablist / Colored nameplates

Discussion in 'Plugin Help/Development/Requests' started by maux, Apr 25, 2016.

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


    Have you ever wondered how to organise the tab list/color the nameplates like most major servers? Most people have mentioned the use of PacketPlayOutPlayerInfo and a bunch of other creative ways, however I decided to go the all Bukkit route. Here is how you do such things!

    So first, you want to get the Team class from Bukkit:
        private Team team;
    After that, you want to make a constructer for the class like such:
    public PlayerNameplate(String plateName) {
            Scoreboard board = Bukkit.getServer().getScoreboardManager().getMainScoreboard();
            Team team = board.getTeam(plateName); // plateName = teamName
            if (board.getTeam(plateName) != null) { // checking if the team exists
       = team;
            } else {
                b.registerNewTeam(plateName); // registers the team if it doesn't exist
       = team;
    Now, here is where you can set the player's name tag. Make sure you don't put extraneous characters / characters > 16.
    team.addPlayer(player); // adds the player to the team that has the nameplate
    team.setPrefix(prefix); // sets the nameplate before the name
    team.setSuffix(suffix); // sets the nameplate after the name
    How the Minecraft team system works is that it changes the tab list as well. It orders the team names in alphabetical order. So the "plateName" part of the constructer is critical. So I used this code as an example in one of my projects. Here is the code:
    if (gamePlayer.hasGroup(Group.AMBER)) {
    gamePlayer.setName("§e" + gamePlayer.getName());
    gamePlayer.setNameplate("j", "§e", ""); // As you can see, "j" is going to be lower than "h" because that's
                                                                             // how alphabetical order works
    } else if (gamePlayer.hasGroup(Group.AMETHYST)) {
    gamePlayer.setName("§d" + gamePlayer.getName());
    gamePlayer.setNameplate("h", "§d", ""); // The plate's name is "h." This will result in team "h" being higher
                                                                              // than team "j."
    Now, let's put this to the test!:
    Screenshots (open)

    Screenshot from maux (he is in the team "h"):
    (if that image doesn't show, click:
    Screenshot from xdbfplaysgamesx (he is in the team "j"):
    (if that image also doesn't show, click:

    As you can see, it works!

    End Comments
    Thank you for taking your time reading this. I sincerely hope you learned something new. I am not good at explaining or doing tutorials. In fact, this is my first. I really wanted to show the Bukkit community, however, how to use such a cool feature to your advantage. There is more to things behind Bukkit's code then you think. (; If there are any problems you see, or improvements I should put upon this code or myself, please do tell me. I do want constructive criticism and excellent questions.
    crzassassin likes this.
  2. Offline


    Why not just do
    if(team==null){ //You're assigning it anyway .
  3. Offline


    That works! I just took the weird route. My bad
Thread Status:
Not open for further replies.

Share This Page