Class GamePhaseChangeEvent
java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.ZentrixGameEvent
dev.itsharshxd.zentrix.api.events.game.GamePhaseChangeEvent
Called when a game phase changes in a Zentrix Battle Royale game.
This event is fired whenever a phase transition occurs, including:
- Normal phase progression (one phase ending and the next starting)
- Phase system being paused
- Phase system being resumed
- Phase system being stopped (game ending)
This event is NOT cancellable.
Example Usage
@EventHandler
public void onPhaseChange(GamePhaseChangeEvent event) {
ZentrixGame game = event.getGame();
GamePhase newPhase = event.getNewPhase();
PhaseChangeType changeType = event.getChangeType();
if (changeType == PhaseChangeType.PHASE_START) {
String phaseName = newPhase.getDisplayName();
int duration = newPhase.getDuration();
getLogger().info("New phase: " + phaseName + " (" + duration + "s)");
// Check if this is the final shrink phase
if (newPhase.getName().contains("final")) {
game.broadcast("&c&lFINAL PHASE! Get ready for the final fight!");
}
// React to border shrinkage
if (event.hasBorderShrinkage()) {
double targetSize = newPhase.getBorderTargetSize();
game.broadcast("Border shrinking to " + targetSize + " blocks!");
}
}
}
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the type of phase change that occurred.Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionGamePhaseChangeEvent(@NotNull ZentrixGame game, @NotNull GamePhase newPhase, @Nullable GamePhase oldPhase, @NotNull GamePhaseChangeEvent.PhaseChangeType changeType) Constructs a new GamePhaseChangeEvent. -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the target border size for the new phase.@NotNull GamePhaseChangeEvent.PhaseChangeTypeGets the type of phase change that occurred.static @NotNull org.bukkit.event.HandlerListGets the static handler list for this event type.@NotNull org.bukkit.event.HandlerListGets the handler list for this event.@NotNull GamePhaseGets the new phase that is starting.Gets the previous phase that was active.@NotNull StringGets the display name of the new phase.intGets the duration of the new phase in seconds.@NotNull StringGets the name of the new phase.booleanChecks if the new phase has border shrinkage enabled.booleanChecks if this is the first phase of the game.booleanChecks if this is a normal phase progression event.booleanisPaused()Checks if the phase system was paused.booleanChecks if the phase system was resumed.booleanChecks if the phase system was stopped.booleanChecks if the new phase starts a deathmatch.Methods inherited from class dev.itsharshxd.zentrix.api.events.ZentrixGameEvent
getArenaName, getGame, getGameId, getGameState, getGameTypeName, getPlayerCountMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
GamePhaseChangeEvent
public GamePhaseChangeEvent(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull GamePhase newPhase, @Nullable @Nullable GamePhase oldPhase, @NotNull @NotNull GamePhaseChangeEvent.PhaseChangeType changeType) Constructs a new GamePhaseChangeEvent.- Parameters:
game- The game where the phase change occurrednewPhase- The new phase that is startingoldPhase- The previous phase (may be null for the first phase)changeType- The type of phase change
-
-
Method Details
-
getNewPhase
Gets the new phase that is starting.- Returns:
- The new phase (never null)
-
getOldPhase
Gets the previous phase that was active.Returns empty if this is the first phase of the game.
- Returns:
- Optional containing the previous phase, or empty if this is the first phase
-
getChangeType
Gets the type of phase change that occurred.- Returns:
- The change type (never null)
-
isFirstPhase
public boolean isFirstPhase()Checks if this is the first phase of the game.Returns true when there was no previous phase (oldPhase is null).
- Returns:
trueif this is the first phase
-
getPhaseName
Gets the name of the new phase.Convenience method equivalent to
getNewPhase().getName().- Returns:
- The phase name (never null)
-
getPhaseDisplayName
Gets the display name of the new phase.Convenience method equivalent to
getNewPhase().getDisplayName().- Returns:
- The phase display name (never null)
-
getPhaseDuration
public int getPhaseDuration()Gets the duration of the new phase in seconds.Convenience method equivalent to
getNewPhase().getDuration().- Returns:
- Duration in seconds
-
hasBorderShrinkage
public boolean hasBorderShrinkage()Checks if the new phase has border shrinkage enabled.Convenience method equivalent to
getNewPhase().hasBorderShrinkage().- Returns:
trueif the border will shrink during this phase
-
getBorderTargetSize
public double getBorderTargetSize()Gets the target border size for the new phase.Returns 0 if no border shrinkage is configured.
- Returns:
- Target border diameter in blocks, or 0 if not applicable
-
startsDeathmatch
public boolean startsDeathmatch()Checks if the new phase starts a deathmatch.Convenience method equivalent to
getNewPhase().startsDeathmatch().- Returns:
trueif this phase triggers deathmatch
-
isNormalProgression
public boolean isNormalProgression()Checks if this is a normal phase progression event.- Returns:
trueif the change type isGamePhaseChangeEvent.PhaseChangeType.PHASE_START
-
isPaused
public boolean isPaused()Checks if the phase system was paused.- Returns:
trueif the change type isGamePhaseChangeEvent.PhaseChangeType.PHASE_PAUSED
-
isResumed
public boolean isResumed()Checks if the phase system was resumed.- Returns:
trueif the change type isGamePhaseChangeEvent.PhaseChangeType.PHASE_RESUMED
-
isStopped
public boolean isStopped()Checks if the phase system was stopped.- Returns:
trueif the change type isGamePhaseChangeEvent.PhaseChangeType.PHASE_STOPPED
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Gets the handler list for this event.- Overrides:
getHandlersin classZentrixGameEvent- Returns:
- The handler list
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Gets the static handler list for this event type.- Returns:
- The handler list
-