Package dev.itsharshxd.zentrix.api.team
Interface TeamService
public interface TeamService
Service for team-related queries within Zentrix games.
This service provides access to team information, membership, and team status queries.
Example Usage
TeamService teamService = ZentrixProvider.get().getTeamService();
// Check if two players are teammates
if (teamService.areTeammates(player1, player2)) {
// Don't allow friendly fire, etc.
}
// Get a player's team
Optional<ZentrixTeam> team = teamService.getPlayerTeam(player);
team.ifPresent(t -> {
String teamName = t.getDisplayName();
int aliveMembers = t.getAliveMemberCount();
});
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanareTeammates(@NotNull UUID playerId1, @NotNull UUID playerId2) Checks if two players are on the same team by UUID.booleanareTeammates(@NotNull org.bukkit.entity.Player player1, @NotNull org.bukkit.entity.Player player2) Checks if two players are on the same team.intgetAliveTeamCount(@NotNull ZentrixGame game) Gets the number of alive teams in a game.getAliveTeammates(@NotNull UUID playerId) Gets alive teammates of a player by UUID.getAliveTeammates(@NotNull org.bukkit.entity.Player player) Gets alive teammates of a player (still in the game).@NotNull Collection<ZentrixPlayer> getAliveTeamMembers(@NotNull ZentrixGame game, @NotNull ZentrixTeam team) Gets alive ZentrixPlayer members of a team.@NotNull Collection<ZentrixTeam> getAliveTeams(@NotNull ZentrixGame game) Gets all alive teams in a game.@NotNull Optional<ZentrixTeam> getPlayerTeam(@NotNull ZentrixGame game, @NotNull UUID playerId) Gets the team a player belongs to within a specific game.@NotNull Optional<ZentrixTeam> getPlayerTeam(@NotNull UUID playerId) Gets the team a player belongs to by UUID.@NotNull Optional<ZentrixTeam> getPlayerTeam(@NotNull org.bukkit.entity.Player player) Gets the team a player belongs to.@NotNull Optional<ZentrixTeam> getTeam(@NotNull ZentrixGame game, @NotNull String teamId) Gets a team by its ID within a game.getTeammates(@NotNull UUID playerId) Gets the teammates of a player by UUID.getTeammates(@NotNull org.bukkit.entity.Player player) Gets the teammates of a player (excluding the player themselves).@NotNull Collection<ZentrixPlayer> getTeamMembers(@NotNull ZentrixTeam team) Gets all ZentrixPlayer members of a team.@NotNull Collection<ZentrixTeam> getTeams(@NotNull ZentrixGame game) Gets all teams in a specific game.@NotNull Optional<ZentrixTeam> getWinningTeam(@NotNull ZentrixGame game) Gets the winning team for a game.booleanisTeamEliminated(@NotNull ZentrixGame game, @NotNull ZentrixTeam team) Checks if a team is eliminated.
-
Method Details
-
getTeams
Gets all teams in a specific game.- Parameters:
game- The game- Returns:
- An unmodifiable collection of teams (never null, may be empty)
-
getTeam
@NotNull @NotNull Optional<ZentrixTeam> getTeam(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull String teamId) Gets a team by its ID within a game.- Parameters:
game- The gameteamId- The team ID (e.g., "team-1")- Returns:
- Optional containing the team, or empty if not found
-
getPlayerTeam
@NotNull @NotNull Optional<ZentrixTeam> getPlayerTeam(@NotNull @NotNull org.bukkit.entity.Player player) Gets the team a player belongs to.- Parameters:
player- The player- Returns:
- Optional containing the team, or empty if not in a team
-
getPlayerTeam
Gets the team a player belongs to by UUID.- Parameters:
playerId- The player's UUID- Returns:
- Optional containing the team, or empty if not in a team
-
getPlayerTeam
@NotNull @NotNull Optional<ZentrixTeam> getPlayerTeam(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull UUID playerId) Gets the team a player belongs to within a specific game.- Parameters:
game- The gameplayerId- The player's UUID- Returns:
- Optional containing the team, or empty if not found
-
areTeammates
boolean areTeammates(@NotNull @NotNull org.bukkit.entity.Player player1, @NotNull @NotNull org.bukkit.entity.Player player2) Checks if two players are on the same team.- Parameters:
player1- First playerplayer2- Second player- Returns:
trueif both players are on the same team
-
areTeammates
Checks if two players are on the same team by UUID.- Parameters:
playerId1- First player's UUIDplayerId2- Second player's UUID- Returns:
trueif both players are on the same team
-
getAliveTeams
Gets all alive teams in a game.A team is considered alive if it has at least one member who is still playing (not eliminated).
- Parameters:
game- The game- Returns:
- An unmodifiable collection of alive teams (never null)
-
getAliveTeamCount
Gets the number of alive teams in a game.- Parameters:
game- The game- Returns:
- The count of teams with at least one alive member
-
isTeamEliminated
Checks if a team is eliminated.A team is eliminated when all its members have been killed or left.
- Parameters:
game- The gameteam- The team to check- Returns:
trueif the team has no alive members
-
getTeammates
Gets the teammates of a player (excluding the player themselves).- Parameters:
player- The player- Returns:
- Set of teammate UUIDs (never null, may be empty)
-
getTeammates
Gets the teammates of a player by UUID.- Parameters:
playerId- The player's UUID- Returns:
- Set of teammate UUIDs (never null, may be empty)
-
getAliveTeammates
Gets alive teammates of a player (still in the game).- Parameters:
player- The player- Returns:
- Set of alive teammate UUIDs (never null, may be empty)
-
getAliveTeammates
Gets alive teammates of a player by UUID.- Parameters:
playerId- The player's UUID- Returns:
- Set of alive teammate UUIDs (never null, may be empty)
-
getWinningTeam
Gets the winning team for a game.Returns the team if only one team remains alive.
- Parameters:
game- The game- Returns:
- Optional containing the winning team, or empty if no winner yet
-
getTeamMembers
Gets all ZentrixPlayer members of a team.- Parameters:
team- The team- Returns:
- An unmodifiable collection of team members (never null)
-
getAliveTeamMembers
@NotNull @NotNull Collection<ZentrixPlayer> getAliveTeamMembers(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull ZentrixTeam team) Gets alive ZentrixPlayer members of a team.- Parameters:
game- The gameteam- The team- Returns:
- An unmodifiable collection of alive team members (never null)
-