Skip to content

GameEvent

The GameEvent class is an abstract base for all events associated with a specific, active game session. It provides developers with direct access to the Game instance and its internal managers, making it the primary entry point for manipulating game logic.


  • Package: dev.despical.tntrun.api.event.game
  • Parent Class: TNTRunEvent

MethodReturn TypeDescription
getGame()GameReturns the active Game instance.
getArena()ArenaShortcut to return the Arena associated with the game.

Through the Game object provided by this event, you can access several core managers to customize the game experience:

  • VisibilityManager: Controls player visibility rules.
  • ScoreboardManager: Updates and manages player scoreboards.
  • ScoreRegistry: Stores and manages player scores and placements.
  • MessageTicker: Displays timed game messages.
  • PlacementMessenger: Handles placement-based announcements.
  • BossBarManager: Controls the boss bar displays for players in the game.

Since GameEvent is the root for game lifecycle notifications, it is implemented by:

  • GameStartEvent: Fired after a game enters active play.
  • GameEndEvent: Fired after a game finishes and enters the ending phase.
  • GameStateChangeEvent: Fired immediately before a game changes state.
  • GameStopEvent: Fired after a game has been forcefully stopped and cleaned up.

When listening to any game-related event, you can easily pull arena settings or check the current game state.

import dev.despical.tntrun.api.event.game.GameStartEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class GameStatusListener implements Listener {
@EventHandler
public void onGameEvent(GameStartEvent event) {
String arenaId = event.getArena().getId();
int players = event.getGame().getUsers().size();
System.out.println("TNT Run started in arena: " + arenaId + " with " + players + " players.");
}
}