Class BukkitSettleDispatcher

java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.pagination.source.BukkitSettleDispatcher
All Implemented Interfaces:
SettleDispatcher

public final class BukkitSettleDispatcher extends Object implements SettleDispatcher
Default SettleDispatcher: settles route to the viewer's region thread (Folia) or the main thread (legacy Spigot/Paper) via the injected PlatformScheduler.

Routing rules:

  1. No viewer (PageRequest.viewer() is null) — engine-external test usage: settle runs inline on the completing thread.
  2. The calling thread already owns the viewer's region — settle runs inline.
  3. Otherwise — the settle is dispatched to the viewer's entity scheduler.

Dispatch order is FIFO: inline settles run immediately; the scheduler runs same-tick tasks in submission order. AsyncPageSource relies on this — a request's timeout settle must reach the dispatcher before the cancellation settle it triggers.

A settle that is rejected because the owning plugin is disabling (IllegalPluginAccessException) is dropped with a warning: the scheduler will not accept new tasks at that point and the inventory is about to be closed anyway.

  • Constructor Details

    • BukkitSettleDispatcher

      public BukkitSettleDispatcher(@NotNull @NotNull PlatformScheduler scheduler)
      Creates the dispatcher.
      Parameters:
      scheduler - the platform scheduler used to route settles to the viewer's region
  • Method Details

    • dispatch

      public void dispatch(PageRequest request, Runnable task)
      Description copied from interface: SettleDispatcher
      Runs the settle task on the appropriate thread for the given request.
      Specified by:
      dispatch in interface SettleDispatcher
      Parameters:
      request - the request being settled, never null
      task - the settle work, never null