Interface PhaseService


public interface PhaseService
Service for accessing game phase information within Zentrix.

This service provides access to phase configurations, current phase state, and phase-related queries for active games.

Example Usage


 PhaseService phaseService = ZentrixProvider.get().getPhaseService();

 // Get all configured phases
 Collection<GamePhase> phases = phaseService.getAllPhases();

 // Get current phase for a game
 Optional<GamePhase> currentPhase = phaseService.getCurrentPhase(game);
 currentPhase.ifPresent(phase -> {
     String name = phase.getName();
     int timeLeft = phaseService.getTimeRemaining(game);
     player.sendMessage("Phase: " + name + " - Time left: " + timeLeft + "s");
 });
 
Since:
1.0.0
  • Method Details

    • getAllPhases

      @NotNull @NotNull Collection<GamePhase> getAllPhases()
      Gets all configured game phases.

      These are the phases defined in the phases.yml configuration file. The collection is ordered by phase sequence.

      Returns:
      An unmodifiable collection of all phases (never null, may be empty)
    • getPhase

      @NotNull @NotNull Optional<GamePhase> getPhase(@NotNull @NotNull String phaseName)
      Gets a phase by its name.
      Parameters:
      phaseName - The phase name (case-insensitive)
      Returns:
      Optional containing the phase, or empty if not found
    • getCurrentPhase

      @NotNull @NotNull Optional<GamePhase> getCurrentPhase(@NotNull @NotNull ZentrixGame game)
      Gets the current active phase for a game.

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

      Parameters:
      game - The game
      Returns:
      Optional containing the current phase, or empty if not in a phase
    • getCurrentPhaseIndex

      int getCurrentPhaseIndex(@NotNull @NotNull ZentrixGame game)
      Gets the index of the current phase for a game (0-based).

      Returns -1 if no phase is active.

      Parameters:
      game - The game
      Returns:
      The phase index, or -1 if not in a phase
    • getTimeRemaining

      int getTimeRemaining(@NotNull @NotNull ZentrixGame game)
      Gets the time remaining in the current phase, in seconds.

      Returns 0 if no phase is active.

      Parameters:
      game - The game
      Returns:
      Seconds remaining in current phase
    • getTimeElapsed

      int getTimeElapsed(@NotNull @NotNull ZentrixGame game)
      Gets the elapsed time in the current phase, in seconds.

      Returns 0 if no phase is active.

      Parameters:
      game - The game
      Returns:
      Seconds elapsed in current phase
    • getPhaseCount

      int getPhaseCount()
      Gets the total number of configured phases.
      Returns:
      The phase count
    • getNextPhase

      @NotNull @NotNull Optional<GamePhase> getNextPhase(@NotNull @NotNull ZentrixGame game)
      Gets the next phase after the current one for a game.

      Returns empty if there is no next phase (current is the last) or if no phase is active.

      Parameters:
      game - The game
      Returns:
      Optional containing the next phase, or empty if none
    • getPreviousPhase

      @NotNull @NotNull Optional<GamePhase> getPreviousPhase(@NotNull @NotNull ZentrixGame game)
      Gets the previous phase before the current one for a game.

      Returns empty if there is no previous phase (current is the first) or if no phase is active.

      Parameters:
      game - The game
      Returns:
      Optional containing the previous phase, or empty if none
    • isInPhase

      boolean isInPhase(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull String phaseName)
      Checks if a game is currently in a specific phase.
      Parameters:
      game - The game
      phaseName - The phase name to check
      Returns:
      true if the game is in the specified phase
    • hasCompletedAllPhases

      boolean hasCompletedAllPhases(@NotNull @NotNull ZentrixGame game)
      Checks if a game has completed all phases.

      Returns true if the game has finished its last phase.

      Parameters:
      game - The game
      Returns:
      true if all phases are complete
    • isPaused

      boolean isPaused(@NotNull @NotNull ZentrixGame game)
      Checks if phase system is paused for a game.
      Parameters:
      game - The game
      Returns:
      true if phases are paused
    • getTotalPhaseDuration

      int getTotalPhaseDuration()
      Gets the total duration of all phases combined, in seconds.
      Returns:
      Total phase duration
    • getPhaseByIndex

      @NotNull @NotNull Optional<GamePhase> getPhaseByIndex(int index)
      Gets a phase by its index (0-based).
      Parameters:
      index - The phase index
      Returns:
      Optional containing the phase, or empty if index is out of bounds
    • hasBorderShrinkage

      boolean hasBorderShrinkage(@NotNull @NotNull ZentrixGame game)
      Checks if the current phase for a game has border shrinkage enabled.
      Parameters:
      game - The game
      Returns:
      true if current phase has border shrinkage
    • getTargetBorderSize

      double getTargetBorderSize(@NotNull @NotNull ZentrixGame game)
      Gets the target border size for the current phase.

      Returns 0 if no phase is active or no border config exists.

      Parameters:
      game - The game
      Returns:
      The target border size, or 0 if not applicable