Skip to content

TaskEvent

The TaskEvent class is an abstract base for all events occurring during the lifecycle of a Task. It provides developers with the necessary context to identify which game is active and exactly which task is being executed.


  • Package: io.greenmc.santasays.api.event.task
  • Parent Class: SantaSaysEvent

MethodReturn TypeDescription
getGame()GameReturns the Game instance where the task is occurring.
getTask()TaskReturns the specific Task instance associated with this event.

These events inherit all methods from TaskEvent:

  • TaskStartEvent: Fired when a task objective is displayed and the timer starts.
  • TaskEndEvent: Fired when the task timer expires or everyone completes the objective.

When listening to task-related events, you can use the base methods to fetch the name of the task or modify the game environment based on the task type.

import io.greenmc.santasays.api.event.task.TaskStartEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class TaskListener implements Listener {
@EventHandler
public void onTaskStart(TaskStartEvent event) {
// Access data from the base TaskEvent
String taskName = event.getTask().getName();
String arenaName = event.getGame().getArena().getName();
System.out.println("A new task '" + taskName + "' has started in arena: " + arenaName);
}
}