Package xyz.srnyx.annoyingapi.scheduler
Class AnnoyingScheduler
java.lang.Object
xyz.srnyx.annoyingapi.scheduler.AnnoyingScheduler
- All Implemented Interfaces:
Annoyable
A scheduler for running tasks on Bukkit or Folia
-
Constructor Summary
ConstructorsConstructorDescriptionAnnoyingScheduler(@NotNull AnnoyingPlugin plugin) Constructs a newAnnoyingSchedulerinstance -
Method Summary
Modifier and TypeMethodDescription@NotNull Optional<TaskWrapper> attemptAsync(@NotNull Runnable runnable) Attempt to run a task asynchronously
If running Folia, the task will be run on Folia's global scheduler
If the plugin is disabled, the task will be run synchronously on the current thread@NotNull AnnoyingPluginTheAnnoyingPlugininstance@NotNull TaskWrapperrunGlobalTaskLater(@NotNull Runnable runnable, long delay) Runs a global task at a later time
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)@NotNull TaskWrapperrunGlobalTaskLaterAsync(@NotNull Runnable runnable, long delay) Runs a global task later asynchronously
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)@NotNull TaskWrapperrunGlobalTaskTimer(@NotNull Runnable runnable, long delay, long interval) Runs a global task timer
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)@NotNull TaskWrapperrunGlobalTaskTimerAsync(@NotNull Runnable runnable, long delay, long interval) Runs a global task timer asynchronously
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)@NotNull TaskWrapperAttempt to run a task synchronously on the main server thread
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)
-
Constructor Details
-
AnnoyingScheduler
Constructs a newAnnoyingSchedulerinstance- Parameters:
plugin- theAnnoyingPluginthis scheduler belongs to
-
-
Method Details
-
getAnnoyingPlugin
Description copied from interface:AnnoyableTheAnnoyingPlugininstance- Specified by:
getAnnoyingPluginin interfaceAnnoyable- Returns:
- the plugin instance
-
runSync
Attempt to run a task synchronously on the main server thread
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)- Parameters:
runnable- the task to run- Returns:
- a
TaskWrappercontaining the scheduled task
-
attemptAsync
Attempt to run a task asynchronously
If running Folia, the task will be run on Folia's global scheduler
If the plugin is disabled, the task will be run synchronously on the current thread- Parameters:
runnable- the task to run- Returns:
- an
Optionalcontaining aTaskWrapperif the task was scheduled, or an emptyOptionalif the plugin is disabled
-
runGlobalTaskLater
@NotNull public @NotNull TaskWrapper runGlobalTaskLater(@NotNull @NotNull Runnable runnable, long delay) Runs a global task at a later time
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)- Parameters:
runnable- the task to rundelay- tick delay before the task starts- Returns:
- a
TaskWrappercontaining the task and itstype
-
runGlobalTaskLaterAsync
@NotNull public @NotNull TaskWrapper runGlobalTaskLaterAsync(@NotNull @NotNull Runnable runnable, long delay) Runs a global task later asynchronously
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)- Parameters:
runnable- the task to rundelay- tick delay before the task starts- Returns:
- a
TaskWrappercontaining the task and itstype
-
runGlobalTaskTimer
@NotNull public @NotNull TaskWrapper runGlobalTaskTimer(@NotNull @NotNull Runnable runnable, long delay, long interval) Runs a global task timer
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)- Parameters:
runnable- the task to rundelay- tick delay before the task startsinterval- tick interval between each execution of the task- Returns:
- a
TaskWrappercontaining the task and itstype
-
runGlobalTaskTimerAsync
@NotNull public @NotNull TaskWrapper runGlobalTaskTimerAsync(@NotNull @NotNull Runnable runnable, long delay, long interval) Runs a global task timer asynchronously
If running Folia, the task will be run on Folia's global scheduler (as Folia is inherently asynchronous)- Parameters:
runnable- the task to rundelay- tick delay before the task startsinterval- tick interval between each execution of the task- Returns:
- a
TaskWrappercontaining the task and itstype
-