Interface TickManager


public interface TickManager
Manages a collection of Tickables, driving each once per tick using the platform's preferred strategy.
  • On Folia, one scheduled region task per Tickable (necessary because regions own different threads).
  • On Spigot/Paper, one shared global task iterates every Tickable (cheaper than N individual tasks when N is large).
Build one with create(Plugin, ServerImplementation) and shut it down on plugin disable.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(@NotNull Tickable tickable)
    Registers a tickable.
    static @NotNull TickManager
    create(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull com.cjcrafter.foliascheduler.ServerImplementation scheduler)
    Returns the manager appropriate for this server: a Folia variant if the server exposes Server#isOwnedByCurrentRegion(Location), otherwise a Bukkit shared-loop variant.
    void
    Cancels all scheduled work and calls Tickable.remove() on every registered tickable.
  • Method Details

    • add

      void add(@NotNull @NotNull Tickable tickable)
      Registers a tickable. From this point on, Tickable.tick() is invoked once per tick on the appropriate thread until it returns true (or this manager is shut down).
      Parameters:
      tickable - The non-null tickable to register.
    • shutdown

      void shutdown()
      Cancels all scheduled work and calls Tickable.remove() on every registered tickable. Safe to call multiple times; subsequent add(Tickable) calls throw.
    • create

      @NotNull static @NotNull TickManager create(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull com.cjcrafter.foliascheduler.ServerImplementation scheduler)
      Returns the manager appropriate for this server: a Folia variant if the server exposes Server#isOwnedByCurrentRegion(Location), otherwise a Bukkit shared-loop variant.
      Parameters:
      plugin - The non-null plugin (used for logging).
      scheduler - The non-null foliascheduler abstraction.
      Returns:
      A non-null tick manager.