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 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

      @NotNull @NotNull Optional<ZentrixPlayer> getPlayer(@NotNull @NotNull UUID playerId)
      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 in
      playerId - The player's UUID
      Returns:
      Optional containing the ZentrixPlayer, or empty if not found
    • getAllPlayers

      @NotNull @NotNull Collection<ZentrixPlayer> getAllPlayers()
      Gets all players currently in any game (alive only).
      Returns:
      An unmodifiable collection of all players in games (never null)
    • getAllSpectators

      @NotNull @NotNull Collection<ZentrixPlayer> 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:
      true if the player is alive in a game
    • isAlive

      boolean isAlive(@NotNull @NotNull UUID playerId)
      Checks if a player is currently alive in any game by UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      true if 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:
      true if the player is spectating a game
    • isSpectating

      boolean isSpectating(@NotNull @NotNull UUID playerId)
      Checks if a player is spectating any game by UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      true if 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

      int getGameKills(@NotNull @NotNull UUID playerId)
      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

      @NotNull @NotNull Collection<ZentrixPlayer> getPlayersInGame(@NotNull @NotNull ZentrixGame game)
      Gets all players in a specific game.
      Parameters:
      game - The game
      Returns:
      An unmodifiable collection of players (never null)
    • getSpectatorsInGame

      @NotNull @NotNull Collection<ZentrixPlayer> getSpectatorsInGame(@NotNull @NotNull ZentrixGame game)
      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 player
      player2 - Second player
      Returns:
      true if both players are in the same game
    • areInSameGame

      boolean areInSameGame(@NotNull @NotNull UUID playerId1, @NotNull @NotNull UUID playerId2)
      Checks if two players are in the same game by UUID.
      Parameters:
      playerId1 - First player's UUID
      playerId2 - Second player's UUID
      Returns:
      true if both players are in the same game