Solved Clearing Scoreboard Scores

Discussion in 'Spigot Plugin Development' started by Skifty, Feb 7, 2020.

  1. Hey!
    So I want to be able to edit a ScoreBoard displayed on the sidebar without any flickering
    I currently have an Objective to which I just add scores with the stuff I need to be displayed like so:
    Code (Text):
    private void setEntries(Player p) {
            List<String> entries = plugin.getConfig().getStringList("ScoreboardEntries");
            int i = 0;
            for (String entry : entries) {

                Economy econ = plugin.economy;
                entry = entry.replace("{Rang}", plugin.luckApi.getRang(p)).replace("{Money}", Double.toString(econ.getBalance(p)));
                //System.out.print(entry);

                objective.getScore(Color(entry)).setScore(i);
                i--;
            }
        }
    Code (Text):
    boardName = plugin.getConfig().getString("Boardname");
                objective = sb.getObjective(Color(boardName)) == null ? sb.registerNewObjective(Color(boardName), "dummy") : sb.getObjective(Color(boardName));
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    When I update the scoreboard with new Information (so for example let's say his group changed) it just gets added with the same score (which makes sense because I didn't remove the old one).
    So how would I remove all the old scores to set them again?
    I already tried the following:
    Code (Text):
    //Makes it flicker

    //        objective.unregister();
    //        objective = sb.registerNewObjective(Color(boardName), "dummy");
    //        objective.setDisplaySlot(DisplaySlot.SIDEBAR);
         
    // Throws UnsupportedOperationException

    //Set<Score> scores = sb.getScores(p);
            //sb.getScores(p).removeAll(scores);

     //Nothing happens

            //sb.resetScores(p);
            //sb.resetScores(boardName);
            //sb.resetScores(objective.getName());
     
    #1 Skifty, Feb 7, 2020
    Last edited: Feb 7, 2020
    • Agree Agree x 1
  2. Whoops, guess I didn't find that, thanks a lot