Skip to content

Commit 1704f3e

Browse files
committed
Improve registry-registed dialogs phrasing
1 parent 53e888e commit 1704f3e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/content/docs/paper/dev/api/dialogs.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ the `Server Links...` button. This button only appears if server links are prese
6262
## Creating dialogs dynamically
6363
You can build a [`Dialog`](jd:paper:io.papermc.paper.dialog.Dialog) object using the [`Dialog#create`](jd:paper:io.papermc.paper.dialog.Dialog#create(java.util.function.Consumer))
6464
method. The consumer parameter allows you to build the dialog. **A dialog always requires a base and a type**, which
65-
can be declared in the builder. In order to create a new dialog, you first call `.empty()` on the consumer parameter.
66-
You can alternatively modify an existing [registry-registered](#registering-dialogs-in-the-registry) dialog instead
67-
of starting from scratch.
65+
can be declared in the builder. You can either create a new dialog or alternatively use an existing
66+
[registry-registered](#registering-dialogs-in-the-registry) dialog as a base instead.
6867

6968
For reference, a very simple (notice-type) dialog can be constructed and shown to a player with the following code:
7069
```java
@@ -144,16 +143,25 @@ The type primarily influences the bottom part of the dialog.
144143
If you want dialogs to be registered in the dialogs registry, you must register them inside a registry modification lifecycle
145144
event in your plugin's bootstrapper. Some general information on that can be read [here](/paper/dev/registries).
146145

146+
:::tip
147+
148+
The advantage of registering dialogs in the registry is that it allows you to use that same dialog
149+
elsewhere in your code without having to pass around the `Dialog` object. This also allows the dialog
150+
to be referenced in commands with a dialog parameter.
151+
152+
:::
153+
147154
The general registration looks fairly similar to dynamically created dialogs:
148155
```java title="YourPluginBootstrapper.java" showLineNumbers
149156
@Override
150157
public void bootstrap(BootstrapContext context) {
151158
context.getLifecycleManager().registerEventHandler(RegistryEvents.DIALOG.compose()
152159
.newHandler(event -> event.registry().register(
153160
DialogKeys.create(Key.key("papermc:custom_dialog")),
154-
builder -> {
155-
// ... build your dialog here
156-
}
161+
builder -> builder
162+
// Build your dialog here ...
163+
.base(DialogBase.builder(Component.text("Title")).build())
164+
.type(DialogType.notice())
157165
)));
158166
}
159167
```

0 commit comments

Comments
 (0)