Class OpenContextImpl
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.internal.context.AbstractViewContext
tech.guilhermekaua.spigotboot.inventoryapi.internal.context.OpenContextImpl
- All Implemented Interfaces:
OpenContext,ViewContext,StateBackedContext
Context for
View.onOpen: records per-open overrides and the cancel decision.
No container exists yet, so inventory(), update() and
updateTitle(String) throw IllegalStateException naming the phase.-
Constructor Summary
ConstructorsConstructorDescriptionOpenContextImpl(@NotNull ViewSession session, @NotNull ViewEngine engine) Creates the context for one open attempt. -
Method Summary
Modifier and TypeMethodDescriptionvoidAborts this open with zero side effects; the player's current view is untouched.@NotNull org.bukkit.inventory.InventoryReturns the top container of this session.booleanReturns whetherOpenContext.cancelOpen()was called for this open.@Nullable IntegerReturns the per-open rows override recorded inonOpen.@Nullable StringReturns the per-open title override recorded inonOpen.voidoverrideRows(int rows) Overrides the configured row count for this open only.voidoverrideTitle(@NotNull String title) Overrides the configured title for this open only.voidupdate()Runs a full update pass (UpdateTrigger.EXPLICIT) synchronously:onUpdatefollowed by a component repaint.voidupdateTitle(@NotNull String title) Updates the container title in place (no reopen) via the title updater: placeholders are applied forViewContext.player()when enabled by the view config, then legacy&color codes are translated.Methods inherited from class tech.guilhermekaua.spigotboot.inventoryapi.internal.context.AbstractViewContext
arguments, close, config, contextActive, engine, isActive, openView, openView, owner, player, playerId, plugin, session, stateStore, view
-
Constructor Details
-
OpenContextImpl
Creates the context for one open attempt.- Parameters:
session- the session being openedengine- the engine executing the open
-
-
Method Details
-
overrideTitle
Description copied from interface:OpenContextOverrides the configured title for this open only.- Specified by:
overrideTitlein interfaceOpenContext- Parameters:
title- the per-open title, legacy color codes supported
-
overrideRows
public void overrideRows(int rows) Description copied from interface:OpenContextOverrides the configured row count for this open only.- Specified by:
overrideRowsin interfaceOpenContext- Parameters:
rows- the per-open row count, 1 to 6
-
cancelOpen
public void cancelOpen()Description copied from interface:OpenContextAborts this open with zero side effects; the player's current view is untouched.- Specified by:
cancelOpenin interfaceOpenContext
-
isOpenCancelled
public boolean isOpenCancelled()Description copied from interface:OpenContextReturns whetherOpenContext.cancelOpen()was called for this open.- Specified by:
isOpenCancelledin interfaceOpenContext- Returns:
truewhen this open is cancelled
-
overriddenTitle
Returns the per-open title override recorded inonOpen.- Returns:
- the overridden title, or
nullwhen none was recorded
-
overriddenRows
Returns the per-open rows override recorded inonOpen.- Returns:
- the overridden row count, or
nullwhen none was recorded
-
inventory
@NotNull public @NotNull org.bukkit.inventory.Inventory inventory()Description copied from interface:ViewContextReturns the top container of this session.- Specified by:
inventoryin interfaceViewContext- Overrides:
inventoryin classAbstractViewContext- Returns:
- the Bukkit inventory backing this view
-
update
public void update()Description copied from interface:ViewContextRuns a full update pass (UpdateTrigger.EXPLICIT) synchronously:onUpdatefollowed by a component repaint. State written during the pass is coalesced into a single trailing flush. Main thread only.- Specified by:
updatein interfaceViewContext- Overrides:
updatein classAbstractViewContext
-
updateTitle
Description copied from interface:ViewContextUpdates the container title in place (no reopen) via the title updater: placeholders are applied forViewContext.player()when enabled by the view config, then legacy&color codes are translated. Main thread only.- Specified by:
updateTitlein interfaceViewContext- Overrides:
updateTitlein classAbstractViewContext- Parameters:
title- the new title, legacy color codes supported
-