Interface UiBackend

All Known Implementing Classes:
ChestBackend, DialogBackend

@Internal public interface UiBackend
A rendering backend. Framework-internal in 7.0: modules do not implement it.

Selection: among registered backends whose supports(UiIntent, Player) returns true, the one with the highest priority() opens the intent. Priorities are unique: registering a backend whose priority equals that of an already registered backend fails with IllegalStateException, whatever intents the two support, so selection never depends on registration order. The framework registers its backends at start-up, so a clash is a start-up error.

The service calls supports, open and update in a task of the viewer's entity context; close as stated on close(UiSession). It never calls a backend for a session whose outcome has already been delivered.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    How a backend reports back.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(UiSession<?> session)
    Closes the screen of session if this backend opened it and it is still showing; called at most once per opened session, after the outcome is chosen and before the result completes.
    net.kyori.adventure.key.Key
    id()
    Unique backend identity.
    <R> void
    open(UiSession<R> session, UiBackend.BackendCallbacks<R> callbacks)
    Opens session's intent; reports through callbacks.
    int
    Higher wins; unique among registered backends.
    boolean
    supports(UiIntent<?> intent, org.bukkit.entity.Player viewer)
    Whether this backend can show intent to viewer now.
    void
    update(GridSession session, Grid previous, Grid next)
    Shows next instead of previous on a grid this backend opened, before returning.
  • Method Details

    • id

      net.kyori.adventure.key.Key id()
      Unique backend identity.
    • priority

      int priority()
      Higher wins; unique among registered backends. Framework values: Dialog 100, chest 0.
    • supports

      boolean supports(UiIntent<?> intent, org.bukkit.entity.Player viewer)
      Whether this backend can show intent to viewer now. May depend on the intent's content (for example the inputs of a form) and on the viewer (for example client capabilities).
    • open

      <R> void open(UiSession<R> session, UiBackend.BackendCallbacks<R> callbacks)
      Opens session's intent; reports through callbacks. For a Grid it shows GridSession.current() as it is at this call, which may already differ from the intent.
      Type Parameters:
      R - answer type
    • update

      void update(GridSession session, Grid previous, Grid next)
      Shows next instead of previous on a grid this backend opened, before returning. previous is the snapshot this backend was last given (by open or update). Called only while the session is open. A backend that cannot change the title of a shown screen may reopen it to show a new title; that does not end the session.
    • close

      void close(UiSession<?> session)
      Closes the screen of session if this backend opened it and it is still showing; called at most once per opened session, after the outcome is chosen and before the result completes. Called in a task of the viewer's entity context; in a task of the global context if the viewer has quit, when the screen is already gone and the backend must only release its own bookkeeping; or on the unloading thread during owner unload.