Flashy Scoreboard

Discussion in 'Plugin Development' started by micrlink, Jul 6, 2014.

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

    micrlink

    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);
            }
        }
     
  2. Offline

    xTigerRebornx

    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.
     
  3. Offline

    RingOfStorms

    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.
     
  4. Offline

    viper_monster

    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
     
  5. Offline

    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.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    viper_monster

    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
     
  7. Offline

    micrlink


    Its not updating the score its updating the score name
     
  8. Offline

    xTigerRebornx

    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.
     
  9. Offline

    viper_monster

  10. Offline

    micrlink

    Look at the main post
     
Thread Status:
Not open for further replies.

Share This Page