🕙Delayed Timers
Delay a task from being ran
Overview
The DelayedTimer
class provides a utility for scheduling delayed tasks in Bukkit.
Methods
scheduleDelayedTask
scheduleDelayedTask
public static BukkitTask scheduleDelayedTask(Plugin plugin, long delay, Runnable task)
Schedules a delayed task to run after a specified delay.
Parameters
plugin
: The plugin instance that is scheduling the task.delay
: The delay in server ticks before the task should be executed.task
: The task to be executed after the delay.
Returns
Returns the BukkitTask representing the scheduled task.
Usage
Call the
scheduleDelayedTask
method and pass the plugin instance, delay in ticks, and the task to be executed as parameters.
Example
Plugin plugin = // your plugin instance
long delay = 20; // 20 ticks (1 second)
Runnable task = () -> {
// Your task logic here
};
BukkitTask scheduledTask = DelayedTimer.scheduleDelayedTask(plugin, delay, task);
In this example, we schedule a delayed task using the scheduleDelayedTask
method. The task will run after a delay of 20 ticks (1 second).
Last updated