It just flashes everytime it updates and it is quite annoying. Code: public void onEnable() { getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ public void run(){ updateScoreboards(); } }, 20, 20); } Code: public void updateScoreboards(){ for(Player p : getServer().getOnlinePlayers()){ ScoreboardManager manager = getServer().getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); Objective stats = board.registerNewObjective("stats", "dummy"); stats.setDisplayName("§3Player Stats"); stats.setDisplaySlot(DisplaySlot.SIDEBAR); Score name = stats.getScore(p.getName()); name.setScore(9); Score Kills = stats.getScore("§6Kills: "); Kills.setScore(8); Score kills = stats.getScore("§f§f§l" + getKills(p)); kills.setScore(7); Score space2 = stats.getScore("§e "); space2.setScore(6); Score Deaths = stats.getScore("§6Deaths: "); Deaths.setScore(5); Score deaths = stats.getScore("§f§l" + getDeaths(p)); deaths.setScore(4); Score space3 = stats.getScore("§4 "); space3.setScore(3); Score KD = stats.getScore("§6K/D: "); KD.setScore(2); Score kd = stats.getScore("§f§l" + getKD(p)); kd.setScore(1); p.setScoreboard(board); } }
micrlink Well, you are making a new scoreboard every single time, so the client will show the change in scoreboards. Don't make new scoreboards every second, store the scoreboard's per player in a Map and update those.
Every update will cause a flash because you're sending a brand new scoreboard each time. You need to update an existing scoreboard rather than making new ones all the time.
xTigerRebornx he doesn't have to use Maps for this, he can just check if a player has a scoreboard it he does, he needs to get it and update the scores, otherwise create a new scoreboard and do the above. micrlink
xTigerRebornx how do I do that That sounds easier, but how would I update a score that is a variable? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
micrlink Scoreboard scoreboard = player.getScoreboard(); Objective obj = scoreboard.getObjective("stats"); obj.getScore(String).setScore(Integer); and you don't have to set the scoreboard again
viper_monster And what happens if something else were to change the scoreboard? He'd be changing some random scoreboard and its values rather then the scoreboard he wants to be changing.