Interface DialogRegistry
public interface DialogRegistry
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddToPauseScreen(Key key) Adds a dialog to the pause menu, under theminecraft:pause_screen_additionstag.voidaddToQuickActions(Key key) Adds a dialog to the Quick Actions hotkey, under theminecraft:quick_actionstag.booleanReturns whether anything is registered underkey.definition(Key key) Returns the dialog registered underkey, when this server defines one.keys()Returns every registered key, in network order.intReturns the network identifier ofkey, or-1when it is not registered.overwrite(Key key, DialogDefinition dialog) Registers a dialog, replacing any dialog already sitting under the same key.Returns the dialogs reachable from the pause menu.Returns the dialogs reachable from the quick actions hotkey.default DialogDefinitionregister(TypedKey<Dialog> key, DialogDefinition dialog) Registers a dialog.register(Key key, DialogDefinition dialog) Registers a dialog.registerFromJson(Key key, String json) Reads a dialog from its data pack JSON representation and registers it.booleanremoveFromMenus(Key key) Drops a dialog from the pause menu and the quick actions hotkey.booleanunregister(Key key) Removes a dialog.
-
Method Details
-
register
Registers a dialog.- Parameters:
key- the key to register it underdialog- the dialog to add- Returns:
- the registered dialog
- Throws:
IllegalStateException- if a dialog already sits underkey; useoverwrite(Key, DialogDefinition)to replace it on purpose- Since:
- 0.1.0
-
overwrite
Registers a dialog, replacing any dialog already sitting under the same key.- Parameters:
key- the key to register it underdialog- the dialog to add or replace- Returns:
- the dialog previously registered under that key, if any
- Since:
- 0.1.0
-
unregister
Removes a dialog.- Parameters:
key- the key to free- Returns:
trueif a dialog was removed- Since:
- 0.1.0
-
definition
Returns the dialog registered underkey, 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)returnstrue.- Parameters:
key- the key to look up- Returns:
- the dialog registered under
key, when this server defines one - Since:
- 0.1.0
-
contains
Returns whether anything is registered underkey.- Parameters:
key- the key to look up- Returns:
- whether anything is registered under
key - Since:
- 0.1.0
-
keys
Returns every registered key, in network order.- Returns:
- every registered key, in network order
- Since:
- 0.1.0
-
networkId
Returns the network identifier ofkey, or-1when it is not registered.- Parameters:
key- the key to look up- Returns:
- the network identifier of
key, or-1when it is not registered - Since:
- 0.1.0
-
addToPauseScreen
Adds a dialog to the pause menu, under theminecraft:pause_screen_additionstag.One tagged dialog is reachable directly; several are gathered behind the built-in
minecraft:custom_optionsscreen, which lists them by external title.- Parameters:
key- the key of an already registered dialog- Throws:
IllegalArgumentException- if nothing is registered underkey- Since:
- 0.1.0
-
addToQuickActions
Adds a dialog to the Quick Actions hotkey, under theminecraft:quick_actionstag.- Parameters:
key- the key of an already registered dialog- Throws:
IllegalArgumentException- if nothing is registered underkey- Since:
- 0.1.0
-
removeFromMenus
Drops a dialog from the pause menu and the quick actions hotkey.- Parameters:
key- the key to untag- Returns:
trueif the dialog carried at least one of the two tags- Since:
- 0.1.0
-
pauseScreenAdditions
Returns the dialogs reachable from the pause menu.- Returns:
- the dialogs reachable from the pause menu
- Since:
- 0.1.0
-
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 underdialog- the dialog to add- Returns:
- the registered dialog
- Throws:
IllegalStateException- if a dialog already sits underkey- Since:
- 0.1.0
-
registerFromJson
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 underjson- the JSON object describing the dialog- Returns:
- the registered dialog
- Throws:
IllegalArgumentException- if the JSON is malformed or misses a mandatory fieldIllegalStateException- if a dialog already sits underkey- Since:
- 0.1.0
-