Skip to content

Server plugins

Dialogs and quick actions

Dialogs are vanilla's dialog screens, so vanilla clients show them. The codecs follow Mojang's dialog format.

Use Obsidian.API.Builders and Obsidian.API.Registry.Codecs.Dialogs.

var dialog = DialogBuilder.Notice("Welcome")
    .WithMessage("Welcome to the server!")
    .Build();
await player.ShowDialogAsync(dialog);
await player.ClearDialogAsync();

DialogBuilder.MultiAction("Quick actions")
    .WithActions(
        DialogAction.Create("Spawn", DialogClickAction.RunCommand("spawn")),
        DialogAction.Create("Website", DialogClickAction.OpenUrl("https://example.com")))
    .WithExitAction(DialogAction.Create("Back"))
    .Register("myplugin:quick_actions", quickAction: true);

Register dialogs during plugin initialization, before players connect. Players already playing get the change when plugins load or unload, which sends them back through configuration. A registered dialog is a snapshot: changing it afterwards changes nothing players are sent. A plugin's dialogs are removed when it unloads.

quickAction: true puts the dialog under the quick-actions key, G by default; pauseScreen: true adds it to the pause menu. One entry opens directly, and several open vanilla's chooser.

Builders cover notice, confirmation, multi-action, server-links and dialog-list screens; DialogTag backs a list with a tag. Bodies take messages and items. Inputs take text (multiline too), booleans, single options and number ranges. WithExternalTitle, WithColumns, WithButtonWidth, WithEscape, WithPause and AfterAction set vanilla's layout and behaviour.

var form = DialogBuilder.Notice("Suggestion",
        DialogAction.Create("Submit", DialogClickAction.Submit("myplugin:suggestion")))
    .WithInput(DialogInput.Text("message", "Suggestion", maxLength: 500))
    .Build();

Handle DialogActionEventArgs like any event, with MinecraftEventHandler and [EventPriority]. ActionId names the action, and Payload holds a submission's input values, normally an NbtCompound. SetHandled() stops further handling.

Client actions are untrusted: check the identifier, the player's permission, and each field's type and limits in your handler. Custom payloads are limited to 64 KiB, 32 levels of nesting and 4,096 tags.

Buttons can also run or suggest commands, open URLs, copy text, change book pages, show another dialog, send a static custom payload or fill in a command template.

Feedback

First-time players get a welcome dialog once their client has loaded the world. It says Obsidian is early in development and links to GitHub and Discord; when feedback is set up, it also explains the G key. A player counts as new when they have no saved player data, so deleting it, or leaving before the first save, shows the dialog again.

Set feedbackWebhookUrl in config/server.json to a Discord webhook URL to let players send feedback:

"feedbackWebhookUrl": "https://discord.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN"

Newly connected players then find a feedback form under quick actions. Discord receives the message with the player's details: username, UUID, world and position, game mode, health, ping, client brand and the like. A null, empty or invalid URL turns feedback off.

  • Messages are up to 1,500 characters, one per player each minute. Mentions are suppressed and Markdown is escaped.
  • Players see whether delivery worked. Nothing is stored or retried.
  • Keep the webhook URL private. Parameters in it, such as thread_id, are kept.
  • The server reloads the URL, but players must reconnect to gain or lose the form.