-
-
Notifications
You must be signed in to change notification settings - Fork 1
PacketEvents
Huynh Tien edited this page Jul 8, 2025
·
2 revisions
Add io.github.projectunified:uni-dialog-packetevents to your build tools
For example, here is the dependency for Maven:
<dependency>
<groupId>io.github.projectunified</groupId>
<artifactId>uni-dialog-packetevents</artifactId>
<version>VERSION</version>
</dependency>Check here for more information on other build tools
Check here for the JavaDoc
Create a PocketEventsDialogManager like this:
String defaultNamespace = "testdialogs";
PocketEventsDialogManager dialogManager = new PocketEventsDialogManager(defaultNamespace) {
@Override
protected @Nullable Object getPlayer(UUID uuid) {
return null; // Return an object representing the player (must be supported by PacketEvents)
}
@Override
protected UUID getPlayerId(Object player) {
return null; // Return an UUID of the player
}
};Implement the required methods getPlayer and getPlayerId
For example, here is how to do it in Spigot:
String defaultNamespace = "testdialogs";
PocketEventsDialogManager dialogManager = new PocketEventsDialogManager(defaultNamespace) {
@Override
protected @Nullable Player getPlayer(UUID uuid) {
return Bukkit.getPlayer(uuid);
}
@Override
protected UUID getPlayerId(Object player) {
Player p = (Player) player;
return p.getUniqueId();
}
};Simply call the register method
dialogManager.register()The preferred way is to construct a Dialog and call its opener to get the DialogOpener. The DialogOpener is preserved and used to open the dialog for the player.
DialogOpener dialogOpener = dialogManager.createConfirmationDialog()
.title("Sample Dialog")
.canCloseWithEscape(true)
.afterAction(Dialog.AfterAction.CLOSE)
.body(builder -> builder.text().text("This is a sample dialog. Do you want to proceed?"))
.input("name", builder -> builder.textInput().label("Enter your name:"))
.yesAction(builder -> builder.label("Confirm"))
.noAction(builder -> builder.label("Cancel"))
.opener();UUID playerUUID;
dialogOpener.open(playerUUID);- ItemBody only display the material of the item and not its components