Class AnnoyingScheduler

java.lang.Object
xyz.srnyx.annoyingapi.scheduler.AnnoyingScheduler
All Implemented Interfaces:
Annoyable

public class AnnoyingScheduler extends Object implements Annoyable
A scheduler for running tasks on Bukkit or Folia
  • Constructor Details

  • Method Details

    • getAnnoyingPlugin

      @NotNull public @NotNull AnnoyingPlugin getAnnoyingPlugin()
      Description copied from interface: Annoyable
      The AnnoyingPlugin instance
      Specified by:
      getAnnoyingPlugin in interface Annoyable
      Returns:
      the plugin instance
    • runSync

      @NotNull public @NotNull TaskWrapper runSync(@NotNull @NotNull Runnable runnable)
      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 TaskWrapper containing the scheduled task
    • attemptAsync

      @NotNull public @NotNull Optional<TaskWrapper> attemptAsync(@NotNull @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
      Parameters:
      runnable - the task to run
      Returns:
      an Optional containing a TaskWrapper if the task was scheduled, or an empty Optional if 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 run
      delay - tick delay before the task starts
      Returns:
      a TaskWrapper containing the task and its type
    • 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 run
      delay - tick delay before the task starts
      Returns:
      a TaskWrapper containing the task and its type
    • 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 run
      delay - tick delay before the task starts
      interval - tick interval between each execution of the task
      Returns:
      a TaskWrapper containing the task and its type
    • 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 run
      delay - tick delay before the task starts
      interval - tick interval between each execution of the task
      Returns:
      a TaskWrapper containing the task and its type