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(java.util.function.Supplier<? extends DisplaySlot> slot)Clears anyObjectivein the specified slot.default voidclearSlot(DisplaySlot slot)Clears anyObjectivein the specified slot.java.util.Optional<Team>memberTeam(Component member)java.util.Optional<Objective>objective(java.lang.String name)Gets anObjectiveon this scoreboard by name, if it exists.default java.util.Optional<Objective>objective(java.util.function.Supplier<? extends DisplaySlot> slot)Gets theObjectivecurrently displayed in aDisplaySloton this scoreboard, if one is present.java.util.Optional<Objective>objective(DisplaySlot slot)Gets theObjectivecurrently displayed in aDisplaySloton this scoreboard, if one is present.java.util.Set<Objective>objectives()Gets allObjectives on this scoreboard.default java.util.Set<Objective>objectivesByCriterion(java.util.function.Supplier<? extends Criterion> criterion)Gets allObjectives of a Criteria on this scoreboard.java.util.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.java.util.Set<Score>scores()Gets all the scores on this scoreboard, across all objectives.java.util.Set<Score>scores(Component name)Gets all scores with the specified name on this scoreboard, across all objectives.java.util.Optional<Team>team(java.lang.String teamName)Gets aTeamby name on this scoreboard.java.util.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
java.util.Optional<Objective> objective(java.lang.String name)
Gets anObjectiveon this scoreboard by name, if it exists.
-
objective
default java.util.Optional<Objective> objective(java.util.function.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
java.util.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 java.lang.IllegalArgumentException
Adds the specifiedObjectiveto this scoreboard.
-
updateDisplaySlot
default void updateDisplaySlot(@Nullable Objective objective, DefaultedRegistryReference<? extends DisplaySlot> displaySlot) throws java.lang.IllegalStateException
Sets the specifiedObjectivein the specifiedDisplaySlot.If the
Objectiveisnull, then the specifiedDisplaySlotwill be cleared.- Parameters:
objective- TheObjectiveto setdisplaySlot- TheDisplaySlotto the specifiedObjectivein- Throws:
java.lang.IllegalStateException- if the specifiedObjectivedoes not exist on this scoreboard
-
updateDisplaySlot
void updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) throws java.lang.IllegalStateException
Sets the specifiedObjectivein the specifiedDisplaySlot.If the
Objectiveisnull, then the specifiedDisplaySlotwill be cleared.- Parameters:
objective- TheObjectiveto setdisplaySlot- TheDisplaySlotto the specifiedObjectivein- Throws:
java.lang.IllegalStateException- if the specifiedObjectivedoes not exist on this scoreboard
-
clearSlot
default void clearSlot(java.util.function.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 java.util.Set<Objective> objectivesByCriterion(java.util.function.Supplier<? extends Criterion> criterion)
Gets allObjectives of a Criteria on this scoreboard.
-
objectivesByCriterion
java.util.Set<Objective> objectivesByCriterion(Criterion criterion)
Gets allObjectives of a Criteria on this scoreboard.
-
objectives
java.util.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
java.util.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
java.util.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
-
team
java.util.Optional<Team> team(java.lang.String teamName)
Gets aTeamby name on this scoreboard.
-
registerTeam
void registerTeam(Team team) throws java.lang.IllegalArgumentException
Registers the specifiedTeamto this scoreboard.
-
-