Interface UiSession<R>
- Type Parameters:
R- the answer type
- All Known Subinterfaces:
GridSession
- All Known Implementing Classes:
RuntimeGridSession, RuntimeSession
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()ChoosesClosed(CLOSED_BY_CODE)if no outcome has been chosen yet, at once and from any thread.intent()The originally submitted intent.booleanisOpen()Whether no outcome has been chosen yet.result()The outcome.org.bukkit.entity.Playerviewer()The viewer.
-
Method Details
-
viewer
org.bukkit.entity.Player viewer()The viewer. -
intent
-
result
CompletionStage<UiResult<R>> result()The outcome. Completes exactly once, with the outcome chosen first (seeisOpen()); a minimal stage, so callers cannot complete it.Thread: the stage is completed in a task of the viewer's entity context, or of the global context if the viewer has quit. The one exception is owner unload, which completes it on the unloading thread before the unload returns (on Paper the main thread, which owns every entity context), while the owner's services are still usable. Non-async dependents attached before completion run on the completing thread. Following
CompletionStagerules, a non-async dependent attached after completion runs at once on the attaching thread, which may be an async thread. To touch the player from a dependent whatever thread attaches it, use an async variant with the scheduler:session.result().thenAcceptAsync(result -> ..., scheduler.entity(viewer)). If the viewer has quit by then, that executor rejects the task and the dependent stage completes exceptionally withRejectedExecutionException; usescheduler.global()for work that must run even then. -
isOpen
boolean isOpen()Whether no outcome has been chosen yet. The outcome is chosen, at once and on whatever thread it happens, by the first of: a backend's answer or close report,close(), the timeout, the viewer quitting, another intent opening for the viewer, the owner's unload. From then on this returnsfalse,GridSession.update(Grid)does nothing and later reports are ignored; the screen is closed andresult()completed afterwards, as described there. -
close
void close()ChoosesClosed(CLOSED_BY_CODE)if no outcome has been chosen yet, at once and from any thread. The screen closes and the result completes later, in a task of the viewer's entity context, never inside this call, so calling it from a grid action or an event handler is safe. Idempotent.
-