Interface AsyncScheduler
public interface AsyncScheduler
Scheduler that may be used by plugins to schedule tasks to execute asynchronously from the server tick process.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelTasks
(@NotNull Plugin plugin) Attempts to cancel all tasks scheduled by the specified plugin.runAtFixedRate
(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, long initialDelay, long period, @NotNull TimeUnit unit) Schedules the specified task to be executed asynchronously after the initial delay has passed, and then periodically executed with the specified period.runDelayed
(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, long delay, @NotNull TimeUnit unit) Schedules the specified task to be executed asynchronously after the time delay has passed.Schedules the specified task to be executed asynchronously immediately.
-
Method Details
-
runNow
Schedules the specified task to be executed asynchronously immediately.- Parameters:
plugin
- Plugin which owns the specified task.task
- Specified task.- Returns:
- The
ScheduledTask
that represents the scheduled task.
-
runDelayed
@NotNull ScheduledTask runDelayed(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, long delay, @NotNull TimeUnit unit) Schedules the specified task to be executed asynchronously after the time delay has passed.- Parameters:
plugin
- Plugin which owns the specified task.task
- Specified task.delay
- The time delay to pass before the task should be executed.unit
- The time unit for the time delay.- Returns:
- The
ScheduledTask
that represents the scheduled task.
-
runAtFixedRate
@NotNull ScheduledTask runAtFixedRate(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, long initialDelay, long period, @NotNull TimeUnit unit) Schedules the specified task to be executed asynchronously after the initial delay has passed, and then periodically executed with the specified period.- Parameters:
plugin
- Plugin which owns the specified task.task
- Specified task.initialDelay
- The time delay to pass before the first execution of the task.period
- The time between task executions after the first execution of the task.unit
- The time unit for the initial delay and period.- Returns:
- The
ScheduledTask
that represents the scheduled task.
-
cancelTasks
Attempts to cancel all tasks scheduled by the specified plugin.- Parameters:
plugin
- Specified plugin.
-