Attempt to track, and remove scoreboards at reconnect

This commit is contained in:
md_5
2013-03-16 21:06:28 +11:00
parent 156ea30c32
commit 54098c8989
5 changed files with 125 additions and 5 deletions

View File

@@ -1,7 +1,13 @@
package net.md_5.bungee.api.scoreboard;
import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
@Data
public class Scoreboard
@@ -18,9 +24,43 @@ public class Scoreboard
/**
* Objectives for this scoreboard.
*/
private final Collection<Objective> objectives;
@Getter(AccessLevel.NONE)
private final Map<String, Objective> objectives = new HashMap<>();
/**
* Scores for this scoreboard.
*/
private final Collection<Score> scores;
@Getter(AccessLevel.NONE)
private final Map<String, Score> scores = new HashMap<>();
public Collection<Objective> getObjectives()
{
return Collections.unmodifiableCollection( objectives.values() );
}
public Collection<Score> getScores()
{
return Collections.unmodifiableCollection( scores.values() );
}
public void addObjective(Objective objective)
{
Preconditions.checkArgument( !objectives.containsKey( objective.getName() ), "Objective %s already exists in this scoreboard", objective );
objectives.put( objective.getName(), objective );
}
public void addScore(Score score)
{
Preconditions.checkArgument( !scores.containsKey( score.getItemName() ), "Score %s already exists in this scoreboard", score );
scores.put( score.getItemName(), score );
}
public void removeObjective(String objectiveName)
{
objectives.remove( objectiveName );
}
public void removeScore(String scoreName)
{
scores.remove( scoreName );
}
}