java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.session.ViewSession

@Internal public final class ViewSession extends Object
Runtime state of one (player, open) pair: lifecycle status, container, effective config, resolved layout, component table, state storage and deferred end-of-tick operations.

Created in ViewSession.Status.OPENING by the open phase and mutated only by the engine on the main thread; everything here is dropped when the session closes.

  • Constructor Details

    • ViewSession

      public ViewSession(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull RegisteredView registered, @NotNull @NotNull ViewArguments arguments, @NotNull @NotNull StateStore stateStore)
      Creates a session in ViewSession.Status.OPENING.
      Parameters:
      player - the viewer
      registered - the registration of the opened view
      arguments - the arguments this open was requested with
      stateStore - the per-session state storage, sized for the view's token table
  • Method Details

    • player

      @NotNull public @NotNull org.bukkit.entity.Player player()
      Returns the viewer of this session.
      Returns:
      the player
    • registered

      @NotNull public @NotNull RegisteredView registered()
      Returns the registration of the opened view.
      Returns:
      the registered view
    • arguments

      @NotNull public @NotNull ViewArguments arguments()
      Returns the arguments this open was requested with.
      Returns:
      the open arguments; empty when none were passed
    • stateStore

      @NotNull public @NotNull StateStore stateStore()
      Returns the per-session state storage.
      Returns:
      the state store
    • components

      @NotNull public @NotNull ComponentTable components()
      Returns this session's component table; one stable instance for the session's lifetime.
      Returns:
      the component table
    • status

      @NotNull public @NotNull ViewSession.Status status()
      Returns the current lifecycle status.
      Returns:
      the status
    • status

      public void status(@NotNull @NotNull ViewSession.Status s)
      Sets the lifecycle status; called only by the engine.
      Parameters:
      s - the new status
    • inventory

      @Nullable public @Nullable org.bukkit.inventory.Inventory inventory()
      Returns the top container of this session.
      Returns:
      the container, or null until the open phase creates it
    • inventory

      public void inventory(@NotNull @NotNull org.bukkit.inventory.Inventory inv)
      Sets the top container once it is created.
      Parameters:
      inv - the created container
    • effectiveConfig

      @NotNull public @NotNull ViewConfig effectiveConfig()
      Returns the effective configuration of this session: the registered config until the open phase applies per-open overrides.
      Returns:
      the effective config, never null
    • effectiveConfig

      public void effectiveConfig(@NotNull @NotNull ViewConfig c)
      Sets the effective configuration after per-open overrides were merged.
      Parameters:
      c - the merged config
    • layout

      @Nullable public @Nullable ResolvedLayout layout()
      Returns the resolved layout of this session.
      Returns:
      the resolved layout, or null until layout resolution ran
    • layout

      public void layout(@NotNull @NotNull ResolvedLayout l)
      Sets the resolved layout.
      Parameters:
      l - the resolved layout
    • updateTask

      @Nullable public @Nullable PlatformTask updateTask()
      Returns the scheduled update task of this session.
      Returns:
      the task, or null when scheduling is disabled or not started
    • updateTask

      public void updateTask(@Nullable @Nullable PlatformTask t)
      Sets or clears the scheduled update task.
      Parameters:
      t - the task, or null to clear it
    • isActive

      public boolean isActive()
      Returns whether this session is currently active.
      Returns:
      true only while the status is ViewSession.Status.ACTIVE
    • deferredOps

      @NotNull public @NotNull List<Runnable> deferredOps()
      Returns the operations deferred to the end of the current tick; the engine appends during click dispatch and drains in FIFO order at tick end, removing each op from the queue before it runs. Ops left behind by a session that closed before the tick are cleared by the close phase, and each queued op is guarded by the engine so it no-ops against a closed session either way.
      Returns:
      the mutable deferred-operations list, one stable instance per session