Interface GameService


public interface GameService
Service for game management and query operations.

This service provides read-only access to game state and information. Use the events system to react to game state changes.

Example Usage


 GameService gameService = ZentrixProvider.get().getGameService();

 // Get all active games
 Collection<ZentrixGame> games = gameService.getActiveGames();

 // Check if player is in a game
 if (gameService.isInGame(player)) {
     ZentrixGame game = gameService.getPlayerGame(player).orElseThrow();
     // Do something with the game
 }
 
Since:
1.0.0
  • Method Details

    • getActiveGames

      @NotNull @NotNull Collection<ZentrixGame> getActiveGames()
      Gets all currently active games.

      Active games include games in any state: WAITING, STARTING, PLAYING, ENDING, or RESTARTING.

      Returns:
      An unmodifiable collection of all active games (never null, may be empty)
    • getGame

      @NotNull @NotNull Optional<ZentrixGame> getGame(@NotNull @NotNull String gameId)
      Gets a game by its unique identifier.
      Parameters:
      gameId - The game's unique ID
      Returns:
      Optional containing the game, or empty if not found
    • getPlayerGame

      @NotNull @NotNull Optional<ZentrixGame> getPlayerGame(@NotNull @NotNull org.bukkit.entity.Player player)
      Gets the game a player is currently in.

      This includes both active players and spectators.

      Parameters:
      player - The player to check
      Returns:
      Optional containing the game, or empty if player is not in any game
    • getPlayerGame

      @NotNull @NotNull Optional<ZentrixGame> getPlayerGame(@NotNull @NotNull UUID playerId)
      Gets the game a player is currently in by UUID.

      This includes both active players and spectators.

      Parameters:
      playerId - The player's UUID
      Returns:
      Optional containing the game, or empty if player is not in any game
    • isInGame

      boolean isInGame(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks if a player is currently in any game.

      This returns true for both active players and spectators.

      Parameters:
      player - The player to check
      Returns:
      true if the player is in a game (playing or spectating)
    • isInGame

      boolean isInGame(@NotNull @NotNull UUID playerId)
      Checks if a player is currently in any game by UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      true if the player is in a game (playing or spectating)
    • isSpectating

      boolean isSpectating(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks if a player is spectating a game.

      Spectators are players who have been eliminated but are still watching the game, or players who joined as spectators.

      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 a game by UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      true if the player is spectating a game
    • isPlaying

      boolean isPlaying(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks if a player is actively playing (alive) in a game.

      This returns true only for alive players, not spectators.

      Parameters:
      player - The player to check
      Returns:
      true if the player is alive in a game
    • isPlaying

      boolean isPlaying(@NotNull @NotNull UUID playerId)
      Checks if a player is actively playing (alive) in a game by UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      true if the player is alive in a game
    • getActiveGameCount

      int getActiveGameCount()
      Gets the total number of active games.
      Returns:
      The count of active games
    • getGamesForArena

      @NotNull @NotNull Collection<ZentrixGame> getGamesForArena(@NotNull @NotNull String arenaName)
      Gets all games running on a specific arena.

      Multiple game instances can run on the same arena template.

      Parameters:
      arenaName - The arena name
      Returns:
      Collection of games for that arena (never null, may be empty)
    • getGamesByState

      @NotNull @NotNull Collection<ZentrixGame> getGamesByState(@NotNull ZentrixGame.GameState state)
      Gets all games in a specific state.
      Parameters:
      state - The game state to filter by
      Returns:
      Collection of games in that state (never null, may be empty)
    • getTotalPlayerCount

      int getTotalPlayerCount()
      Gets the total number of players across all active games.

      This includes only alive players, not spectators.

      Returns:
      Total player count across all games
    • getAvailableArenas

      @NotNull @NotNull Collection<String> getAvailableArenas()
      Gets all available arena names.
      Returns:
      Collection of arena names (never null, may be empty)