Weird Scoreboard/Objective Issue

Discussion in 'Plugin Development' started by Drkmaster83, May 11, 2014.

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

    Drkmaster83

    Code:
    for(Player p : getServer().getOnlinePlayers()) {
        Scoreboard score = p.getScoreboard();
        Objective objective = score.getObjective("Hub") == null ? score.registerNewObjective("Hub", "dummy") : score.getObjective("Hub");
        String displayName = "Welcome, " + p.getName() + "!";
        objective.setDisplayName("\u00A76\u00A7l" + displayName); //Would normally have the first color protocol be changing, but took it out for less confusion for thread responders
    }
    
    Here's the issue:
    If I run this code with two people online, one of the players will see the other player's name on his scoreboard. The slot is automatically DisplaySlot.SIDEBAR, so don't ask. So, two players, "Drkmaster83", and "DesecratedAngel", and Drkmaster83 will end up seeing "Welcome, DesecratedAngel!" while DesecratedAngel sees "Welcome, DesecratedAngel!". Why is this? Doesn't p.getScoreboard() return the Scoreboard associated with that player's scoreboard object, not the server scoreboard?

    Edit: Upon even further examination, it will also set all players' scoreboards to the display name of the last player that joined. While this happens, it also appears that the scoreboard rarely flickers to the correct scoreboard with the correct name.
     
  2. Offline

    Rocoty

    Drkmaster83 It seems all the players have the same scoreboard registered on them then. Try making a new scoreboard for each player
     
  3. Offline

    Drkmaster83

    The problem with that is that that creates a flickering or jittering effect when I fill the scoreboard and objective with data, and that's not attractive at all. And I'm not storing Scoreboard objects in a HashMap just so that I can do this.

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page