You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/paper/dev/api/dialogs.mdx
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,9 +62,8 @@ the `Server Links...` button. This button only appears if server links are prese
62
62
## Creating dialogs dynamically
63
63
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))
64
64
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.
68
67
69
68
For reference, a very simple (notice-type) dialog can be constructed and shown to a player with the following code:
70
69
```java
@@ -144,16 +143,25 @@ The type primarily influences the bottom part of the dialog.
144
143
If you want dialogs to be registered in the dialogs registry, you must register them inside a registry modification lifecycle
145
144
event in your plugin's bootstrapper. Some general information on that can be read [here](/paper/dev/registries).
146
145
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
+
147
154
The general registration looks fairly similar to dynamically created dialogs:
0 commit comments