Scoreboard update - Blinking

Discussion in 'Plugin Development' started by DACA, Oct 12, 2017.

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

    DACA

    Hi, in Sheduler i update scoreboard every 1 second with this method:
    Code:
        public static Scoreboard board;
        public static HashMap<String, String> map = new HashMap<>();
      
        public static void update(){  
          
            for (Player p : Bukkit.getOnlinePlayers()){
              
          board = p.getScoreboard();
          Objective o = board.getObjective("minigame");
        
          if (o == null) {
          o = board.registerNewObjective("minigame", "dummy");
          }
              
          board.resetScores(" §9Blue §7(§f§l0%§7)");
          board.resetScores(" §aGreen §7(§f§l0%§7)");
          board.resetScores(" §cRed §7(§f§l0%§7)");
          board.resetScores(" §eYellow §7(§f§l0%§7)");
          if (map.get("time") != null){
          board.resetScores(map.get("time"));
          }
        
          o.setDisplaySlot(DisplaySlot.SIDEBAR);
          o.setDisplayName("  §b§lMiniGame ");
          o.getScore("      ").setScore(15);
          o.getScore(" §9Blue §7(§f§l0%§7)").setScore(14);
          o.getScore(" §aGreen §7(§f§l0%§7)").setScore(13);
          o.getScore(" §cRed §7(§f§l0%§7)").setScore(12);
          o.getScore(" §eYellow §7(§f§l0%§7)").setScore(11);
          o.getScore("   ").setScore(10);
    
          o.getScore("       §f§l" + GameProgress.Minutes + "§7:§f§l" + GameProgress.Seconds).setScore(9);
          map.put("time", "       §f§l" + GameProgress.Minutes + "§7:§f§l" + GameProgress.Seconds);
        
          p.setScoreboard(board);
        
        }
        }
    But sometimes Scoreboard blinking, how to fix it? :)
     
    Last edited: Oct 12, 2017
  2. Offline

    Zombie_Striker

    @DACA
    Don't create a new scoreboard/objective every time you need to update it. That is why it is currently blinking. Instead, find the values that have changed, remove them from the existing scoreboard, and replace them with the values you want.
     
Thread Status:
Not open for further replies.

Share This Page