Interface RankLadder

  • All Superinterfaces:
    net.kyori.adventure.text.ComponentLike

    public interface RankLadder
    extends net.kyori.adventure.text.ComponentLike
    Represents a track of ranks along which a user can be promoted or demoted.

    These objects are immutable.

    Since:
    2.0.0
    • Method Detail

      • name

        String name()
        The name assigned to the rank-ladder.

        These names are case-insensitive.

        Returns:
        The ladder's name
        Since:
        2.0.0
      • promote

        ImmutableSubjectData promote​(Set<ContextValue<?>> contexts,
                                     ImmutableSubjectData input)
        Promote the given subject data on this rank ladder in the given context. If the subject is not currently on the rank ladder in this context, the subject will be placed on the lowest rank in this ladder. If the subject is currently at the top of this rank ladder, nothing will happen. If the subject has multiple memberships at various points in this rank ladder, all of them will be moved up by one step
        Parameters:
        contexts - The context combination to promote in
        input - The subject data to promote
        Returns:
        The promoted data
        Since:
        2.0.0
      • demote

        ImmutableSubjectData demote​(Set<ContextValue<?>> contexts,
                                    ImmutableSubjectData input)
        Demote the given subject data on this rank ladder in the given context.

        If the subject is not currently on the rank ladder in this context, nothing will happen. If the subject is currently at the bottom of this rank ladder, the subject will be removed from the rank ladder entirely. If the subject has multiple memberships at various points in this rank ladder, all of them will be moved down by one step

        Parameters:
        contexts - The context combination to promote in
        input - The subject data to promote
        Returns:
        the demoted data
        Since:
        2.0.0
      • isOnLadder

        boolean isOnLadder​(Set<ContextValue<?>> contexts,
                           ImmutableSubjectData subject)
        Return if this subject is a member of any subjects that are part of this rank ladder within the given contexts.
        Parameters:
        contexts - The contexts to check in
        subject - The subject
        Returns:
        Whether this ladder contains any of the direct parents of the subject in the given contexts
        Since:
        2.0.0
      • with

        RankLadder with​(SubjectRef<?> subject)
        Return a new rank ladder with the specified rank added at the highest point in the ladder.

        If the rank is currently already in the rank ladder, it will be moved to the highest point.

        Parameters:
        subject - the rank to add
        Returns:
        a rank ladder instance with the appropriate changes
        Since:
        2.0.0
      • with

        RankLadder with​(SubjectRef<?> subject,
                        int index)
        Return a new rank ladder with the specified rank added at a given point in the rank ladder. If the rank is currently already in the rank ladder, it will be moved to the given index.
        Parameters:
        subject - The rank to add
        index - The point to add the rank at. Must be on the range [0, getRanks().size()]
        Returns:
        a rank ladder instance with the appropriate changes
      • indexOf

        int indexOf​(SubjectRef<?> subject)
        Get the index of this rank in the current ladder. This index is the index of the rank in ranks().
        Parameters:
        subject - The rank to find the index of
        Returns:
        The index of the rank, or -1 if the rank is not present.
      • without

        RankLadder without​(SubjectRef<?> subject)
        Remove the given rank from this rank ladder.
        Parameters:
        subject - The rank to remove
        Returns:
        A new ladder without the given rank, or this if the rank was not contained in this ladder
      • ranks

        List<? extends SubjectRef<?>> ranks()
        Provides a way to iterate through ranks currently active in this ladder.
        Returns:
        A list of ranks present in the ladder. This list is immutable.