Interface Score


public interface Score
A score entry for an entry on an objective. Changing this will not affect any other objective or scoreboard.
  • Method Details

    • getPlayer

      Deprecated.
      Scoreboards can contain entries that aren't players
      Gets the OfflinePlayer being tracked by this Score
      Returns:
      this Score's tracked player
      See Also:
    • getEntry

      Gets the entry being tracked by this Score
      Returns:
      this Score's tracked entry
    • getObjective

      @NotNull @NotNull Objective getObjective()
      Gets the Objective being tracked by this Score
      Returns:
      this Score's tracked objective
    • getScore

      int getScore()
      Gets the current score
      Returns:
      the current score
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • setScore

      void setScore(int score)
      Sets the current score.
      Parameters:
      score - New score
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • isScoreSet

      boolean isScoreSet()
      Shows if this score has been set at any point in time.
      Returns:
      if this score has been set before
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • getScoreboard

      @Nullable @Nullable Scoreboard getScoreboard()
      Gets the scoreboard for the associated objective.
      Returns:
      the owning objective's scoreboard, or null if it has been unregistered
    • resetScore

      void resetScore() throws IllegalStateException
      Resets this score, if a value has been set.
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • isTriggerable

      boolean isTriggerable()
      Gets if this score is triggerable and cannot be used by the /trigger command executed by the owner of this score.
      Returns:
      true if triggerable, false if not triggerable, score isn't set, or the objective isn't Criteria.TRIGGER
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • setTriggerable

      void setTriggerable(boolean triggerable)
      Sets if this score is triggerable and can be used by the /trigger command executed by the owner of this score. Can only be set on Criteria.TRIGGER objectives.

      If the score doesn't exist (aka isScoreSet() returns false), this will create the score with a 0 value.

      Parameters:
      triggerable - true to enable trigger, false to disable
      Throws:
      IllegalArgumentException - if this objective isn't Criteria.TRIGGER
      IllegalStateException - if the associated objective has been unregistered
    • customName

      @Nullable Component customName()
      Get the custom name for this entry.
      Returns:
      the custom name or null if not set (or score isn't set)
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • customName

      void customName(@Nullable Component customName)
      Sets the custom name for this entry.

      If the score doesn't exist (aka isScoreSet() returns false), this will create the score with a 0 value.

      Parameters:
      customName - the custom name or null to reset
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • numberFormat

      @Nullable NumberFormat numberFormat()
      Gets the number format for this score or null if the score has not been set yet or the objective's default is being used.
      Returns:
      this score's number format, or null if the objective's default is used or the score doesn't exist
      Throws:
      IllegalStateException - if the associated objective has been unregistered
    • numberFormat

      void numberFormat(@Nullable NumberFormat format)
      Sets the number format for this score. If this score has not been set yet isScoreSet(), it will be created
      Parameters:
      format - the number format to set, pass null to reset format to default
      Throws:
      IllegalStateException - if the associated objective has been unregistered