Help - Weird Name Tag Issue

Status
This thread has been locked.

SimonM

Java Developer
Premium
Feedback score
12
Posts
190
Reactions
58
Resources
0
Hi there,
So I am trying to create a name tag feature for my plugin and this is what I am using.

getScoreboard Method:
Java:
public Scoreboard getScoreboard() {
    Scoreboard scoreboard = getPlayer().getScoreboard();
    if (scoreboard == null)
        getPlayer().setScoreboard(scoreboard = Core.getCore().getServer().getScoreboardManager().getNewScoreboard());
    return scoreboard;
}

setNameTag Method:
Java:
public void setNameTag() {
    Scoreboard scoreboard = getScoreboard();
    scoreboard.getTeams().forEach(Team::unregister);
    Team team = scoreboard.registerNewTeam(rank.getName());
    team.setPrefix(rank.getPrefix());
    team.addPlayer(getPlayer());
    team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
}

Now this works fine when the first player joins the server but, when the second person joins the server, their name tag gets set but the first player's name tag gets set back to normal and I have 0 idea why. Can anyone help? Thank you.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

tchristofferson

Developer
Premium
Feedback score
2
Posts
2
Reactions
12
Resources
0
Players can only see the prefix of the team if they are on the same scoreboard. You are creating a new scoreboard for each player.
 

SimonM

Java Developer
Premium
Feedback score
12
Posts
190
Reactions
58
Resources
0
Players can only see the prefix of the team if they are on the same scoreboard. You are creating a new scoreboard for each player.
I also use the sidebar scoreboards so if each player had the same scoreboard, it wouldn't work cause everything would have to be the same
 
Status
This thread has been locked.
Top