Skeleton team object. TODO: Make @mbax come and show me how to rewrite entire API. Also interface

This commit is contained in:
md_5 2013-03-23 20:41:35 +11:00
parent c97f113497
commit fd062503e1
4 changed files with 56 additions and 7 deletions

View File

@ -16,5 +16,5 @@ public class Objective
/** /**
* Value of the objective. * Value of the objective.
*/ */
private final String value; private final String value; // displayName
} }

View File

@ -12,11 +12,11 @@ public class Score
/** /**
* Name to be displayed in the list. * Name to be displayed in the list.
*/ */
private final String itemName; private final String itemName; // Player
/** /**
* Unique name of the score. * Unique name of the score.
*/ */
private final String scoreName; private final String scoreName; // Score
/** /**
* Value of the score. * Value of the score.
*/ */

View File

@ -24,13 +24,15 @@ public class Scoreboard
/** /**
* Objectives for this scoreboard. * Objectives for this scoreboard.
*/ */
@Getter(AccessLevel.NONE)
private final Map<String, Objective> objectives = new HashMap<>(); private final Map<String, Objective> objectives = new HashMap<>();
/** /**
* Scores for this scoreboard. * Scores for this scoreboard.
*/ */
@Getter(AccessLevel.NONE)
private final Map<String, Score> scores = new HashMap<>(); private final Map<String, Score> scores = new HashMap<>();
/**
* Teams on this board.
*/
private final Map<String, Team> teams = new HashMap<>();
public Collection<Objective> getObjectives() public Collection<Objective> getObjectives()
{ {
@ -42,18 +44,36 @@ public class Scoreboard
return Collections.unmodifiableCollection( scores.values() ); return Collections.unmodifiableCollection( scores.values() );
} }
public Collection<Team> getTeams()
{
return Collections.unmodifiableCollection( teams.values() );
}
public void addObjective(Objective objective) public void addObjective(Objective objective)
{ {
Preconditions.checkArgument( !objectives.containsKey( objective.getName() ), "Objective %s already exists in this scoreboard", objective ); Preconditions.checkNotNull( objective, "objective" );
Preconditions.checkArgument( !objectives.containsKey( objective.getName() ), "Objective %s already exists in this scoreboard", objective.getName() );
objectives.put( objective.getName(), objective ); objectives.put( objective.getName(), objective );
} }
public void addScore(Score score) public void addScore(Score score)
{ {
Preconditions.checkArgument( !scores.containsKey( score.getItemName() ), "Score %s already exists in this scoreboard", score ); Preconditions.checkNotNull( score, "score" );
Preconditions.checkArgument( !scores.containsKey( score.getItemName() ), "Score %s already exists in this scoreboard", score.getItemName() );
scores.put( score.getItemName(), score ); scores.put( score.getItemName(), score );
} }
public void addTeam(Team team)
{
Preconditions.checkNotNull( team, "team" );
Preconditions.checkArgument( !teams.containsKey( team.getName() ), "Team %s already exists in this scoreboard", team.getName() );
}
public Team getTeam(String name)
{
return teams.get( name );
}
public void removeObjective(String objectiveName) public void removeObjective(String objectiveName)
{ {
objectives.remove( objectiveName ); objectives.remove( objectiveName );
@ -63,4 +83,9 @@ public class Scoreboard
{ {
scores.remove( scoreName ); scores.remove( scoreName );
} }
public void removeTeam(String teamName)
{
teams.remove( teamName );
}
} }

View File

@ -0,0 +1,24 @@
package net.md_5.bungee.api.scoreboard;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import lombok.Data;
@Data
public class Team
{
private final String name;
private String displayName;
private String prefix;
private String suffix;
private byte friendlyMode;
private Set<String> players = new HashSet<>();
public Collection<String> getPlayers()
{
return Collections.unmodifiableSet( players );
}
}