Package org.spongepowered.api.scoreboard
Interface Scoreboard
-
public interface ScoreboardRepresents a scoreboard, which containsTeams andObjectives. The server has a default scoreboard, but eachPlayercan have their own scoreboard.- See Also:
- Scoreboards on the Minecraft Wiki
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceScoreboard.BuilderRepresents a builder to createScoreboardinstances.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddObjective(Objective objective)Adds the specifiedObjectiveto this scoreboard.static Scoreboard.Builderbuilder()Creates a newScoreboard.Builderto build aScoreboard.default voidclearSlot(Supplier<? extends DisplaySlot> slot)Clears anyObjectivein the specified slot.default voidclearSlot(DisplaySlot slot)Clears anyObjectivein the specified slot.Optional<Team>memberTeam(Component member)Optional<Objective>objective(String name)Gets anObjectiveon this scoreboard by name, if it exists.default Optional<Objective>objective(Supplier<? extends DisplaySlot> slot)Gets theObjectivecurrently displayed in aDisplaySloton this scoreboard, if one is present.Optional<Objective>objective(DisplaySlot slot)Gets theObjectivecurrently displayed in aDisplaySloton this scoreboard, if one is present.Set<Objective>objectives()Gets allObjectives on this scoreboard.default Set<Objective>objectivesByCriterion(Supplier<? extends Criterion> criterion)Gets allObjectives of a Criteria on this scoreboard.Set<Objective>objectivesByCriterion(Criterion criterion)Gets allObjectives of a Criteria on this scoreboard.voidregisterTeam(Team team)Registers the specifiedTeamto this scoreboard.voidremoveObjective(Objective objective)Removes the specifiedObjectivefrom this scoreboard.voidremoveScores(Component name)Removes all scores with the specified name on this scoreboard, across all objectives.Set<Score>scores()Gets all the scores on this scoreboard, across all objectives.Set<Score>scores(Component name)Gets all scores with the specified name on this scoreboard, across all objectives.Optional<Team>team(String teamName)Gets aTeamby name on this scoreboard.Set<Team>teams()Gets all theTeams on this scoreboard.default voidupdateDisplaySlot(@Nullable Objective objective, DefaultedRegistryReference<? extends DisplaySlot> displaySlot)Sets the specifiedObjectivein the specifiedDisplaySlot.voidupdateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot)Sets the specifiedObjectivein the specifiedDisplaySlot.
-
-
-
Method Detail
-
builder
static Scoreboard.Builder builder()
Creates a newScoreboard.Builderto build aScoreboard.- Returns:
- The new builder
-
objective
Optional<Objective> objective(String name)
Gets anObjectiveon this scoreboard by name, if it exists.
-
objective
default Optional<Objective> objective(Supplier<? extends DisplaySlot> slot)
Gets theObjectivecurrently displayed in aDisplaySloton this scoreboard, if one is present.- Parameters:
slot- TheDisplaySlot- Returns:
- the
Objectivecurrently displayed, if present
-
objective
Optional<Objective> objective(DisplaySlot slot)
Gets theObjectivecurrently displayed in aDisplaySloton this scoreboard, if one is present.- Parameters:
slot- TheDisplaySlot- Returns:
- the
Objectivecurrently displayed, if present
-
addObjective
void addObjective(Objective objective) throws IllegalArgumentException
Adds the specifiedObjectiveto this scoreboard.- Parameters:
objective- TheObjectiveadd- Throws:
IllegalArgumentException- if anObjectivewith the samenamealready exists, or if the specifiedObjectivehas already been added.
-
updateDisplaySlot
default void updateDisplaySlot(@Nullable Objective objective, DefaultedRegistryReference<? extends DisplaySlot> displaySlot) throws IllegalStateException
Sets the specifiedObjectivein the specifiedDisplaySlot.If the
Objectiveisnull, then the specifiedDisplaySlotwill be cleared.- Parameters:
objective- TheObjectiveto setdisplaySlot- TheDisplaySlotto the specifiedObjectivein- Throws:
IllegalStateException- if the specifiedObjectivedoes not exist on this scoreboard
-
updateDisplaySlot
void updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) throws IllegalStateException
Sets the specifiedObjectivein the specifiedDisplaySlot.If the
Objectiveisnull, then the specifiedDisplaySlotwill be cleared.- Parameters:
objective- TheObjectiveto setdisplaySlot- TheDisplaySlotto the specifiedObjectivein- Throws:
IllegalStateException- if the specifiedObjectivedoes not exist on this scoreboard
-
clearSlot
default void clearSlot(Supplier<? extends DisplaySlot> slot)
Clears anyObjectivein the specified slot.- Parameters:
slot- TheDisplaySlotto remove anyObjectivefor
-
clearSlot
default void clearSlot(DisplaySlot slot)
Clears anyObjectivein the specified slot.- Parameters:
slot- TheDisplaySlotto remove anyObjectivefor
-
objectivesByCriterion
default Set<Objective> objectivesByCriterion(Supplier<? extends Criterion> criterion)
Gets allObjectives of a Criteria on this scoreboard.
-
objectivesByCriterion
Set<Objective> objectivesByCriterion(Criterion criterion)
Gets allObjectives of a Criteria on this scoreboard.
-
objectives
Set<Objective> objectives()
Gets allObjectives on this scoreboard.- Returns:
- A set of all
Objectives on this scoreboard
-
removeObjective
void removeObjective(Objective objective)
Removes the specifiedObjectivefrom this scoreboard.- Parameters:
objective- TheObjectiveto remove
-
scores
Set<Score> scores()
Gets all the scores on this scoreboard, across all objectives.If the same
Scorehas been added to multiple objectives, it will only appear once in the set.- Returns:
- A set of all scores
-
scores
Set<Score> scores(Component name)
Gets all scores with the specified name on this scoreboard, across all objectives.If the same
Scorehas been added to multiple objectives, it will only appear once in the set.- Parameters:
name- The name whose scores are being retrieved- Returns:
- A set of all scores for the name
-
removeScores
void removeScores(Component name)
Removes all scores with the specified name on this scoreboard, across all objectives.- Parameters:
name- The name to remove all scores for
-
registerTeam
void registerTeam(Team team) throws IllegalArgumentException
Registers the specifiedTeamto this scoreboard.- Parameters:
team- TheTeamto register- Throws:
IllegalArgumentException- if a team with the samenamealready exists on this scoreboard, or if the specifiedTeamis already registered to a scoreboard (this scoreboard, or another one).
-
-