Class GameStateChangeEvent
java.lang.Object
org.bukkit.event.Event
dev.despical.whackme.api.event.WhackMeEvent
dev.despical.whackme.api.event.game.GameEvent
dev.despical.whackme.api.event.game.GameStateChangeEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
Called immediately before a Whack Me game changes state.
The game still reports getOldState() during dispatch. Cancelling the
event prevents assignment of getNewState() and prevents the target
state's first tick from running.
@EventHandler
public void onStateChange(GameStateChangeEvent event) {
if (event.getNewState() == GameState.IN_GAME && maintenanceMode) {
event.setCancelled(true);
}
}
API note: Cancelling internal recovery transitions such as
RESTARTING may leave a game occupied. Listeners should only cancel a
transition when they also manage the resulting lifecycle.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionGameStateChangeEvent(Game game, GameState oldState, GameState newState) Creates a state change event. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.event.HandlerList@NotNull org.bukkit.event.HandlerListReturns the requested destination state.Returns the state assigned when the event was fired.booleanReturns whether the state transition has been cancelled.voidsetCancelled(boolean cancel) Sets whether the requested transition should be prevented.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
GameStateChangeEvent
-
-
Method Details
-
getOldState
Returns the state assigned when the event was fired.- Returns:
- current state before the transition
-
getNewState
Returns the requested destination state.- Returns:
- state that will be assigned unless cancelled
-
isCancelled
public boolean isCancelled()Returns whether the state transition has been cancelled.- Specified by:
isCancelledin interfaceorg.bukkit.event.Cancellable- Returns:
truewhen the old state must be retained
-
setCancelled
public void setCancelled(boolean cancel) Sets whether the requested transition should be prevented.- Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable- Parameters:
cancel-trueto retain the old state
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlersin classorg.bukkit.event.Event
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()
-