Class RuntimeSession<R>
- Type Parameters:
R- the intent's answer type
- All Implemented Interfaces:
UiSession<R>
- Direct Known Subclasses:
RuntimeGridSession
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) @Nullable UiBackendprivate final CompletableFuture<UiResult<R>> private booleanprivate final ViewerLane(package private) final UiRuntime(package private) final RuntimeUiServiceprivate @Nullable TaskHandle(package private) final org.bukkit.entity.Player(package private) final UUID -
Constructor Summary
ConstructorsConstructorDescriptionRuntimeSession(RuntimeUiService service, org.bukkit.entity.Player viewer, UiIntent<R> intent) -
Method Summary
Modifier and TypeMethodDescriptionprivate UiBackend.BackendCallbacks<R> private voidcancelTimeout(TaskHandle handle) (package private) final boolean(package private) voidvoidclose()ChoosesClosed(CLOSED_BY_CODE)if no outcome has been chosen yet, at once and from any thread.(package private) final void(package private) void(package private) final voidintent()The originally submitted intent.booleanisOpen()Whether no outcome has been chosen yet.(package private) boolean(package private) final voidopenTask(ShowOptions options) No supporting backend leaves the previous session untouched.(package private) final voidrequestChoose(UiResult<R> result) (package private) final voidrequestClose(CloseReason reason) result()The outcome.private voidscheduleTimeout(ShowOptions options) (package private) voidorg.bukkit.entity.Playerviewer()The viewer.
-
Field Details
-
service
-
runtime
-
viewer
final org.bukkit.entity.Player viewer -
viewerId
-
lane
-
intent
-
completion
-
backend
-
timeout
-
chosen
-
finished
private boolean finished
-
-
Constructor Details
-
RuntimeSession
RuntimeSession(RuntimeUiService service, org.bukkit.entity.Player viewer, UiIntent<R> intent)
-
-
Method Details
-
viewer
-
intent
-
result
Description copied from interface:UiSessionThe outcome. Completes exactly once, with the outcome chosen first (seeUiSession.isOpen()); 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
public boolean isOpen()Description copied from interface:UiSessionWhether 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,UiSession.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 andUiSession.result()completed afterwards, as described there. -
isOpenLocked
boolean isOpenLocked() -
close
public void close()Description copied from interface:UiSessionChoosesClosed(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. -
requestClose
-
dispatch
-
requestChoose
-
choose
-
closeAndComplete
final void closeAndComplete() -
openTask
No supporting backend leaves the previous session untouched. Once a supporting backend is selected, replacement is committed before calling open: an open failure leaves the old session REPLACED and never restores its screen. Backends may select an outcome first (chests use INTERRUPTED for rejected opens); an otherwise unhandled open exception selects UNSUPPORTED. -
takeBindings
void takeBindings() -
detachBindings
void detachBindings() -
clicked
-
scheduleTimeout
-
cancelTimeout
-
callbacks
-