TaskEndEvent
The TaskEndEvent is fired immediately after a task has executed its finish() logic. This event focuses strictly on the lifecycle of the individual task that was just played, occurring before the broader round-level cleanup and scoring processes take place.
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 just finished. |
getTask() | Task | Returns the specific task instance that has concluded. |
Lifecycle Timing
Section titled “Lifecycle Timing”It is important to understand the order of execution at the end of a round:
- Task Completion: The task timer hits zero or all players finish.
- Task Finish Logic: Internal
Task#finish()is executed. - TaskEndEvent (This event): Fired for task-specific post-processing.
- Round Cleanup: Scoring is applied, and the round counter increments.
- RoundEndEvent: The broader round-level notification is fired.
Example Usage
Section titled “Example Usage”This example demonstrates how to log the end of a task or perform custom cleanup for external integrations (like clearing custom particles).
import io.greenmc.santasays.api.event.task.TaskEndEvent;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;
public class TaskCleanupListener implements Listener {
@EventHandler public void onTaskEnd(TaskEndEvent event) { String taskName = event.getTask().getName(); int arenaName = event.getGame().getArena().getName();
// Perform custom task-specific logging System.out.println("The task '" + taskName + "' has finished in " + arenaName);
// Example: If you spawned custom entities for this task, clean them up here }}