Interface Objective
-
public interface ObjectiveAn 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 interfaceObjective.BuilderRepresents a builder to createObjectiveinstances.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddScore(Score score)Adds the specifiedScoreto this objective.static Objective.Builderbuilder()Creates a newObjective.Builderto build aObjective.Criterioncriterion()Gets the criterion for this objective.ObjectiveDisplayModedisplayMode()Gets theObjectiveDisplayModeused to display this objective.ComponentdisplayName()Gets the name displayed to players.ScorefindOrCreateScore(Component name)Gets an entry'sScorefor this objective.default Optional<Score>findScore(Component name)Gets an entry'sScorefor this objective, if it exists.booleanhasScore(Component name)Returns whether this objective has aScorewith the given name.Stringname()Gets the name of this Objective.booleanremoveScore(Component name)Removes theScorewith the specified name from this objective, if present.booleanremoveScore(Score score)Removes the specifiedScorefrom this objective, if present.Set<Scoreboard>scoreboards()Map<Component,Score>scores()Gets the set ofScores for this objective.voidsetDisplayMode(ObjectiveDisplayMode displayMode)Sets theObjectiveDisplayModeused to display this objective.voidsetDisplayName(Component displayName)Sets the name displayed to players.
-
-
-
Method Detail
-
builder
static Objective.Builder builder()
Creates a newObjective.Builderto 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
void setDisplayName(Component displayName) throws IllegalArgumentException
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 theObjectiveDisplayModeused to display this objective.- Returns:
- The
ObjectiveDisplayModeused to display this objective
-
setDisplayMode
void setDisplayMode(ObjectiveDisplayMode displayMode)
Sets theObjectiveDisplayModeused to display this objective.- Parameters:
displayMode- TheObjectiveDisplayModeused to display this objective
-
scores
Map<Component,Score> scores()
Gets the set ofScores for this objective.- Returns:
- The set of
Scores for this objective
-
hasScore
boolean hasScore(Component name)
Returns whether this objective has aScorewith the given name.
-
addScore
void addScore(Score score) throws IllegalArgumentException
Adds the specifiedScoreto this objective.- Parameters:
score- TheScoreto add- Throws:
IllegalArgumentException- If aScorewith the same name exists, or the specifiedScorehas already been added
-
findScore
default Optional<Score> findScore(Component name)
Gets an entry'sScorefor this objective, if it exists.
-
removeScore
boolean removeScore(Score score)
Removes the specifiedScorefrom this objective, if present.- Parameters:
score- TheScoreto remove- Returns:
- Whether the score existed on this objective
-
removeScore
boolean removeScore(Component name)
Removes theScorewith the specified name from this objective, if present.- Parameters:
name- The name of theScoreto remove.- Returns:
- Whether the score existed on this objective
-
scoreboards
Set<Scoreboard> scoreboards()
- Returns:
- A
Setof parentScoreboards thisObjectiveis registered to
-
-