Skeleton team object. TODO: Make @mbax come and show me how to rewrite entire API. Also interface
This commit is contained in:
parent
c97f113497
commit
fd062503e1
@ -16,5 +16,5 @@ public class Objective
|
||||
/**
|
||||
* Value of the objective.
|
||||
*/
|
||||
private final String value;
|
||||
private final String value; // displayName
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ public class Score
|
||||
/**
|
||||
* Name to be displayed in the list.
|
||||
*/
|
||||
private final String itemName;
|
||||
private final String itemName; // Player
|
||||
/**
|
||||
* Unique name of the score.
|
||||
*/
|
||||
private final String scoreName;
|
||||
private final String scoreName; // Score
|
||||
/**
|
||||
* Value of the score.
|
||||
*/
|
||||
|
@ -24,13 +24,15 @@ public class Scoreboard
|
||||
/**
|
||||
* Objectives for this scoreboard.
|
||||
*/
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final Map<String, Objective> objectives = new HashMap<>();
|
||||
/**
|
||||
* Scores for this scoreboard.
|
||||
*/
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final Map<String, Score> scores = new HashMap<>();
|
||||
/**
|
||||
* Teams on this board.
|
||||
*/
|
||||
private final Map<String, Team> teams = new HashMap<>();
|
||||
|
||||
public Collection<Objective> getObjectives()
|
||||
{
|
||||
@ -42,18 +44,36 @@ public class Scoreboard
|
||||
return Collections.unmodifiableCollection( scores.values() );
|
||||
}
|
||||
|
||||
public Collection<Team> getTeams()
|
||||
{
|
||||
return Collections.unmodifiableCollection( teams.values() );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
objectives.remove( objectiveName );
|
||||
@ -63,4 +83,9 @@ public class Scoreboard
|
||||
{
|
||||
scores.remove( scoreName );
|
||||
}
|
||||
|
||||
public void removeTeam(String teamName)
|
||||
{
|
||||
teams.remove( teamName );
|
||||
}
|
||||
}
|
||||
|
24
api/src/main/java/net/md_5/bungee/api/scoreboard/Team.java
Normal file
24
api/src/main/java/net/md_5/bungee/api/scoreboard/Team.java
Normal 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 );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user