Class ViewSession
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.session.ViewSession
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionViewSession(@NotNull org.bukkit.entity.Player player, @NotNull RegisteredView registered, @NotNull ViewArguments arguments, @NotNull StateStore stateStore) Creates a session inViewSession.Status.OPENING. -
Method Summary
Modifier and TypeMethodDescription@NotNull ViewArgumentsReturns the arguments this open was requested with.@NotNull ComponentTableReturns this session's component table; one stable instance for the session's lifetime.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.@NotNull ViewConfigReturns the effective configuration of this session: the registered config until the open phase applies per-open overrides.voideffectiveConfig(@NotNull ViewConfig c) Sets the effective configuration after per-open overrides were merged.@Nullable org.bukkit.inventory.InventoryReturns the top container of this session.voidinventory(@NotNull org.bukkit.inventory.Inventory inv) Sets the top container once it is created.booleanisActive()Returns whether this session is currently active.@Nullable ResolvedLayoutlayout()Returns the resolved layout of this session.voidlayout(@NotNull ResolvedLayout l) Sets the resolved layout.@NotNull org.bukkit.entity.Playerplayer()Returns the viewer of this session.@NotNull RegisteredViewReturns the registration of the opened view.@NotNull StateStoreReturns the per-session state storage.@NotNull ViewSession.Statusstatus()Returns the current lifecycle status.voidstatus(@NotNull ViewSession.Status s) Sets the lifecycle status; called only by the engine.@Nullable PlatformTaskReturns the scheduled update task of this session.voidupdateTask(@Nullable PlatformTask t) Sets or clears the scheduled update task.
-
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 inViewSession.Status.OPENING.- Parameters:
player- the viewerregistered- the registration of the opened viewarguments- the arguments this open was requested withstateStore- 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
Returns the registration of the opened view.- Returns:
- the registered view
-
arguments
Returns the arguments this open was requested with.- Returns:
- the open arguments; empty when none were passed
-
stateStore
Returns the per-session state storage.- Returns:
- the state store
-
components
Returns this session's component table; one stable instance for the session's lifetime.- Returns:
- the component table
-
status
Returns the current lifecycle status.- Returns:
- the status
-
status
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
nulluntil 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
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
Sets the effective configuration after per-open overrides were merged.- Parameters:
c- the merged config
-
layout
Returns the resolved layout of this session.- Returns:
- the resolved layout, or
nulluntil layout resolution ran
-
layout
Sets the resolved layout.- Parameters:
l- the resolved layout
-
updateTask
Returns the scheduled update task of this session.- Returns:
- the task, or
nullwhen scheduling is disabled or not started
-
updateTask
Sets or clears the scheduled update task.- Parameters:
t- the task, ornullto clear it
-
isActive
public boolean isActive()Returns whether this session is currently active.- Returns:
trueonly while the status isViewSession.Status.ACTIVE
-
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
-