TaskStartEvent
The TaskStartEvent is fired immediately before a task begins its execution logic. While RoundStartEvent signals the beginning of the round transition, this event is focused strictly on the lifecycle of an individual task.
Technical Overview
Section titled “Technical Overview”- Package:
io.greenmc.santasays.api.event.task - Parent Class:
TaskEvent - Cancellable: No
Methods
Section titled “Methods”This event inherits all utility methods from the base TaskEvent class.
| Method | Return Type | Description |
|---|---|---|
getGame() | Game | Returns the game instance where the task is starting. |
getTask() | Task | Returns the specific task that is about to begin. |
Lifecycle Timing
Section titled “Lifecycle Timing”It is important to distinguish this from the round start:
- RoundStartEvent: The system prepares for a new round and selects a task.
- Task Registration: The selected task is initialized.
- TaskStartEvent (This event): The last chance to initialize task-specific state or UI before the timer starts.
- Task Start: The task begins, and players receive their instructions.
Example Usage
Section titled “Example Usage”This example demonstrates how to play a specific sound or send a custom action bar message when a task starts.
import io.greenmc.santasays.api.event.task.TaskStartEvent;import org.bukkit.Sound;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;
public class TaskInitListener implements Listener {
@EventHandler public void onTaskStart(TaskStartEvent event) { String taskName = event.getTask().getName();
// Notify all players in the game that a task is starting for (Player player : event.getGame().getPlayers()) { player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f); player.sendActionBar("§fNew Task: §6§l" + taskName); } }}