Interface DialogRegistry


public interface DialogRegistry
  • Method Details

    • register

      @Contract("_, _ -> param2") DialogDefinition register(Key key, DialogDefinition dialog)
      Registers a dialog.
      Parameters:
      key - the key to register it under
      dialog - the dialog to add
      Returns:
      the registered dialog
      Throws:
      IllegalStateException - if a dialog already sits under key; use overwrite(Key, DialogDefinition) to replace it on purpose
      Since:
      0.1.0
    • overwrite

      Optional<DialogDefinition> overwrite(Key key, DialogDefinition dialog)
      Registers a dialog, replacing any dialog already sitting under the same key.
      Parameters:
      key - the key to register it under
      dialog - the dialog to add or replace
      Returns:
      the dialog previously registered under that key, if any
      Since:
      0.1.0
    • unregister

      boolean unregister(Key key)
      Removes a dialog.
      Parameters:
      key - the key to free
      Returns:
      true if a dialog was removed
      Since:
      0.1.0
    • definition

      Optional<DialogDefinition> definition(Key key)
      Returns the dialog registered under key, when this server defines one.

      The three dialogs the vanilla client ships with are known to the registry but carry no definition of their own, so this returns empty for them while contains(Key) returns true.

      Parameters:
      key - the key to look up
      Returns:
      the dialog registered under key, when this server defines one
      Since:
      0.1.0
    • contains

      boolean contains(Key key)
      Returns whether anything is registered under key.
      Parameters:
      key - the key to look up
      Returns:
      whether anything is registered under key
      Since:
      0.1.0
    • keys

      @Contract(pure=true) Collection<Key> keys()
      Returns every registered key, in network order.
      Returns:
      every registered key, in network order
      Since:
      0.1.0
    • networkId

      int networkId(Key key)
      Returns the network identifier of key, or -1 when it is not registered.
      Parameters:
      key - the key to look up
      Returns:
      the network identifier of key, or -1 when it is not registered
      Since:
      0.1.0
    • addToPauseScreen

      void addToPauseScreen(Key key)
      Adds a dialog to the pause menu, under the minecraft:pause_screen_additions tag.

      One tagged dialog is reachable directly; several are gathered behind the built-in minecraft:custom_options screen, which lists them by external title.

      Parameters:
      key - the key of an already registered dialog
      Throws:
      IllegalArgumentException - if nothing is registered under key
      Since:
      0.1.0
    • addToQuickActions

      void addToQuickActions(Key key)
      Adds a dialog to the Quick Actions hotkey, under the minecraft:quick_actions tag.
      Parameters:
      key - the key of an already registered dialog
      Throws:
      IllegalArgumentException - if nothing is registered under key
      Since:
      0.1.0
    • removeFromMenus

      boolean removeFromMenus(Key key)
      Drops a dialog from the pause menu and the quick actions hotkey.
      Parameters:
      key - the key to untag
      Returns:
      true if the dialog carried at least one of the two tags
      Since:
      0.1.0
    • pauseScreenAdditions

      @Contract(pure=true) Collection<Key> pauseScreenAdditions()
      Returns the dialogs reachable from the pause menu.
      Returns:
      the dialogs reachable from the pause menu
      Since:
      0.1.0
    • quickActions

      @Contract(pure=true) Collection<Key> quickActions()
      Returns the dialogs reachable from the quick actions hotkey.
      Returns:
      the dialogs reachable from the quick actions hotkey
      Since:
      0.1.0
    • register

      @Contract("_, _ -> param2") default DialogDefinition register(TypedKey<Dialog> key, DialogDefinition dialog)
      Registers a dialog.
      Parameters:
      key - the typed key to register it under
      dialog - the dialog to add
      Returns:
      the registered dialog
      Throws:
      IllegalStateException - if a dialog already sits under key
      Since:
      0.1.0
    • registerFromJson

      DialogDefinition registerFromJson(Key key, String json)
      Reads a dialog from its data pack JSON representation and registers it.

      The JSON is the very same one a data pack would drop in data/<namespace>/dialog/<name>.json.

      Parameters:
      key - the key to register it under
      json - the JSON object describing the dialog
      Returns:
      the registered dialog
      Throws:
      IllegalArgumentException - if the JSON is malformed or misses a mandatory field
      IllegalStateException - if a dialog already sits under key
      Since:
      0.1.0