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
Modifier and TypeInterfaceDescriptionstatic interface
Represents a builder to createObjective
instances. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specifiedScore
to this objective.static Objective.Builder
builder()
Creates a newObjective.Builder
to build aObjective
.Gets the criterion for this objective.Gets theObjectiveDisplayMode
used to display this objective.Gets the name displayed to players.findOrCreateScore
(String name) Gets an entry'sScore
for this objective.findOrCreateScore
(Entity entity) Gets an entry'sScore
for this objective.findOrCreateScore
(GameProfile profile) Gets an entry'sScore
for this objective.Gets an entry'sScore
for this objective, if it exists.Gets an entry'sScore
for this objective, if it exists.findScore
(GameProfile profile) Gets an entry'sScore
for this objective, if it exists.boolean
Returns whether this objective has aScore
with the given name.boolean
Returns whether this objective has aScore
with the given entity.boolean
hasScore
(GameProfile profile) Returns whether this objective has aScore
with the given profile.name()
Gets the name of this Objective.boolean
removeScore
(String name) Removes theScore
with the specified name from this objective, if present.boolean
removeScore
(Entity entity) Removes theScore
with the specified entity from this objective, if present.boolean
removeScore
(GameProfile profile) Removes theScore
with the specified profile from this objective, if present.boolean
removeScore
(Score score) Removes the specifiedScore
from this objective, if present.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 Details
-
builder
Creates a newObjective.Builder
to build aObjective
.- Returns:
- The new builder
-
name
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
Sets the name displayed to players.- Parameters:
displayName
- Display name to set- Throws:
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
Sets theObjectiveDisplayMode
used to display this objective.- Parameters:
displayMode
- TheObjectiveDisplayMode
used to display this objective
-
scores
Gets the set ofScore
s for this objective.- Returns:
- The set of
Score
s for this objective
-
hasScore
Returns whether this objective has aScore
with the given name. -
hasScore
Returns whether this objective has aScore
with the given entity. -
hasScore
Returns whether this objective has aScore
with the given profile. -
addScore
Adds the specifiedScore
to this objective.- Parameters:
score
- TheScore
to add- Throws:
IllegalArgumentException
- If aScore
with the same name exists, or the specifiedScore
has already been added
-
findScore
Gets an entry'sScore
for this objective, if it exists. -
findOrCreateScore
-
removeScore
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
-
findScore
Gets an entry'sScore
for this objective, if it exists. -
findOrCreateScore
-
removeScore
Removes theScore
with the specified entity from this objective, if present.- Parameters:
entity
- The entity of theScore
to remove.- Returns:
- Whether the score existed on this objective
-
findScore
Gets an entry'sScore
for this objective, if it exists. -
findOrCreateScore
-
removeScore
Removes theScore
with the specified profile from this objective, if present.- Parameters:
profile
- The profile of theScore
to remove.- Returns:
- Whether the score existed on this objective
-
removeScore
Removes the specifiedScore
from this objective, if present.- Parameters:
score
- TheScore
to remove- Returns:
- Whether the score existed on this objective
-
scoreboards
Set<Scoreboard> scoreboards()- Returns:
- A
Set
of parentScoreboard
s thisObjective
is registered to
-