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(Supplier<? extends DisplaySlot> slot)
Clears anyObjective
in the specified slot.default void
clearSlot(DisplaySlot slot)
Clears anyObjective
in the specified slot.Optional<Team>
memberTeam(Component member)
Optional<Objective>
objective(String name)
Gets anObjective
on this scoreboard by name, if it exists.default Optional<Objective>
objective(Supplier<? extends DisplaySlot> slot)
Gets theObjective
currently displayed in aDisplaySlot
on this scoreboard, if one is present.Optional<Objective>
objective(DisplaySlot slot)
Gets theObjective
currently displayed in aDisplaySlot
on this scoreboard, if one is present.Set<Objective>
objectives()
Gets allObjective
s on this scoreboard.default Set<Objective>
objectivesByCriterion(Supplier<? extends Criterion> criterion)
Gets allObjective
s of a Criteria on this scoreboard.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.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 aTeam
by name on this scoreboard.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
Optional<Objective> objective(String name)
Gets anObjective
on this scoreboard by name, if it exists.
-
objective
default Optional<Objective> objective(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
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 IllegalArgumentException
Adds the specifiedObjective
to this scoreboard.- Parameters:
objective
- TheObjective
add- Throws:
IllegalArgumentException
- if anObjective
with the samename
already exists, or if the specifiedObjective
has already been added.
-
updateDisplaySlot
default void updateDisplaySlot(@Nullable Objective objective, DefaultedRegistryReference<? extends DisplaySlot> displaySlot) throws 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:
IllegalStateException
- if the specifiedObjective
does not exist on this scoreboard
-
updateDisplaySlot
void updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) throws 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:
IllegalStateException
- if the specifiedObjective
does not exist on this scoreboard
-
clearSlot
default void clearSlot(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 Set<Objective> objectivesByCriterion(Supplier<? extends Criterion> criterion)
Gets allObjective
s of a Criteria on this scoreboard.
-
objectivesByCriterion
Set<Objective> objectivesByCriterion(Criterion criterion)
Gets allObjective
s of a Criteria on this scoreboard.
-
objectives
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
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
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
-
registerTeam
void registerTeam(Team team) throws IllegalArgumentException
Registers the specifiedTeam
to this scoreboard.- Parameters:
team
- TheTeam
to register- Throws:
IllegalArgumentException
- if a team with the samename
already exists on this scoreboard, or if the specifiedTeam
is already registered to a scoreboard (this scoreboard, or another one).
-
-