-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathDialog.java
More file actions
66 lines (57 loc) · 2.6 KB
/
Dialog.java
File metadata and controls
66 lines (57 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package io.papermc.paper.dialog;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryBuilderFactory;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.InlinedRegistryBuilderProvider;
import io.papermc.paper.registry.data.dialog.DialogRegistryEntry;
import java.util.function.Consumer;
import net.kyori.adventure.dialog.DialogLike;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a dialog. Can be created during normal server operation via {@link #create(Consumer)}.
* Can also be created during bootstrap via {@link io.papermc.paper.registry.event.RegistryEvents#DIALOG}.
*/
@ApiStatus.NonExtendable
public interface Dialog extends RegistryElement<Dialog>, Keyed, DialogLike {
/**
* Creates a new dialog using the provided builder.
*
* @param value the builder to use for creating the dialog
* @return a new dialog instance
*/
@ApiStatus.Experimental
static Dialog create(final Consumer<RegistryBuilderFactory<Dialog, ? extends DialogRegistryEntry.Builder>> value) {
return InlinedRegistryBuilderProvider.instance().createDialog(value);
}
// Start generate - Dialog
Dialog CUSTOM_OPTIONS = getDialog("custom_options");
Dialog QUICK_ACTIONS = getDialog("quick_actions");
Dialog SERVER_LINKS = getDialog("server_links");
// End generate - Dialog
private static Dialog getDialog(@KeyPattern.Value final String value) {
final Registry<Dialog> registry = RegistryAccess.registryAccess().getRegistry(RegistryKey.DIALOG);
return registry.getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, value));
}
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#DIALOG}. Dialogs can exist without a key.
*/
@Deprecated(since = "1.21.8", forRemoval = true)
@Override
NamespacedKey getKey();
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#DIALOG}. Dialogs can exist without a key.
*/
@Deprecated(since = "1.21.8", forRemoval = true)
@Override
default Key key() {
return Keyed.super.key();
}
}