Solved Scoreboard Score value not adding for other players

Discussion in 'Plugin Development' started by CoderMusgrove, Mar 31, 2014.

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

    CoderMusgrove

    I am developing a plugin for a person, and I haven't ever really used scoreboards. Mostly everything is working fine, except for players that already have a scoreboard, they don't get the new value. I have arenas set up and each individual arena has its own scoreboard.

    So here in my GameScoreboard.java class, this is what I do to add a value, or a player score:
    Code:java
    1. public void addPlayer(Player p) {
    2. Score s = objective.getScore(p);
    3. s.setScore(0);
    4. p.setScoreboard(sb);
    5. }

    I have tried checking to see if it's the same scoreboard, and it is. I just don't get what I'm missing. I followed tutorial on how to do this correctly, to see if I missed anything, but I didn't see a problem with it.

    To recover what the problem is, when I add a player to a specific scoreboard, the player that was added has all of the values they need. On the other hand, if there was a player with that scoreboard already, they don't get the updated version.

    What am I doing wrong? If you need to see the rest of my code in my GameManager.java class, here it is:
    Show Spoiler
    Code:java
    1. public class GameScoreboard {
    2.  
    3. private static ScoreboardManager sbm;
    4. private Arena a;
    5. private Scoreboard sb;
    6. private Objective objective;
    7.  
    8. public GameScoreboard(Arena a) {
    9. sbm = Bukkit.getScoreboardManager();
    10. sb = sbm.getNewScoreboard();
    11. this.a = a;
    12. init();
    13. }
    14.  
    15. private void init() {
    16. objective = sb.registerNewObjective("SticksAndStones", "SticksAndStones");
    17. objective.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Sticks and Stones");
    18. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    19. }
    20.  
    21. public void addPlayer(Player p) {
    22. Score s = objective.getScore(p);
    23. s.setScore(0);
    24. p.setScoreboard(sb);
    25. }
    26.  
    27. public void removePlayer(Player p) {
    28. sb.resetScores(p);
    29. p.setScoreboard(sbm.getNewScoreboard());
    30. }
    31.  
    32. public void setPlayerScore(Player p, int score) {
    33. if (score > 0) objective.getScore(p).setScore(score);
    34. else objective.getScore(p).setScore(0);
    35. }
    36.  
    37. public Arena getArena() {
    38. return a;
    39. }
    40.  
    41. public Scoreboard getScoreboard() {
    42. return sb;
    43. }
    44. }
    45.  

     
  2. Offline

    xXSniperzzXx_SD

    CoderMusgrove Set the score to 1 then you can set it to 0, if you don't it doesn't actually set
     
    CoderMusgrove likes this.
  3. Offline

    CoderMusgrove

Thread Status:
Not open for further replies.

Share This Page