Updating Scoreboard without blinking.

Discussion in 'Plugin Development' started by WingedMLGPro, May 16, 2015.

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

    WingedMLGPro

    Hey Everyone!
    I know i can make a Scoreboard update without blinking by setting the score when it needs to but i dont know how i would do it with my Scoreboard.
    Right now i just have a runnable where it updates every second.
    I want to change it so it doesn't blink and updates when it only needs to.
    Here is my code:
    Code:
    public class Scoarboard implements Listener {
        @EventHandler
        public void onJoin(PlayerJoinEvent e){
    
            final Player p = e.getPlayer();
            final SwiftyPlayer user = new SwiftyPlayer(p);
            final StatsAPI stats = new StatsAPI();
    
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(TheMain.getInstance(), new Runnable() {
                public void run() {
    
                    ScoreboardManager manager = Bukkit.getScoreboardManager();
    
                    final Scoreboard board = manager.getNewScoreboard();
    
                    Objective obj = board.registerNewObjective("test", "test1");
                    obj.setDisplaySlot(DisplaySlot.SIDEBAR);
                    obj.setDisplayName("§5§lSWIFTY PVP");
    
                    Score score1 = obj.getScore("§6Rank: ");
                    score1.setScore(9);
    
                    Score score10 = obj.getScore(user.getRank());
                    score10.setScore(8);
    
    
                    Score score2 = obj.getScore("§6OnlinePlayers:");
                    score2.setScore(7);
    
                    Score score8 = obj.getScore("§5"+Bukkit.getServer().getOnlinePlayers().length);
                    score8.setScore(6);
    
                    Score score3 = obj.getScore("§6Server: ");
                    score3.setScore(5);
    
                    Score score9 = obj.getScore("§5"+p.getServer().getServerId());
                    score9.setScore(4);
    
                    Score score4 = obj.getScore("§6Kills: "+"§5"+stats.getKills(p));
                    score4.setScore(3);
    
                    Score score5 = obj.getScore("§6Deaths: "+"§5"+stats.getDeaths(p));
                    score5.setScore(2);
    
                    Score score6 = obj.getScore("§6KS: "+"§5"+stats.getKillStreak(p));
                    score6.setScore(1);
    
                    Score score11 = obj.getScore("§6HKS: §5"+stats.getHKillStreak(p));
                    score11.setScore(0);
    
                    p.setScoreboard(board);
                }
            }, 20, 40);
        }
    }
    Thanks,
    WingedMLGPro
     
  2. Offline

    Gater12

  3. Offline

    1Rogue Retired Staff

    Keep your eyes open
     
Thread Status:
Not open for further replies.

Share This Page