Interface TeamManager


@NonExtendable public interface TeamManager
Represents a group of ScoreboardTeams. To get an instance of this interface, use ScoreboardLibrary.createTeamManager(). Note: this interface is not thread-safe, meaning you can only use it from one thread at a time, although it does not have to be the main thread.
  • Method Details

    • teams

      @NotNull @NotNull Collection<ScoreboardTeam> teams()
      Returns:
      unmodifiable collection of teams in this TeamManager
    • team

      @Nullable @Nullable ScoreboardTeam team(@NotNull @NotNull String name)
      Gets a team by its name.
      Parameters:
      name - name of team
      Returns:
      team with the name, or null if one doesn't exist
    • teamExists

      boolean teamExists(@NotNull @NotNull String name)
      Check whether a team with a name exists.
      Parameters:
      name - name of team
      Returns:
      whether a team by the name exists
    • createIfAbsent

      @NotNull default @NotNull ScoreboardTeam createIfAbsent(@NotNull @NotNull String name)
      Creates a team with a name if one doesn't already exist and returns it.
      Parameters:
      name - name of team
      Returns:
      team
    • createIfAbsent

      @NotNull @NotNull ScoreboardTeam createIfAbsent(@NotNull @NotNull String name, @Nullable @Nullable BiFunction<org.bukkit.entity.Player,ScoreboardTeam,TeamDisplay> teamDisplayFunction)
      Creates a team with a name if one doesn't already exist and returns it.
      Parameters:
      name - name of team
      teamDisplayFunction - a function that provides the team display to set for each player
      Returns:
      team
    • removeTeam

      boolean removeTeam(@NotNull @NotNull String name)
      Removes a team by its name.
      Parameters:
      name - name of team
      Returns:
      if there was a team with than name
    • removeTeam

      void removeTeam(@NotNull @NotNull ScoreboardTeam team)
      Removes a team.
      Parameters:
      team - team to remove
      Throws:
      IllegalArgumentException - if the provided team is not owned by this TeamManager
    • players

      @NotNull @NotNull Collection<org.bukkit.entity.Player> players()
      Returns:
      unmodifiable collection of viewers in this TeamManager
      See Also:
    • addPlayer

      default boolean addPlayer(@NotNull @NotNull org.bukkit.entity.Player player)
      Adds a viewer to this TeamManager. Note that a player can only see a single TeamManager at a time. The TeamManager will internally be added to a queue for this player who will start seeing it once they are removed from all previous TeamManagers.
      Parameters:
      player - player to add
      Returns:
      whether the player was added
    • addPlayer

      boolean addPlayer(@NotNull @NotNull org.bukkit.entity.Player player, @Nullable @Nullable Function<ScoreboardTeam,TeamDisplay> teamDisplayFunction)
      Adds a viewer to this TeamManager. Note that a player can only see a single TeamManager at a time. The TeamManager will internally be added to a queue for this player who will start seeing it once they are removed from all previous TeamManagers.
      Parameters:
      player - player to add
      teamDisplayFunction - a function that provides the team display to set for each team
      Returns:
      whether the player was added
    • addPlayers

      default void addPlayers(@NotNull @NotNull Collection<org.bukkit.entity.Player> players)
      Adds multiple viewers to this TeamManager.
      Parameters:
      players - viewers to add
      See Also:
    • addPlayers

      default void addPlayers(@NotNull @NotNull Collection<org.bukkit.entity.Player> players, @Nullable @Nullable Function<ScoreboardTeam,TeamDisplay> teamDisplayFunction)
      Adds multiple viewers to this TeamManager.
      Parameters:
      players - viewers to add
      teamDisplayFunction - a function that provides the team display to set for each team
      See Also:
    • removePlayer

      boolean removePlayer(@NotNull @NotNull org.bukkit.entity.Player player)
      Removes a viewer from this TeamManager.
      Parameters:
      player - viewer to remove
      Returns:
      whether the viewer was removed
    • removePlayers

      default void removePlayers(@NotNull @NotNull Collection<org.bukkit.entity.Player> players)
      Removes multiple viewers from this TeamManager.
      Parameters:
      players - viewers to remove
    • close

      void close()
      Closes this TeamManager. This must be called once you no longer need this TeamManager to prevent a memory leak.
    • closed

      boolean closed()
      Returns:
      Whether this TeamManager is closed
      See Also: