Skip to content

GameStateChangeEvent

GameStateChangeEvent fires before Whack Me assigns a new game state.


MethodReturn typeDescription
getOldState()GameStateState still assigned during event dispatch.
getNewState()GameStateRequested destination.
isCancelled()booleanWhether the transition will be prevented.
setCancelled(boolean)voidRetain the old state when true.
getGame()GameRelated live game.
getArena()ArenaRelated arena.

States are INACTIVE, WAITING, IN_GAME, ENDING, and RESTARTING.

Cancelling prevents the assignment and the destination state’s first tick.

@EventHandler
public void onStateChange(GameStateChangeEvent event) {
if (event.getNewState() == GameState.IN_GAME && maintenanceArenas.contains(event.getArena().getId())) {
event.setCancelled(true);
}
}