Package dev.itsharshxd.zentrix.api.phase
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 Summary
Modifier and TypeMethodDescription@NotNull Collection<GamePhase> Gets all configured game phases.getCurrentPhase(@NotNull ZentrixGame game) Gets the current active phase for a game.intgetCurrentPhaseIndex(@NotNull ZentrixGame game) Gets the index of the current phase for a game (0-based).getNextPhase(@NotNull ZentrixGame game) Gets the next phase after the current one for a game.Gets a phase by its name.getPhaseByIndex(int index) Gets a phase by its index (0-based).intGets the total number of configured phases.getPreviousPhase(@NotNull ZentrixGame game) Gets the previous phase before the current one for a game.doublegetTargetBorderSize(@NotNull ZentrixGame game) Gets the target border size for the current phase.intgetTimeElapsed(@NotNull ZentrixGame game) Gets the elapsed time in the current phase, in seconds.intgetTimeRemaining(@NotNull ZentrixGame game) Gets the time remaining in the current phase, in seconds.intGets the total duration of all phases combined, in seconds.booleanhasBorderShrinkage(@NotNull ZentrixGame game) Checks if the current phase for a game has border shrinkage enabled.booleanhasCompletedAllPhases(@NotNull ZentrixGame game) Checks if a game has completed all phases.booleanisInPhase(@NotNull ZentrixGame game, @NotNull String phaseName) Checks if a game is currently in a specific phase.booleanisPaused(@NotNull ZentrixGame game) Checks if phase system is paused for a game.
-
Method Details
-
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
Gets a phase by its name.- Parameters:
phaseName- The phase name (case-insensitive)- Returns:
- Optional containing the phase, or empty if not found
-
getCurrentPhase
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
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
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
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
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
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
Checks if a game is currently in a specific phase.- Parameters:
game- The gamephaseName- The phase name to check- Returns:
trueif the game is in the specified phase
-
hasCompletedAllPhases
Checks if a game has completed all phases.Returns true if the game has finished its last phase.
- Parameters:
game- The game- Returns:
trueif all phases are complete
-
isPaused
Checks if phase system is paused for a game.- Parameters:
game- The game- Returns:
trueif phases are paused
-
getTotalPhaseDuration
int getTotalPhaseDuration()Gets the total duration of all phases combined, in seconds.- Returns:
- Total phase duration
-
getPhaseByIndex
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
Checks if the current phase for a game has border shrinkage enabled.- Parameters:
game- The game- Returns:
trueif current phase has border shrinkage
-
getTargetBorderSize
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
-