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 Summary
Modifier and TypeMethodDescriptiondefault booleanaddPlayer(@NotNull org.bukkit.entity.Player player) Adds a viewer to this TeamManager.booleanaddPlayer(@NotNull org.bukkit.entity.Player player, @Nullable Function<ScoreboardTeam, TeamDisplay> teamDisplayFunction) Adds a viewer to this TeamManager.default voidaddPlayers(@NotNull Collection<org.bukkit.entity.Player> players) Adds multiple viewers to this TeamManager.default voidaddPlayers(@NotNull Collection<org.bukkit.entity.Player> players, @Nullable Function<ScoreboardTeam, TeamDisplay> teamDisplayFunction) Adds multiple viewers to this TeamManager.voidclose()Closes this TeamManager.booleanclosed()default @NotNull ScoreboardTeamcreateIfAbsent(@NotNull String name) Creates a team with a name if one doesn't already exist and returns it.@NotNull ScoreboardTeamcreateIfAbsent(@NotNull String name, @Nullable BiFunction<org.bukkit.entity.Player, ScoreboardTeam, TeamDisplay> teamDisplayFunction) Creates a team with a name if one doesn't already exist and returns it.@NotNull Collection<org.bukkit.entity.Player>players()booleanremovePlayer(@NotNull org.bukkit.entity.Player player) Removes a viewer from this TeamManager.default voidremovePlayers(@NotNull Collection<org.bukkit.entity.Player> players) Removes multiple viewers from this TeamManager.booleanremoveTeam(@NotNull String name) Removes a team by its name.voidremoveTeam(@NotNull ScoreboardTeam team) Removes a team.@Nullable ScoreboardTeamGets a team by its name.booleanteamExists(@NotNull String name) Check whether a team with a name exists.@NotNull Collection<ScoreboardTeam>teams()
-
Method Details
-
teams
- Returns:
- unmodifiable collection of teams in this TeamManager
-
team
Gets a team by its name.- Parameters:
name- name of team- Returns:
- team with the name, or null if one doesn't exist
-
teamExists
Check whether a team with a name exists.- Parameters:
name- name of team- Returns:
- whether a team by the name exists
-
createIfAbsent
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 teamteamDisplayFunction- a function that provides the team display to set for each player- Returns:
- team
-
removeTeam
Removes a team by its name.- Parameters:
name- name of team- Returns:
- if there was a team with than name
-
removeTeam
Removes a team.- Parameters:
team- team to remove- Throws:
IllegalArgumentException- if the provided team is not owned by this TeamManager
-
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 addteamDisplayFunction- a function that provides the team display to set for each team- Returns:
- whether the player was added
-
addPlayers
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 addteamDisplayFunction- 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
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:
-