Scoreboard flickering

Discussion in 'Plugin Development' started by stefvanschie, Nov 21, 2015.

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

    stefvanschie

    Hey,

    Currently some of my users have been experiencing flickering in their scoreboard. I would like to know how I can resolve this. My current code:
    Code:
    YamlConfiguration messages = SettingsManager.getInstance().getMessages();
           
            List<String> list = messages.getStringList("global.buildScoreboardText"); //content of scoreboard
            for (String string : scoreboard.getEntries()) {
                scoreboard.resetScores(string);
            }
           
            int place = 0;
            for (int i = list.size(); i > 0; i--) {
                setScore(list.get(place)
                        .replace("%arena%", arena.getName())
                        .replace("%players%", arena.getPlayers() + "")
                        .replace("%max_players%", arena.getMaxPlayers() + "")
                        .replace("%subject%", arena.getSubject() != null ? arena.getSubject() : "?")
                        .replace("%seconds%", arena.getActiveTimer() == null ? "0" : arena.getActiveTimer().getSeconds() + "")
                        .replace("%blocks_placed%", arena.getPlot(player).getGamePlayer().getBlocksPlaced() + "")
                        .replaceAll("&", "ยง"), i);
                place++;
            }
            player.setScoreboard(scoreboard);
     
  2. Offline

    Scimiguy

    It's probably flickering because you're updating it too often
     
  3. Offline

    stefvanschie

    @Scimiguy I'm updating it once a second, is that too much?
     
  4. Offline

    Abstract97

    @stefvanschie Only update the board whenever one of the different types changes, also i would advise you update the actual scores, not setting the players scoreboard every second.
     
  5. Offline

    Konato_K

    @stefvanschie Setting the scoreboard of a player means destroying their previous scoreboard and making it again, this is why it flickers.
     
  6. Offline

    stefvanschie

    So I would need to make a list with the scores check if one of them is different and then only change that one?
     
  7. Offline

    Abstract97

    @stefvanschie Sort of yeah, i don't know why you would create a list, you can simply just override the original score.
     
  8. Offline

    stefvanschie

    How would I override the list? There can be the same numbers in the list multiple times, so I can't just do setScore().
     
Thread Status:
Not open for further replies.

Share This Page