Interface ZentrixGame


public interface ZentrixGame
Read-only view of a Zentrix Battle Royale game instance.

It exposes game state, players, teams, and other game information. Addons cannot modify game state through this interface; use events and services.

Example


 ZentrixGame game = ZentrixProvider.get().getGameService()
     .getPlayerGame(player).orElse(null);

 if (game != null) {
     // Read game information
     String arena = game.getArenaName();
     int playerCount = game.getPlayerCount();
     GameState state = game.getState();

     // Check the phase
     game.getCurrentPhase().ifPresent(phase -> {
         String phaseName = phase.getName();
         int timeLeft = phase.getTimeRemaining();
     });
 }
 
Since:
1.0.0
  • Method Details

    • getGameId

      @NotNull @NotNull String getGameId()
      Gets the unique identifier for this game instance.

      This legacy ID combines the copied arena name and object hash. Prefer getRuntimeId() for the canonical copied game-* ID.

      Returns:
      The unique game ID (never null)
    • getRuntimeId

      @NotNull default @NotNull String getRuntimeId()
      Canonical copied runtime identifier (normally game-*).
    • getSourceArenaName

      @NotNull default @NotNull Optional<String> getSourceArenaName()
      Source/template arena used to create this runtime game, when known.
    • getArenaName

      @NotNull @NotNull String getArenaName()
      Gets the arena name this game is running on.

      This legacy value is the copied runtime arena name. Use getSourceArenaName() for the source/template arena.

      Returns:
      The arena name (never null)
    • getState

      @NotNull @NotNull ZentrixGame.GameState getState()
      Gets the current state of this game.
      Returns:
      The current game state (never null)
    • isPlaying

      default boolean isPlaying()
      Checks if the game is currently in the playing state.
      Returns:
      true if the game state is ZentrixGame.GameState.PLAYING
    • isWaiting

      default boolean isWaiting()
      Checks if the game is waiting for players.
      Returns:
      true if the game state is ZentrixGame.GameState.WAITING
    • getPlayers

      @NotNull @NotNull Collection<ZentrixPlayer> getPlayers()
      Gets all players currently alive in this game.

      This does not include spectators or eliminated players.

      Returns:
      An unmodifiable collection of alive players (never null, may be empty)
    • getSpectators

      @NotNull @NotNull Collection<ZentrixPlayer> getSpectators()
      Gets all spectators watching this game.

      Spectators include eliminated players who stayed to watch and players who joined specifically to spectate.

      Returns:
      An unmodifiable collection of spectators (never null, may be empty)
    • getAllParticipants

      @NotNull @NotNull Collection<ZentrixPlayer> getAllParticipants()
      Gets all participants in this game (players and spectators).
      Returns:
      An unmodifiable collection of all participants (never null, may be empty)
    • getPlayer

      @NotNull @NotNull Optional<ZentrixPlayer> getPlayer(@NotNull @NotNull UUID playerId)
      Gets a player by their UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      Optional containing the player, or empty if not found
    • hasPlayer

      boolean hasPlayer(@NotNull @NotNull UUID playerId)
      Checks if a player is in this game (playing or spectating).
      Parameters:
      playerId - The player's UUID
      Returns:
      true if the player is in this game
    • getPlayerCount

      int getPlayerCount()
      Gets the number of alive players in this game.
      Returns:
      The count of alive players
    • getSpectatorCount

      int getSpectatorCount()
      Gets the number of spectators in this game.
      Returns:
      The count of spectators
    • getTeams

      @NotNull @NotNull Collection<ZentrixTeam> getTeams()
      Gets all teams in this game.
      Returns:
      An unmodifiable collection of teams (never null, may be empty)
    • getAliveTeams

      @NotNull @NotNull Collection<ZentrixTeam> getAliveTeams()
      Gets teams that still have alive members.
      Returns:
      An unmodifiable collection of alive teams (never null, may be empty)
    • getTeam

      @NotNull @NotNull Optional<ZentrixTeam> getTeam(@NotNull @NotNull String teamId)
      Gets a team by its ID.
      Parameters:
      teamId - The team ID (e.g., "team-1")
      Returns:
      Optional containing the team, or empty if not found
    • getAliveTeamCount

      @Deprecated(since="1.8.0") int getAliveTeamCount()
      Deprecated.
      since 1.8.0; ambiguous in solo matches. Use getAliveSideCount().
      Gets the number of alive teams.

      Legacy semantics, kept unchanged: in a match played without teams this counts the players still playing, as each is their own side, even though getAliveTeams() is empty there. It is therefore the number of alive sides, not of alive teams. Use getAliveSideCount() for sides and getAliveTeams().size() for teams.

      Returns:
      The count of alive sides
    • isTeamMode

      default boolean isTeamMode()
      Whether this match is played in teams.

      Settled when the match starts and fixed for the rest of it; before that it follows the current configuration of the game type and of arena-management.solo-teams.

      Returns:
      true when players compete as teams
      Since:
      1.8.0
    • isTeamModeLocked

      default boolean isTeamModeLocked()
      Whether isTeamMode() is fixed for this match, which it is from the start on.
      Returns:
      true once the match's team mode can no longer change
      Since:
      1.8.0
    • getCompetingSides

      @NotNull default @NotNull List<CompetingSide> getCompetingSides()
      Gets every side competing in this match: its teams in team mode, otherwise its players.

      In team mode every team of the match is included, eliminated ones too. Without teams the sides are the players still playing, followed by the players this match eliminated who are still watching it; a player who has left is no longer listed. The list is a snapshot.

      Returns:
      The sides (never null, may be empty)
      Since:
      1.8.0
    • getAliveSideCount

      default int getAliveSideCount()
      Gets the number of sides still competing: alive teams in team mode, otherwise players still playing. This is the count win conditions use.
      Returns:
      The count of alive sides
      Since:
      1.8.0
    • getCurrentPhase

      @NotNull @NotNull Optional<GamePhase> getCurrentPhase()
      Gets the current game phase, if the game is playing.

      Returns empty if the game hasn't started or has ended.

      Returns:
      Optional containing the current phase, or empty if not in a phase
    • getWorld

      @Nullable @Nullable org.bukkit.World getWorld()
      Gets the game world.

      May return null if the world hasn't been created yet (e.g., during WAITING state before arena copy).

      Returns:
      The game world, or null if not yet available
    • getGameTypeName

      @NotNull @NotNull String getGameTypeName()
      Gets the game type name (e.g., "solo", "duo", "squad").
      Returns:
      The game type name (never null)
    • getMaxPlayers

      int getMaxPlayers()
      Gets the maximum number of players for this game type.
      Returns:
      The maximum player capacity
    • getMinPlayers

      int getMinPlayers()
      Gets the minimum number of players required to start.
      Returns:
      The minimum player count
    • getTeamSize

      int getTeamSize()
      Gets the team size for this game type.

      Returns 1 for solo games.

      Returns:
      The team size
    • getPhaseTimeRemaining

      int getPhaseTimeRemaining()
      Gets the time remaining in the current phase, in seconds.

      Returns 0 if no phase is active.

      Returns:
      Seconds remaining in current phase
    • getGameDuration

      long getGameDuration()
      Gets the total game duration so far, in seconds.

      Starts counting from when the game enters PLAYING state.

      Returns:
      Game duration in seconds, or 0 if game hasn't started
    • getWorldBorderSize

      double getWorldBorderSize()
      Gets the current world border size.

      Returns 0 if the world is not available.

      Returns:
      The world border diameter in blocks
    • broadcast

      void broadcast(@NotNull @NotNull String message)
      Sends a message to all players and spectators in this game.

      Supports MiniMessage format and legacy color codes.

      Parameters:
      message - The message to send
    • broadcastLocalized

      void broadcastLocalized(@NotNull @NotNull String key, @NotNull @NotNull Object... placeholders)
      Sends a localized message to all players and spectators.

      Uses Zentrix's locale system with placeholder support.

      Parameters:
      key - The locale key
      placeholders - Placeholder pairs (key, value, key, value, ...)