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.

    • Method Detail

      • 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
      • hasScore

        boolean hasScore​(Component name)
        Returns whether this objective has a Score with the given name.
        Parameters:
        name - The name of the Score to check for.
        Returns:
        Whether this objective has a Score with the given name.
      • findScore

        default Optional<Score> findScore​(Component name)
        Gets an entry's Score for this objective, if it exists.
        Parameters:
        name - The name of the Score to get.
        Returns:
        The Score for te specified Component, if it exists.
      • findOrCreateScore

        Score findOrCreateScore​(Component name)
        Gets an entry's Score for this objective.

        If the Score does not exist, it will be created.

        Parameters:
        name - The name of the Score to get
        Returns:
        The Score for the specified Component
      • removeScore

        boolean removeScore​(Score score)
        Removes the specified Score from this objective, if present.
        Parameters:
        score - The Score to remove
        Returns:
        Whether the score existed on this objective
      • removeScore

        boolean removeScore​(Component name)
        Removes the Score with the specified name from this objective, if present.
        Parameters:
        name - The name of the Score to remove.
        Returns:
        Whether the score existed on this objective