Class AsyncScheduler
java.lang.Object
io.github.retrooper.packetevents.util.folia.AsyncScheduler
Represents a scheduler for executing tasks asynchronously.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel
(@NotNull org.bukkit.plugin.Plugin plugin) Attempts to cancel all tasks scheduled by the specified plugin.runAtFixedRate
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<Object> task, long initialDelayTicks, long periodTicks) Schedules the specified task to be executed asynchronously after the initial delay has passed, and then periodically executed.runAtFixedRate
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<Object> task, long delay, long period, @NotNull TimeUnit timeUnit) Schedules the specified task to be executed asynchronously after the initial delay has passed, and then periodically executed with the specified period.runDelayed
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<Object> task, long delay, @NotNull TimeUnit timeUnit) Schedules the specified task to be executed asynchronously after the specified delay.Schedules the specified task to be executed asynchronously immediately.
-
Constructor Details
-
AsyncScheduler
protected AsyncScheduler()
-
-
Method Details
-
runNow
public TaskWrapper runNow(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task) Schedules the specified task to be executed asynchronously immediately.- Parameters:
plugin
- Plugin which owns the specified task.task
- Specified task.- Returns:
TaskWrapper
instance representing a wrapped task
-
runDelayed
public TaskWrapper runDelayed(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task, long delay, @NotNull @NotNull TimeUnit timeUnit) Schedules the specified task to be executed asynchronously after the specified delay.- Parameters:
plugin
- Plugin which owns the specified task.task
- Specified task.delay
- The time delay to pass before the task should be executed.timeUnit
- The time unit for the time delay.- Returns:
TaskWrapper
instance representing a wrapped task
-
runAtFixedRate
public TaskWrapper runAtFixedRate(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task, long delay, long period, @NotNull @NotNull TimeUnit timeUnit) 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.delay
- The time delay to pass before the task should be executed.period
- The time period between each task execution. Any value less-than 1 is treated as 1.timeUnit
- The time unit for the initial delay and period.- Returns:
TaskWrapper
instance representing a wrapped task
-
runAtFixedRate
public TaskWrapper runAtFixedRate(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task, long initialDelayTicks, long periodTicks) Schedules the specified task to be executed asynchronously after the initial delay has passed, and then periodically executed.- Parameters:
plugin
- Plugin which owns the specified task.task
- Specified task.initialDelayTicks
- The time delay in ticks to pass before the task should be executed.periodTicks
- The time period in ticks between each task execution. Any value less-than 1 is treated as 1.- Returns:
TaskWrapper
instance representing a wrapped task
-
cancel
public void cancel(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) Attempts to cancel all tasks scheduled by the specified plugin.- Parameters:
plugin
- Specified plugin.
-