Interface Objective
-
public interface Objective
An objective tracks an integer score for each entry it contains.Entries can be updated by plugins, by in-game commands, or automatically by the game, depending on their
Criterion
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Objective.Builder
Represents a builder to createObjective
instances.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addScore(Score score)
Adds the specifiedScore
to this objective.static Objective.Builder
builder()
Creates a newObjective.Builder
to build aObjective
.Criterion
criterion()
Gets the criterion for this objective.ObjectiveDisplayMode
displayMode()
Gets theObjectiveDisplayMode
used to display this objective.Component
displayName()
Gets the name displayed to players.Score
findOrCreateScore(Component name)
Gets an entry'sScore
for this objective.default java.util.Optional<Score>
findScore(Component name)
Gets an entry'sScore
for this objective, if it exists.boolean
hasScore(Component name)
Returns whether this objective has aScore
with the given name.java.lang.String
name()
Gets the name of this Objective.boolean
removeScore(Component name)
Removes theScore
with the specified name from this objective, if present.boolean
removeScore(Score score)
Removes the specifiedScore
from this objective, if present.java.util.Set<Scoreboard>
scoreboards()
java.util.Map<Component,Score>
scores()
Gets the set ofScore
s for this objective.void
setDisplayMode(ObjectiveDisplayMode displayMode)
Sets theObjectiveDisplayMode
used to display this objective.void
setDisplayName(Component displayName)
Sets the name displayed to players.
-
-
-
Method Detail
-
builder
static Objective.Builder builder()
Creates a newObjective.Builder
to build aObjective
.- Returns:
- The new builder
-
name
java.lang.String name()
Gets the name of this Objective.- Returns:
- The objective's name
-
displayName
Component displayName()
Gets the name displayed to players.- Returns:
- The objective's display name
-
setDisplayName
void setDisplayName(Component displayName) throws java.lang.IllegalArgumentException
Sets the name displayed to players.- Parameters:
displayName
- Display name to set- Throws:
java.lang.IllegalArgumentException
- if displayName is longer than 32 characters (in its legacy representation)
-
criterion
Criterion criterion()
Gets the criterion for this objective.- Returns:
- This objective's criterion
-
displayMode
ObjectiveDisplayMode displayMode()
Gets theObjectiveDisplayMode
used to display this objective.- Returns:
- The
ObjectiveDisplayMode
used to display this objective
-
setDisplayMode
void setDisplayMode(ObjectiveDisplayMode displayMode)
Sets theObjectiveDisplayMode
used to display this objective.- Parameters:
displayMode
- TheObjectiveDisplayMode
used to display this objective
-
scores
java.util.Map<Component,Score> scores()
Gets the set ofScore
s for this objective.- Returns:
- The set of
Score
s for this objective
-
hasScore
boolean hasScore(Component name)
Returns whether this objective has aScore
with the given name.
-
addScore
void addScore(Score score) throws java.lang.IllegalArgumentException
Adds the specifiedScore
to this objective.
-
findScore
default java.util.Optional<Score> findScore(Component name)
Gets an entry'sScore
for this objective, if it exists.
-
removeScore
boolean removeScore(Score score)
Removes the specifiedScore
from this objective, if present.- Parameters:
score
- TheScore
to remove- Returns:
- Whether the score existed on this objective
-
removeScore
boolean removeScore(Component name)
Removes theScore
with the specified name from this objective, if present.- Parameters:
name
- The name of theScore
to remove.- Returns:
- Whether the score existed on this objective
-
scoreboards
java.util.Set<Scoreboard> scoreboards()
- Returns:
- A
Set
of parentScoreboard
s thisObjective
is registered to
-
-