Interface GamePhase
Game phases define the stages of a Battle Royale match, including timing, border behavior, and actions that occur when the phase starts.
Example Usage
PhaseService phaseService = ZentrixProvider.get().getPhaseService();
// Get current phase for a game
Optional<GamePhase> phase = phaseService.getCurrentPhase(game);
phase.ifPresent(p -> {
String name = p.getName();
String display = p.getDisplayName();
int duration = p.getDuration();
if (p.hasBorderShrinkage()) {
double targetSize = p.getBorderTargetSize();
player.sendMessage("Border shrinking to " + targetSize + " blocks!");
}
});
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the damage per block when outside the border.intGets the duration of the border shrink animation in seconds.doubleGets the target border size after shrinkage.@NotNull StringGets the display name of this phase.intGets the duration of this phase in seconds.@NotNull StringgetName()Gets the internal name of this phase.intGets the number of on-start actions configured for this phase.default doubleGets the progress through this phase as a percentage.intGets the time elapsed in this phase.intGets the time remaining in this phase.Checks if this phase enables PvP.intGets the warning time before the phase ends, in seconds.booleanChecks if this phase has border configuration.booleanChecks if the world border shrinks during this phase.booleanChecks if this phase has any on-start actions configured.booleanChecks if this phase has a warning configured.booleanChecks if this phase starts the deathmatch.
-
Method Details
-
getName
Gets the internal name of this phase.This is the identifier used in configuration files.
- Returns:
- The phase name (never null)
-
getDisplayName
Gets the display name of this phase.This is the formatted name shown to players, with color codes. Falls back to the internal name if not set.
- Returns:
- The display name (never null)
-
getDuration
int getDuration()Gets the duration of this phase in seconds.- Returns:
- Duration in seconds
-
hasBorderConfig
boolean hasBorderConfig()Checks if this phase has border configuration.- Returns:
trueif border settings are configured
-
hasBorderShrinkage
boolean hasBorderShrinkage()Checks if the world border shrinks during this phase.- Returns:
trueif border shrinkage is enabled
-
getBorderTargetSize
double getBorderTargetSize()Gets the target border size after shrinkage.Returns 0 if no border shrinkage is configured.
- Returns:
- Target border diameter in blocks
-
getBorderShrinkDuration
int getBorderShrinkDuration()Gets the duration of the border shrink animation in seconds.Returns 0 if no border shrinkage is configured.
- Returns:
- Shrink duration in seconds
-
getBorderDamagePerBlock
double getBorderDamagePerBlock()Gets the damage per block when outside the border.Returns 0 if no border configuration exists.
- Returns:
- Damage per block per second
-
getWarningTime
int getWarningTime()Gets the warning time before the phase ends, in seconds.A warning may be shown to players when this time remains. Returns 0 if no warning is configured.
- Returns:
- Warning time in seconds
-
hasWarning
boolean hasWarning()Checks if this phase has a warning configured.- Returns:
trueif a warning is configured
-
hasOnStartActions
boolean hasOnStartActions()Checks if this phase has any on-start actions configured.Actions can include announcements, titles, sounds, effects, etc.
- Returns:
trueif actions are configured
-
getOnStartActionCount
int getOnStartActionCount()Gets the number of on-start actions configured for this phase.- Returns:
- The action count
-
getTimeRemaining
int getTimeRemaining()Gets the time remaining in this phase.This is only meaningful when retrieved from an active game context. When retrieved from configuration, returns the full duration.
- Returns:
- Time remaining in seconds
-
getTimeElapsed
int getTimeElapsed()Gets the time elapsed in this phase.This is only meaningful when retrieved from an active game context. When retrieved from configuration, returns 0.
- Returns:
- Time elapsed in seconds
-
getProgress
default double getProgress()Gets the progress through this phase as a percentage.Returns a value between 0.0 (just started) and 1.0 (complete).
- Returns:
- Progress percentage (0.0 to 1.0)
-
getTogglePvP
Checks if this phase enables PvP.Some phases may toggle PvP state when they start.
- Returns:
trueif this phase enables PvP,falseif it disables PvP, empty if PvP state is not changed
-
startsDeathmatch
boolean startsDeathmatch()Checks if this phase starts the deathmatch.- Returns:
trueif this phase triggers deathmatch
-