Solved Clearing scoreboard?

Discussion in 'Spigot Plugin Development' started by IdkMan, Jun 27, 2018.

Thread Status:
Not open for further replies.
  1. Hello guys, I just wonder if this is really needed:
    Code (Java):

    protected void clearScoreboard(Scoreboard scoreboard) {
      for(Objective obj : scoreboard.getObjectives()){
                obj.unregister();
            }
      for(Team team : scoreboard.getTeams()) {
       team.unregister();
      }
     }
     
    (Found this code in a open license plugin - this plugin was using this method to clear the scoreboard and declare new scoreboard using the method described below..)

    Can't I achieve the same result using:
    Code (Java):
    board = plugin.getServer().getScoreboardManager().getNewScoreboard();
    player.setScoreboard(board);
    ?
     
    #1 IdkMan, Jun 27, 2018
    Last edited: Jun 27, 2018
  2. And add this:
    Code (Java):
    player.setScoreboard(scoreboard);
    Do NOT use player for scoreboard but this:
    Code (Java):
    Scoreboard scoreboard = plugin.getServer().getScoreboardManager().getNewScoreboard();
     
    • Like Like x 1
  3. also wrong section :p the right section is on Spigot Plugin Development
     
  4. How can i move thread?
     
  5. Use report button.
     
    • Like Like x 1
  6. foncused

    Moderator Patron

    Moved to Spigot Plugin Development.
     
  7. Yeah, the method seems a bit redundant. In the grand scheme, as long as you set the player's scoreboard to a new scoreboard, even if it does get saved to disk (not saying if it does definitively or not), the amount of storage space used to store an 'empty' scoreboard would be neglible, even at a large scale. If we're assuming it doesn't get saved to a hard disk, then it's RAM and gets GC'd.
     
    • Winner Winner x 1
Thread Status:
Not open for further replies.