Skip to content

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.


  • 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 just finished.
getTask()TaskReturns the specific task instance that has concluded.

It is important to understand the order of execution at the end of a round:

  1. Task Completion: The task timer hits zero or all players finish.
  2. Task Finish Logic: Internal Task#finish() is executed.
  3. TaskEndEvent (This event): Fired for task-specific post-processing.
  4. Round Cleanup: Scoring is applied, and the round counter increments.
  5. RoundEndEvent: The broader round-level notification is fired.

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