-
Notifications
You must be signed in to change notification settings - Fork 0
Tasks
Larrox edited this page Aug 29, 2025
·
3 revisions
The TaskUtil is a utility in LarroxUtilsAPI that allows you to easily schedule tasks on the Bukkit main thread.
It supports running tasks immediately, with a delay, or repeatedly in customizable time intervals.
Note
import dev.larrox.TaskUtil;TaskUtil taskUtil = new TaskUtil(MAIN_CLASS);- Run tasks instantly on the main thread.
- Schedule tasks with delays (seconds, minutes, hours, days).
- Schedule repeating tasks with flexible intervals.
taskUtil.run(() -> {
Bukkit.broadcastMessage("This runs instantly!");
});taskUtil.runLater(() -> {
Bukkit.broadcastMessage("1 minute has passed!");
}, 0, 0, 1, 0, 0);taskUtil.runLater(() -> {
Bukkit.broadcastMessage("2 days and 5 seconds later...");
}, 2, 0, 0, 5, 0);taskUtil.runTimer(() -> {
Bukkit.broadcastMessage("Repeating every 5 seconds!");
}, 0, 0, 0, 10, 0,
0, 0, 0, 5, 0);taskUtil.runTimer(() -> {
Bukkit.broadcastMessage("This message shows once per day!");
}, 0, 1, 0, 0, 0,
1, 0, 0, 0, 0);- Use
run()for instant execution on the main thread. - Use
runLater()for delayed single runs. - Use
runTimer()for scheduled repeating tasks. - Always initialize
TaskUtilwith your plugin’s main class (JavaPlugininstance).