Scoreboard Questions

Discussion in 'Spigot Plugin Development' started by zDrakon, May 29, 2015.

  1. Code (Text):
        public void setupScoreboard(Player p) {
            ScoreboardManager sm = Bukkit.getScoreboardManager();

            Scoreboard onJoin = sm.getNewScoreboard();

            Objective o = onJoin.registerNewObjective("dash", "dummy");

            o.setDisplaySlot(DisplaySlot.SIDEBAR);

            o.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "[KSS]");

            Score killcount = null;

            killcount = o.getScore("Kills");
            killcount.setScore(this.getConfig().getInt(
                    "Users." + p.getUniqueId().toString() + ".killstreak"));
           
            p.setScoreboard(onJoin);
        }
    There is some of my code, I want to have the scoreboard look like

    [KSS]
    Killstreak: 0

    Simple right? One problem I don't know how to make it refresh and i dont know if this is for individual players... or a global scoreboard... please someone help a noob?
     
  2. It's individual for the player for which you set the scoreboard (Player#setScoreboard)
    To refresh the scoreboard simply use Player#getScoreboard, set the score again and set the scoreboard for the player again, too (Player#setScoreboard)
     
  3. Do i put it in a for loop of getScoreboard() and setScoreboard()??
     
  4. setScoreboard(); has to be in the for loop, but remember to update the variables as well.

    You can do a scheduleSyncRepeatingTask which executes setupScoreboard(player);