Class RuntimeUiService

java.lang.Object
com.ultikits.ultitools.ui.runtime.RuntimeUiService
All Implemented Interfaces:
ContainerHost, UiService

@Internal final class RuntimeUiService extends Object implements UiService, ContainerHost
One module copy's view of the shared session registry and item-delivery lifecycle.
  • Field Details

  • Constructor Details

    • RuntimeUiService

      RuntimeUiService(UiRuntime runtime, UiOwner owner, boolean unloaded)
  • Method Details

    • owner

      public String owner()
      Description copied from interface: UiService
      Owning module's name, for diagnostics.
      Specified by:
      owner in interface UiService
    • show

      public <R> UiSession<R> show(org.bukkit.entity.Player viewer, UiIntent<R> intent)
      Description copied from interface: UiService
      Shows an intent with intent-dependent defaults.
      Specified by:
      show in interface UiService
    • show

      public GridSession show(org.bukkit.entity.Player viewer, Grid grid)
      Description copied from interface: UiService
      Shows a grid with intent-dependent defaults.
      Specified by:
      show in interface UiService
    • show

      public GridSession show(org.bukkit.entity.Player viewer, Grid grid, ShowOptions options)
      Description copied from interface: UiService
      Shows a grid with explicit options.
      Specified by:
      show in interface UiService
    • show

      public <R> UiSession<R> show(org.bukkit.entity.Player viewer, UiIntent<R> intent, ShowOptions options)
      Description copied from interface: UiService
      Shows an intent with explicit options.
      Specified by:
      show in interface UiService
    • newSession

      private <R> RuntimeSession<R> newSession(org.bukkit.entity.Player viewer, UiIntent<R> intent)
    • container

      public SlotContainer container(ContainerSpec spec)
      Description copied from interface: UiService
      A new container owned by this module. Call on the server thread (the container's thread).
      Specified by:
      container in interface UiService
    • deliver

      public CompletionStage<Delivery> deliver(org.bukkit.entity.Player player, List<org.bukkit.inventory.ItemStack> items)
      Description copied from interface: UiService
      Gives items to player: into the storage slots of their inventory (never armour or off-hand), the rest dropped at their feet. Runs in a task of the player's entity context; if that task cannot run because the player has quit, or the player is offline when it runs, nothing is given and every item not yet given is in Delivery.undelivered(). During the owner's unload, a call on the unloading thread gives at once, before it returns; a call from another thread during the unload, or any call after it, gives nothing and returns a stage already completed with every item undelivered. The stage always completes normally, exactly once. May be called from any thread.
      Specified by:
      deliver in interface UiService
    • flushDeliveries

      void flushDeliveries()
    • returnTo

      public CompletionStage<Delivery> returnTo(UUID contributor, List<org.bukkit.inventory.ItemStack> items)
      Description copied from interface: ContainerHost
      Returns items to a contributor through UiService#deliver semantics (offline: all undelivered).
      Specified by:
      returnTo in interface ContainerHost
    • changed

      public void changed(SlotContainer container)
      Description copied from interface: ContainerHost
      Contents or state of container changed: redraw every session that shows it before the next tick ends.
      Specified by:
      changed in interface ContainerHost
    • warn

      public void warn(LogRecord record)
      Description copied from interface: ContainerHost
      Logs record (WARNING or higher, message already naming the owner) through the runtime's logger.
      Specified by:
      warn in interface ContainerHost
    • scheduler

      public Scheduler scheduler()
      Description copied from interface: ContainerHost
      The scheduler the runtime uses (tests: the RecordingScheduler wrapper).
      Specified by:
      scheduler in interface ContainerHost
    • copyItems

      private static List<org.bukkit.inventory.ItemStack> copyItems(List<org.bukkit.inventory.ItemStack> items)
    • undelivered

      private static Delivery undelivered(List<org.bukkit.inventory.ItemStack> items)
    • amount

      private static org.bukkit.inventory.ItemStack amount(org.bukkit.inventory.ItemStack item, int count)