Class GamePhaseChangeEvent

java.lang.Object
org.bukkit.event.Event

public class GamePhaseChangeEvent extends ZentrixGameEvent
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:
  • 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 occurred
      newPhase - The new phase that is starting
      oldPhase - The previous phase (may be null for the first phase)
      changeType - The type of phase change
  • Method Details

    • getNewPhase

      @NotNull public @NotNull GamePhase getNewPhase()
      Gets the new phase that is starting.
      Returns:
      The new phase (never null)
    • getOldPhase

      @NotNull public @NotNull Optional<GamePhase> 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

      @NotNull public @NotNull GamePhaseChangeEvent.PhaseChangeType 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:
      true if this is the first phase
    • getPhaseName

      @NotNull public @NotNull String getPhaseName()
      Gets the name of the new phase.

      Convenience method equivalent to getNewPhase().getName().

      Returns:
      The phase name (never null)
    • getPhaseDisplayName

      @NotNull public @NotNull String 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:
      true if 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:
      true if this phase triggers deathmatch
    • isNormalProgression

      public boolean isNormalProgression()
      Checks if this is a normal phase progression event.
      Returns:
      true if the change type is GamePhaseChangeEvent.PhaseChangeType.PHASE_START
    • isPaused

      public boolean isPaused()
      Checks if the phase system was paused.
      Returns:
      true if the change type is GamePhaseChangeEvent.PhaseChangeType.PHASE_PAUSED
    • isResumed

      public boolean isResumed()
      Checks if the phase system was resumed.
      Returns:
      true if the change type is GamePhaseChangeEvent.PhaseChangeType.PHASE_RESUMED
    • isStopped

      public boolean isStopped()
      Checks if the phase system was stopped.
      Returns:
      true if the change type is GamePhaseChangeEvent.PhaseChangeType.PHASE_STOPPED
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Gets the handler list for this event.
      Overrides:
      getHandlers in class ZentrixGameEvent
      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