Adding prefixes to players names on tab?

Discussion in 'Spigot Plugin Development' started by TimeVisualSales, May 23, 2015.

  1. Hi there, How could I set a players prefix to be shown on the tab? I tried creating a scoreboard then teams but it didn't work. Anyone know how I can do it?
  2. Doesn't player.setDisplayName("[Prefix] " + player); do this?
    • Agree Agree x 1
    • Informative Informative x 1
  3. No, that only sets the players name tag. I want it so that you can have a prefix or change the colour of the players name in the tab.
  4. What he said √ ^

    It doesn't set the nametag. It sets the player name in the tab man. If you want to set colors just use the Chat Colors.
    • Agree Agree x 1
  5. @CreeperAnatomy He wants to set a player prefix, and his name with colors, but in the tab.
  6. p#setPlayerListName("&c[PREFIX] " + p.getName()); should do the trick for the tab. Not for the player name tags though, if that's what your looking for.
    • Agree Agree x 1
    • Winner Winner x 1
  7. Yes, but you have the 16 character limit. Ill get my code I used to set player names just a secod
  8. You should be able to get the gist of wht the code does, the whole thing is for my server and has other things accoisated wit it.

    Code (Text):

    Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();

            Iterator<String> keySetIterator = ranks.Instance.rankColor.keySet().iterator();
                while (keySetIterator.hasNext()) {
                String rank =;
                String formattedRank = ranks.Instance.makeRankName(rank, true) + " " + ChatColor.RESET;
                if(!(rank == "guest"))
                    board.getTeam(rank).setSuffix(ChatColor.DARK_RED + " ★ ");
                board.getTeam("afk"+rank).setSuffix(ChatColor.DARK_RED + " AFK ");
            final String rankNTitle = ranks.Instance.getRank(p).toString();
            final Player titleP = p;
            for (Player o : Bukkit.getOnlinePlayers()) {
                String rankN = ranks.Instance.getRank(p).toString();

                String oRankN = ranks.Instance.getRank(o).toString();

                if (afk.contains(o.getName())) {
                    oRankN = "afk" + oRankN;
                if (a) {
                    rankN = "afk" + rankN;




    Ill try and explain what you need to do for every time you want to update the scoreboard
    Grab a new scoreboard and set the player to be that scoreboard.
    For every different prefix you want, register a new team on that scoreboard and set the prefix to be what you want.
    loop through all players on the server, and check what prefix they should have, then get the scoreboard and add them to that prefix team. and the final step get the original players scoreboard, get the prefix you want to add them to and add them to that player.

    Sorry if its complicated, but yeah that what you need to do.
  9. I've done this but when I join my bungeecord network it doesn't update after 4 seconds...
    Code (Text):
            Team t = sb.getTeam("default");
            if(t == null){
                t = sb.registerNewTeam("default");
            for(Player all : Bukkit.getOnlinePlayers()){
  10. For some reason, it wasn't working because of my scoreboard.
  11. So is it working now?
  12. JamesJ


    Code (Text):

           Team team = s.getTeam("teamname");
            if(team == null){
                team = s.registerNewTeam("teamname");
            team.setPrefix(ChatColor.translateAlternateColorCodes('&', "&a[Prefix]"));
    Will show like this in tab:
    [Prefix] JamesJ
    • Winner Winner x 1
  13. Thats not working for me
  14. Is it hooked into your prefix / permissions plugin?
  15. Most of that is incorrect, lmao.
    • Agree Agree x 1
  16. No
  17. JamesJ


    It's amazing how wrong you are.
    • Agree Agree x 3
    • Funny Funny x 2
  18. Hook it into your plugin that's using the prefix.

    That's why it's not reading the code correctly.