Package xyz.srnyx.annoyingapi.scheduler
Class AnnoyingScheduler
java.lang.Object
xyz.srnyx.annoyingapi.parents.AnnoyableClass
xyz.srnyx.annoyingapi.scheduler.AnnoyingScheduler
- All Implemented Interfaces:
Annoyable
A scheduler for running tasks on Bukkit or Folia
-
Field Summary
Fields inherited from class xyz.srnyx.annoyingapi.parents.AnnoyableClass
annoyingPlugin -
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 TaskWrapperrunGlobalTaskLater(@NotNull Consumer<TaskWrapper> 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 Consumer<TaskWrapper> 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 Consumer<TaskWrapper> 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 Consumer<TaskWrapper> 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)Methods inherited from class xyz.srnyx.annoyingapi.parents.AnnoyableClass
getAnnoyingPlugin
-
Constructor Details
-
AnnoyingScheduler
Constructs a newAnnoyingSchedulerinstance- Parameters:
plugin- theAnnoyingPluginthis scheduler belongs to
-
-
Method Details
-
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 Consumer<TaskWrapper> 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 Consumer<TaskWrapper> 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 Consumer<TaskWrapper> 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 Consumer<TaskWrapper> 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
-