GameStartEvent
The GameStartEvent is triggered when a Santa Says game has finished all its internal setup and is about to begin. At this point, players have been teleported, their scores have been reset, and the tasks have been prepared.
Technical Overview
Section titled “Technical Overview”- Package:
io.greenmc.santasays.api.event.game - Parent Class:
GameEvent - Cancellable: No
Methods
Section titled “Methods”This event inherits all utility methods from the base GameEvent class, allowing you to access the Game instance and all its managers.
| Method | Return Type | Description |
|---|---|---|
getGame() | Game | Returns the active Game instance that is starting. |
getArena() | Arena | Shortcut to return the Arena associated with the starting game. |
Lifecycle Notes
Section titled “Lifecycle Notes”When this event is called:
- Player Setup: Players are already in their designated starting positions.
- Score Initialization: The
ScoreRegistryhas been cleared and prepared for the new session. - Ready State: The arena is locked and no longer accepting join attempts.
Example Usage
Section titled “Example Usage”This example demonstrates how to trigger a global sound effect or a custom message to the entire server when a game officially starts.
import io.greenmc.santasays.api.event.game.GameStartEvent;import org.bukkit.Bukkit;import org.bukkit.Sound;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;
public class GlobalAnnouncementListener implements Listener {
@EventHandler public void onGameStart(GameStartEvent event) { String arenaName = event.getArena().getName();
// Notify the whole server Bukkit.broadcastMessage("§6[Santa Says] §eA new game has started in arena: §f" + arenaName);
// Play a start sound for everyone in the game for (Player player : event.getGame().getPlayers()) { player.playSound(player.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0f, 1.0f); } }}