Package me.deecaad.core.tick
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).
create(Plugin, ServerImplementation) and shut it down on plugin disable.-
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a tickable.static @NotNull TickManagercreate(@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 exposesServer#isOwnedByCurrentRegion(Location), otherwise a Bukkit shared-loop variant.voidshutdown()Cancels all scheduled work and callsTickable.remove()on every registered tickable.
-
Method Details
-
add
Registers a tickable. From this point on,Tickable.tick()is invoked once per tick on the appropriate thread until it returnstrue(or this manager is shut down).- Parameters:
tickable- The non-null tickable to register.
-
shutdown
void shutdown()Cancels all scheduled work and callsTickable.remove()on every registered tickable. Safe to call multiple times; subsequentadd(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 exposesServer#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.
-