package team.unstudio.udpl.scoreboard;

import java.util.Collection;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;

public class ScoreboardWrapper {
	
	private final Scoreboard scoreboard;
	private final Objective objective;
	
	public ScoreboardWrapper(){
		scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
		objective = scoreboard.registerNewObjective("ScoreboardAPI", "dummy");
		objective.setDisplaySlot(DisplaySlot.SIDEBAR);
	}
	
	public Scoreboard getScoreboard(){
		return scoreboard;
	}
	
	public String getDisplayName(){
		return objective.getDisplayName();
	}
	
	public void setDisplayName(String name){
		objective.setDisplayName(name);
	}
	
	public void put(String key,int score){
		objective.getScore(key).setScore(score);
	}
	
	public void putAll(Map<String,Integer> map){
		map.entrySet().forEach(entry->objective.getScore(entry.getKey()).setScore(entry.getValue()));
	}
	
	public void remove(String key){
		scoreboard.resetScores(key);
	}
	
	public void removeAll(Collection<String> keys){
		keys.forEach(scoreboard::resetScores);
	}
	
	public int getScore(String key){
		return objective.getScore(key).getScore();
	}
	
	public void display(Player player){
		player.setScoreboard(getScoreboard());
	}
	
	public void reset(Player player){
		player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
	}
}

@@ -88,16 +88,41 @@
 l.Map;%0D%0A
+import java.util.Set;%0D%0A%0D%0A
 import o
@@ -1282,32 +1282,106 @@
 cores);%0D%0A%09%7D%0D%0A%09%0D%0A
+%09public Set%3CString%3E getKeys()%7B%0D%0A%09%09return scoreboard.getEntries();%0D%0A%09%7D%0D%0A%09%0D%0A
 %09public int getS

Update Scoreboard