Class ViewService
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.service.ViewService
DI facade for opening and closing views. All methods must be called on the main thread.
-
Constructor Summary
ConstructorsConstructorDescriptionViewService(ViewEngine engine, SessionRegistry sessions) Creates the service. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(@NotNull org.bukkit.entity.Player player) Closes the player's open view; no-op when none is open.@NotNull Optional<ViewContext>contextOf(@NotNull org.bukkit.entity.Player player) Returns a live context for the player's open view, if any.voidOpens a registered view for the player without arguments.voidopen(@NotNull org.bukkit.entity.Player player, @NotNull Class<? extends View> view, @NotNull ViewArguments arguments) Opens a registered view for the player with the given arguments.
-
Constructor Details
-
ViewService
Creates the service.- Parameters:
engine- the view engine executing lifecycle operationssessions- the per-player session registry
-
-
Method Details
-
open
public void open(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Class<? extends View> view) Opens a registered view for the player without arguments.- Parameters:
player- the viewerview- the registered view class- Throws:
UnknownViewException- if the view class is not registeredIllegalStateException- if called off the main thread
-
open
public void open(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Class<? extends View> view, @NotNull @NotNull ViewArguments arguments) Opens a registered view for the player with the given arguments.- Parameters:
player- the viewerview- the registered view classarguments- the open arguments- Throws:
UnknownViewException- if the view class is not registeredIllegalStateException- if called off the main thread
-
close
public void close(@NotNull @NotNull org.bukkit.entity.Player player) Closes the player's open view; no-op when none is open.- Parameters:
player- the viewer whose view should close- Throws:
IllegalStateException- if called off the main thread
-
contextOf
@NotNull public @NotNull Optional<ViewContext> contextOf(@NotNull @NotNull org.bukkit.entity.Player player) Returns a live context for the player's open view, if any.- Parameters:
player- the viewer to look up- Returns:
- the live context, or empty when the player has no open view
-