Skip to content

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.


  • Package: io.greenmc.santasays.api.event.task
  • Parent Class: TaskEvent
  • Cancellable: No

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

MethodReturn TypeDescription
getGame()GameReturns the game instance where the task is starting.
getTask()TaskReturns the specific task that is about to begin.

It is important to distinguish this from the round start:

  1. RoundStartEvent: The system prepares for a new round and selects a task.
  2. Task Registration: The selected task is initialized.
  3. TaskStartEvent (This event): The last chance to initialize task-specific state or UI before the timer starts.
  4. Task Start: The task begins, and players receive their instructions.

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);
}
}
}