Package org.spongepowered.api.scoreboard
Interface Scoreboard
-
public interface Scoreboard
Represents a scoreboard, which containsTeam
s andObjective
s. The server has a default scoreboard, but eachPlayer
can have their own scoreboard.- See Also:
- Scoreboards on the Minecraft Wiki
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Scoreboard.Builder
Represents a builder to createScoreboard
instances.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addObjective(Objective objective)
Adds the specifiedObjective
to this scoreboard.static Scoreboard.Builder
builder()
Creates a newScoreboard.Builder
to build aScoreboard
.default void
clearSlot(java.util.function.Supplier<? extends DisplaySlot> slot)
Clears anyObjective
in the specified slot.default void
clearSlot(DisplaySlot slot)
Clears anyObjective
in the specified slot.java.util.Optional<Team>
memberTeam(Component member)
java.util.Optional<Objective>
objective(java.lang.String name)
Gets anObjective
on this scoreboard by name, if it exists.default java.util.Optional<Objective>
objective(java.util.function.Supplier<? extends DisplaySlot> slot)
Gets theObjective
currently displayed in aDisplaySlot
on this scoreboard, if one is present.java.util.Optional<Objective>
objective(DisplaySlot slot)
Gets theObjective
currently displayed in aDisplaySlot
on this scoreboard, if one is present.java.util.Set<Objective>
objectives()
Gets allObjective
s on this scoreboard.default java.util.Set<Objective>
objectivesByCriterion(java.util.function.Supplier<? extends Criterion> criterion)
Gets allObjective
s of a Criteria on this scoreboard.java.util.Set<Objective>
objectivesByCriterion(Criterion criterion)
Gets allObjective
s of a Criteria on this scoreboard.void
registerTeam(Team team)
Registers the specifiedTeam
to this scoreboard.void
removeObjective(Objective objective)
Removes the specifiedObjective
from this scoreboard.void
removeScores(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 aTeam
by name on this scoreboard.java.util.Set<Team>
teams()
Gets all theTeam
s on this scoreboard.default void
updateDisplaySlot(@Nullable Objective objective, DefaultedRegistryReference<? extends DisplaySlot> displaySlot)
Sets the specifiedObjective
in the specifiedDisplaySlot
.void
updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot)
Sets the specifiedObjective
in the specifiedDisplaySlot
.
-
-
-
Method Detail
-
builder
static Scoreboard.Builder builder()
Creates a newScoreboard.Builder
to build aScoreboard
.- Returns:
- The new builder
-
objective
java.util.Optional<Objective> objective(java.lang.String name)
Gets anObjective
on this scoreboard by name, if it exists.
-
objective
default java.util.Optional<Objective> objective(java.util.function.Supplier<? extends DisplaySlot> slot)
Gets theObjective
currently displayed in aDisplaySlot
on this scoreboard, if one is present.- Parameters:
slot
- TheDisplaySlot
- Returns:
- the
Objective
currently displayed, if present
-
objective
java.util.Optional<Objective> objective(DisplaySlot slot)
Gets theObjective
currently displayed in aDisplaySlot
on this scoreboard, if one is present.- Parameters:
slot
- TheDisplaySlot
- Returns:
- the
Objective
currently displayed, if present
-
addObjective
void addObjective(Objective objective) throws java.lang.IllegalArgumentException
Adds the specifiedObjective
to this scoreboard.
-
updateDisplaySlot
default void updateDisplaySlot(@Nullable Objective objective, DefaultedRegistryReference<? extends DisplaySlot> displaySlot) throws java.lang.IllegalStateException
Sets the specifiedObjective
in the specifiedDisplaySlot
.If the
Objective
isnull
, then the specifiedDisplaySlot
will be cleared.- Parameters:
objective
- TheObjective
to setdisplaySlot
- TheDisplaySlot
to the specifiedObjective
in- Throws:
java.lang.IllegalStateException
- if the specifiedObjective
does not exist on this scoreboard
-
updateDisplaySlot
void updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) throws java.lang.IllegalStateException
Sets the specifiedObjective
in the specifiedDisplaySlot
.If the
Objective
isnull
, then the specifiedDisplaySlot
will be cleared.- Parameters:
objective
- TheObjective
to setdisplaySlot
- TheDisplaySlot
to the specifiedObjective
in- Throws:
java.lang.IllegalStateException
- if the specifiedObjective
does not exist on this scoreboard
-
clearSlot
default void clearSlot(java.util.function.Supplier<? extends DisplaySlot> slot)
Clears anyObjective
in the specified slot.- Parameters:
slot
- TheDisplaySlot
to remove anyObjective
for
-
clearSlot
default void clearSlot(DisplaySlot slot)
Clears anyObjective
in the specified slot.- Parameters:
slot
- TheDisplaySlot
to remove anyObjective
for
-
objectivesByCriterion
default java.util.Set<Objective> objectivesByCriterion(java.util.function.Supplier<? extends Criterion> criterion)
Gets allObjective
s of a Criteria on this scoreboard.
-
objectivesByCriterion
java.util.Set<Objective> objectivesByCriterion(Criterion criterion)
Gets allObjective
s of a Criteria on this scoreboard.
-
objectives
java.util.Set<Objective> objectives()
Gets allObjective
s on this scoreboard.- Returns:
- A set of all
Objective
s on this scoreboard
-
removeObjective
void removeObjective(Objective objective)
Removes the specifiedObjective
from this scoreboard.- Parameters:
objective
- TheObjective
to remove
-
scores
java.util.Set<Score> scores()
Gets all the scores on this scoreboard, across all objectives.If the same
Score
has 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
Score
has 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 aTeam
by name on this scoreboard.
-
registerTeam
void registerTeam(Team team) throws java.lang.IllegalArgumentException
Registers the specifiedTeam
to this scoreboard.
-
-