Skip to content

GameStopEvent

The GameStopEvent is triggered after a TNT Run game has been forcefully stopped and all internal cleanup logic has been executed. Unlike GameEndEvent, which marks the natural end of the competition, this event marks the point where the game world and players have been restored.


  • Package: dev.despical.tntrun.api.event.game
  • Parent Class: GameEvent
  • Cancellable: No

The event provides a StopReason to help you determine why the game was stopped.

ReasonDescription
STOP_COMMANDAn administrator manually stopped the game via command.
SERVER_RELOADThe plugin detected a server reload.
SERVER_SHUTDOWNThe server is shutting down.
ARENA_DELETEDThe arena was deleted while the game existed.

When this event is called, the following cleanup has already occurred:

  • UI Removal: Scoreboards and boss bars have been removed.
  • Player Restoration: Inventories, health, food, flight, and potion effects have been reset.
  • Teleportation: Players have been moved to the configured end location.
  • Visibility: Player visibility rules have been disabled.
  • Game List: The active user list has been cleared.

This event inherits all utility methods from the base GameEvent class.

MethodReturn TypeDescription
getGame()GameReturns the game instance that has stopped.
getStopReason()StopReasonReturns the reason why the game was stopped.
getStoppedPlayers()List<UUID>Returns the players that were in the game before cleanup.

This example shows how to perform final logging once the game is officially closed.

import dev.despical.tntrun.api.event.game.GameStopEvent;
import dev.despical.tntrun.game.StopReason;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class FinalCleanupListener implements Listener {
@EventHandler
public void onGameStop(GameStopEvent event) {
String arenaId = event.getArena().getId();
StopReason reason = event.getStopReason();
System.out.println("TNT Run arena " + arenaId + " stopped. Reason: " + reason);
if (reason == StopReason.SERVER_SHUTDOWN) {
// Urgent cleanup logic
}
}
}