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?
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.
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.
If you set the display for the players objective in the scoreboard to be the Tab list, you should get the desired affect. Relevant enum: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scoreboard/DisplaySlot.html
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.
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(); p.setScoreboard(board); Iterator<String> keySetIterator = ranks.Instance.rankColor.keySet().iterator(); while (keySetIterator.hasNext()) { String rank = keySetIterator.next(); String formattedRank = ranks.Instance.makeRankName(rank, true) + " " + ChatColor.RESET; board.registerNewTeam(rank).setPrefix(formattedRank); if(!(rank == "guest")) board.getTeam(rank).setSuffix(ChatColor.DARK_RED + " ★ "); board.registerNewTeam("afk"+rank).setPrefix(formattedRank); 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; } board.getTeam(oRankN).addPlayer(o); o.getScoreboard().getTeam(rankN).addPlayer(p); 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.
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"); t.setPrefix("default"); } t.addPlayer(p); for(Player all : Bukkit.getOnlinePlayers()){ all.setScoreboard(sb); }
Code (Text): Team team = s.getTeam("teamname"); if(team == null){ team = s.registerNewTeam("teamname"); } team.setPrefix(ChatColor.translateAlternateColorCodes('&', "&a[Prefix]")); team.addPlayer(e.getPlayer()); Will show like this in tab: [Prefix] JamesJ