Class TeamProgression

java.lang.Object
com.fren_gor.ultimateAdvancementAPI.database.TeamProgression

public final class TeamProgression extends Object
The TeamProgression class stores information about a team and its advancement progressions.

TeamProgression is used to cache team information by the caching system.

This class is thread safe.

  • Constructor Details

    • TeamProgression

      public TeamProgression(int teamId, @NotNull @NotNull UUID member)
      Creates a new TeamProgression for a team with one player in it.

      Note: TeamProgression should be instantiated only by database-related classes. Any illegal instantiation will throw an IllegalOperationException.

      Parameters:
      teamId - The team id.
      member - The member of the team.
      Throws:
      IllegalOperationException - If this constructor is called by a class not in the com.fren_gor.ultimateAdvancementAPI.database package or in one of its sub-packages.
    • TeamProgression

      public TeamProgression(@NotNull @NotNull Map<AdvancementKey,Integer> advancements, int teamId, @NotNull @NotNull Collection<UUID> members)
      Creates a new TeamProgression for a team with more than one player in it.

      Note: TeamProgression should be instantiated only by database-related classes. Any illegal instantiation will throw an IllegalOperationException.

      Parameters:
      advancements - All the advancement keys with their progression.
      teamId - The team id.
      members - A collection of team members.
      Throws:
      IllegalOperationException - If this constructor is called by a class not in the com.fren_gor.ultimateAdvancementAPI.database package or in one of its sub-packages.
  • Method Details

    • getProgression

      public @Range(from=0, to=Integer.MAX_VALUE) int getProgression(@NotNull @NotNull Advancement advancement)
      Gets the progression of the provided advancement for the team.
      Parameters:
      advancement - The advancement.
      Returns:
      The current progression of the team for the provided advancement.
    • contains

      @Contract(pure=true) public boolean contains(@NotNull @NotNull Player player)
      Returns whether the provided player is part of the team.
      Parameters:
      player - The player.
      Returns:
      Whether the provided player is part of the team.
    • contains

      @Contract(pure=true, value="null -> false") public boolean contains(UUID uuid)
      Returns whether the provided player is part of the team.
      Parameters:
      uuid - The UUID of the player.
      Returns:
      Whether the provided player is part of the team.
    • getMembersCopy

      @Contract(pure=true, value="-> new") public Set<@NotNull UUID> getMembersCopy()
      Returns a modifiable copy of the team members set.
      Returns:
      A modifiable copy of the team members set.
    • getSize

      @Contract(pure=true) public @Range(from=0, to=Integer.MAX_VALUE) int getSize()
      Returns the team members count.
      Returns:
      The team members count.
    • forEachMember

      public void forEachMember(@NotNull @NotNull Consumer<UUID> action)
      Runs the provided Consumer for each member of the team.
      Parameters:
      action - The Consumer to run for each member.
    • everyMemberMatch

      public boolean everyMemberMatch(@NotNull @NotNull Predicate<UUID> action)
      Returns whether every member of the team matches the provided Predicate.

      This method may not call the Predicate for every team member, since it stops on the first non-matching one.

      Parameters:
      action - The Predicate to run.
      Returns:
      Whether the Predicate returns true for every member, or true if the team is empty.
    • anyMemberMatch

      public boolean anyMemberMatch(@NotNull @NotNull Predicate<UUID> action)
      Returns whether any member of the team matches the provided Predicate.

      This method may not call the Predicate for every team member, since it stops on the first matching one.

      Parameters:
      action - The Predicate to run.
      Returns:
      Whether the Predicate returns true for at least one member, or false if the team is empty.
    • noMemberMatch

      public boolean noMemberMatch(@NotNull @NotNull Predicate<UUID> action)
      Returns whether no member of the team matches the provided Predicate.

      This method may not call the Predicate for every team member, since it stops on the first matching one.

      Parameters:
      action - The Predicate to run.
      Returns:
      Whether the Predicate returns false for every member, or true if the team is empty.
    • isValid

      public boolean isValid()
      Gets whether the current TeamProgression object is valid. A TeamProgression object is valid if and only if it is stored into the caching system (see DatabaseManager).
      Returns:
      Whether the current TeamProgression object is valid.
      Since:
      1.0.2
    • getAMember

      @Nullable public @Nullable UUID getAMember()
      Returns the UUID of a team member. No particular player is preferred by this operation and the returned member may change from invocation to invocation.
      Returns:
      The UUID of a team member, or null if the team is empty.
    • getAnOnlineMember

      @Nullable public @Nullable Player getAnOnlineMember(@NotNull @NotNull DatabaseManager manager)
      Returns an online team member, if possible.
      Parameters:
      manager - The database manager.
      Returns:
      An online team member, or null if there are none.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getTeamId

      public int getTeamId()
      Returns the team unique id.
      Returns:
      The team unique id.