Interface UiSession<R>

Type Parameters:
R - the answer type
All Known Subinterfaces:
GridSession
All Known Implementing Classes:
RuntimeGridSession, RuntimeSession

@NonExtendable public interface UiSession<R>
One shown intent. Thread-safe.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Chooses Closed(CLOSED_BY_CODE) if no outcome has been chosen yet, at once and from any thread.
    The originally submitted intent.
    boolean
    Whether no outcome has been chosen yet.
    The outcome.
    org.bukkit.entity.Player
    The viewer.
  • Method Details

    • viewer

      org.bukkit.entity.Player viewer()
      The viewer.
    • intent

      UiIntent<R> intent()
      The originally submitted intent.
    • result

      The outcome. Completes exactly once, with the outcome chosen first (see 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 CompletionStage rules, 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 with RejectedExecutionException; use scheduler.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 returns false, GridSession.update(Grid) does nothing and later reports are ignored; the screen is closed and result() completed afterwards, as described there.
    • close

      void close()
      Chooses Closed(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.