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.
Technical Overview
Section titled “Technical Overview”- Package:
dev.despical.tntrun.api.event.game - Parent Class:
GameEvent - Cancellable: No
Stop Reasons
Section titled “Stop Reasons”The event provides a StopReason to help you determine why the game was stopped.
| Reason | Description |
|---|---|
STOP_COMMAND | An administrator manually stopped the game via command. |
SERVER_RELOAD | The plugin detected a server reload. |
SERVER_SHUTDOWN | The server is shutting down. |
ARENA_DELETED | The arena was deleted while the game existed. |
Post-Event Cleanup State
Section titled “Post-Event Cleanup State”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.
Methods
Section titled “Methods”This event inherits all utility methods from the base GameEvent class.
| Method | Return Type | Description |
|---|---|---|
getGame() | Game | Returns the game instance that has stopped. |
getStopReason() | StopReason | Returns the reason why the game was stopped. |
getStoppedPlayers() | List<UUID> | Returns the players that were in the game before cleanup. |
Example Usage
Section titled “Example Usage”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 } }}