Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Pica

A lightweight Dialog API for [Minestom](https://minestom.net/), built around Minecraft's native dialog system.

### Usage

Dialogs are built via `DialogType` and opened directly on a `Player`. The template is associated via a key from Adventure.

```java
DialogTemplate dialog = DialogType.confirm(MY_KEY)
.meta(meta -> {
meta.title(Component.text("Confirm deletion"));
meta.closeWithEscape(false);
meta.afterAction(DialogAfterAction.CLOSE);
meta.messageBody(body -> body.width(400).contents(Component.text("This action cannot be undone!", NamedTextColor.RED)));
})
.yesButton(button -> button.label(Component.text("Yes")).action(myAction))
.noButton(button -> button.label(Component.text("No")))
.build();

dialog.open(player);
```

Dialogs can optionally be tracked via a `DialogRegistry`:

```java
DialogRegistry registry = DialogRegistry.of();
registry.add(dialog);
registry.get(MY_KEY).open(player);
```

### Limitations

Currently only confirmation dialogs (`DialogType.confirm`) are supported. Support for further Minecraft dialog types is planned.