Interface Objective


public interface Objective
An objective on a scoreboard that can show scores specific to entries. This objective is only relevant to the display of the associated scoreboard.
  • Method Details

    • getName

      @NotNull @NotNull String getName()
      Gets the name of this Objective
      Returns:
      this objective's name
      Throws:
      IllegalStateException - if this objective has been unregistered
    • displayName

      @NotNull Component displayName()
      Gets the display name for this objective
      Returns:
      this objective's display name
      Throws:
      IllegalStateException - if this objective has been unregistered
    • displayName

      void displayName(@Nullable Component displayName)
      Sets the name displayed to players for this objective.
      Parameters:
      displayName - Display name to set
      Throws:
      IllegalStateException - if this objective has been unregistered
      IllegalArgumentException - if displayName is null
      IllegalArgumentException - if displayName is longer than 128 characters.
    • getDisplayName

      @NotNull @Deprecated @NotNull String getDisplayName()
      Deprecated.
      in favour of displayName()
      Gets the name displayed to players for this objective
      Returns:
      this objective's display name
      Throws:
      IllegalStateException - if this objective has been unregistered
    • setDisplayName

      @Deprecated void setDisplayName(@NotNull @NotNull String displayName)
      Sets the name displayed to players for this objective.
      Parameters:
      displayName - Display name to set
      Throws:
      IllegalStateException - if this objective has been unregistered
    • getCriteria

      @Deprecated(since="1.19.2") @NotNull @NotNull String getCriteria()
      Deprecated.
      Gets the criteria this objective tracks.
      Returns:
      this objective's criteria
      Throws:
      IllegalStateException - if this objective has been unregistered
    • getTrackedCriteria

      @NotNull @NotNull Criteria getTrackedCriteria()
      Gets the criteria this objective tracks.
      Returns:
      this objective's criteria
      Throws:
      IllegalStateException - if this objective has been unregistered
    • isModifiable

      boolean isModifiable()
      Gets if the objective's scores can be modified directly by a plugin.
      Returns:
      true if scores are modifiable
      Throws:
      IllegalStateException - if this objective has been unregistered
      See Also:
    • getScoreboard

      @Nullable @Nullable Scoreboard getScoreboard()
      Gets the scoreboard to which this objective is attached.
      Returns:
      Owning scoreboard, or null if it has been unregistered
    • unregister

      void unregister()
      Unregisters this objective from the scoreboard.
      Throws:
      IllegalStateException - if this objective has been unregistered
    • setDisplaySlot

      void setDisplaySlot(@Nullable @Nullable DisplaySlot slot)
      Sets this objective to display on the specified slot for the scoreboard, removing it from any other display slot.
      Parameters:
      slot - display slot to change, or null to not display
      Throws:
      IllegalStateException - if this objective has been unregistered
    • getDisplaySlot

      @Nullable @Nullable DisplaySlot getDisplaySlot()
      Gets the display slot this objective is displayed at.
      Returns:
      the display slot for this objective, or null if not displayed
      Throws:
      IllegalStateException - if this objective has been unregistered
    • setRenderType

      void setRenderType(@NotNull @NotNull RenderType renderType)
      Sets manner in which this objective will be rendered.
      Parameters:
      renderType - new render type
      Throws:
      IllegalStateException - if this objective has been unregistered
    • getRenderType

      @NotNull @NotNull RenderType getRenderType()
      Sets manner in which this objective will be rendered.
      Returns:
      the render type
      Throws:
      IllegalStateException - if this objective has been unregistered
    • getScore

      @NotNull @NotNull Score getScore(@NotNull @NotNull OfflinePlayer player)
      Gets a player's Score for an Objective on this Scoreboard
      Parameters:
      player - Player for the Score
      Returns:
      Score tracking the Objective and player specified
      Throws:
      IllegalStateException - if this objective has been unregistered
      See Also:
    • getScore

      @NotNull @NotNull Score getScore(@NotNull @NotNull String entry)
      Gets an entry's Score for an Objective on this Scoreboard.
      Parameters:
      entry - Entry for the Score
      Returns:
      Score tracking the Objective and entry specified
      Throws:
      IllegalStateException - if this objective has been unregistered
      IllegalArgumentException - if entry is longer than 32767 characters.
    • getScoreFor

      @NotNull @NotNull Score getScoreFor(@NotNull Entity entity) throws IllegalArgumentException, IllegalStateException
      Gets an entity's Score for an Objective on this Scoreboard.
      Parameters:
      entity - Entity for the Score
      Returns:
      Score tracking the Objective and entity specified
      Throws:
      IllegalArgumentException - if entity is null
      IllegalStateException - if this objective has been unregistered
    • willAutoUpdateDisplay

      boolean willAutoUpdateDisplay()
      Gets if this objective will auto update score displays on changes.
      Returns:
      true if auto updating
      Throws:
      IllegalStateException - if this objective has been unregistered
    • setAutoUpdateDisplay

      void setAutoUpdateDisplay(boolean autoUpdateDisplay)
      Sets if this objective will auto update score displays on changes.
      Parameters:
      autoUpdateDisplay - true to auto update
      Throws:
      IllegalStateException - if this objective has been unregistered
    • numberFormat

      @Nullable NumberFormat numberFormat()
      Gets the number format for this objective's scores or null if the client default is used.
      Returns:
      this objective's number format, or null if the client default is used
      Throws:
      IllegalStateException - if this objective has been unregistered
    • numberFormat

      void numberFormat(@Nullable NumberFormat format)
      Sets the number format for this objective's scores.
      Parameters:
      format - the number format to set, pass null to reset format to default
      Throws:
      IllegalStateException - if this objective has been unregistered