Interface PlayerService
public interface PlayerService
Service for player-related queries within Zentrix games.
This service provides access to player information, including their game state, statistics, and team membership.
Example Usage
PlayerService playerService = ZentrixProvider.get().getPlayerService();
// Get a player's game representation
Optional<ZentrixPlayer> zentrixPlayer = playerService.getPlayer(player);
zentrixPlayer.ifPresent(zp -> {
int kills = zp.getGameKills();
boolean alive = zp.isAlive();
});
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanareInSameGame(@NotNull UUID playerId1, @NotNull UUID playerId2) Checks if two players are in the same game by UUID.booleanareInSameGame(@NotNull org.bukkit.entity.Player player1, @NotNull org.bukkit.entity.Player player2) Checks if two players are in the same game.@NotNull Collection<ZentrixPlayer> Gets all players currently in any game (alive only).@NotNull Collection<ZentrixPlayer> Gets all spectators currently watching any game.intgetGameKills(@NotNull UUID playerId) Gets the number of kills a player has in their current game by UUID.intgetGameKills(@NotNull org.bukkit.entity.Player player) Gets the number of kills a player has in their current game.@NotNull Optional<ZentrixPlayer> getPlayer(@NotNull ZentrixGame game, @NotNull UUID playerId) Gets a player within a specific game.@NotNull Optional<ZentrixPlayer> Gets a player's Zentrix representation by UUID if they are in a game.@NotNull Optional<ZentrixPlayer> getPlayer(@NotNull org.bukkit.entity.Player player) Gets a player's Zentrix representation if they are in a game.@NotNull Collection<ZentrixPlayer> getPlayersInGame(@NotNull ZentrixGame game) Gets all players in a specific game.@NotNull Collection<ZentrixPlayer> getSpectatorsInGame(@NotNull ZentrixGame game) Gets all spectators in a specific game.booleanChecks if a player is currently alive in any game by UUID.booleanisAlive(@NotNull org.bukkit.entity.Player player) Checks if a player is currently alive in any game.booleanisSpectating(@NotNull UUID playerId) Checks if a player is spectating any game by UUID.booleanisSpectating(@NotNull org.bukkit.entity.Player player) Checks if a player is spectating any game.
-
Method Details
-
getPlayer
@NotNull @NotNull Optional<ZentrixPlayer> getPlayer(@NotNull @NotNull org.bukkit.entity.Player player) Gets a player's Zentrix representation if they are in a game.- Parameters:
player- The Bukkit player- Returns:
- Optional containing the ZentrixPlayer, or empty if not in a game
-
getPlayer
Gets a player's Zentrix representation by UUID if they are in a game.- Parameters:
playerId- The player's UUID- Returns:
- Optional containing the ZentrixPlayer, or empty if not in a game
-
getPlayer
@NotNull @NotNull Optional<ZentrixPlayer> getPlayer(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull UUID playerId) Gets a player within a specific game.- Parameters:
game- The game to search inplayerId- The player's UUID- Returns:
- Optional containing the ZentrixPlayer, or empty if not found
-
getAllPlayers
Gets all players currently in any game (alive only).- Returns:
- An unmodifiable collection of all players in games (never null)
-
getAllSpectators
Gets all spectators currently watching any game.- Returns:
- An unmodifiable collection of all spectators (never null)
-
isAlive
boolean isAlive(@NotNull @NotNull org.bukkit.entity.Player player) Checks if a player is currently alive in any game.- Parameters:
player- The player to check- Returns:
trueif the player is alive in a game
-
isAlive
Checks if a player is currently alive in any game by UUID.- Parameters:
playerId- The player's UUID- Returns:
trueif the player is alive in a game
-
isSpectating
boolean isSpectating(@NotNull @NotNull org.bukkit.entity.Player player) Checks if a player is spectating any game.- Parameters:
player- The player to check- Returns:
trueif the player is spectating a game
-
isSpectating
Checks if a player is spectating any game by UUID.- Parameters:
playerId- The player's UUID- Returns:
trueif the player is spectating a game
-
getGameKills
int getGameKills(@NotNull @NotNull org.bukkit.entity.Player player) Gets the number of kills a player has in their current game.Returns 0 if the player is not in a game.
- Parameters:
player- The player- Returns:
- The kill count, or 0 if not in a game
-
getGameKills
Gets the number of kills a player has in their current game by UUID.- Parameters:
playerId- The player's UUID- Returns:
- The kill count, or 0 if not in a game
-
getPlayersInGame
Gets all players in a specific game.- Parameters:
game- The game- Returns:
- An unmodifiable collection of players (never null)
-
getSpectatorsInGame
Gets all spectators in a specific game.- Parameters:
game- The game- Returns:
- An unmodifiable collection of spectators (never null)
-
areInSameGame
boolean areInSameGame(@NotNull @NotNull org.bukkit.entity.Player player1, @NotNull @NotNull org.bukkit.entity.Player player2) Checks if two players are in the same game.- Parameters:
player1- First playerplayer2- Second player- Returns:
trueif both players are in the same game
-
areInSameGame
Checks if two players are in the same game by UUID.- Parameters:
playerId1- First player's UUIDplayerId2- Second player's UUID- Returns:
trueif both players are in the same game
-