Skip to content
ZERNYTH.

Bedrock Forms

Forms are Bedrock's native dialogs. Player.showForm returns a FormRequest with an asynchronous response.

package dev.example;

import dev.zernyth.api.form.ActionForm;
import dev.zernyth.api.form.FormResponse;
import dev.zernyth.api.player.Player;
import dev.zernyth.api.plugin.JavaPlugin;
import java.util.List;

public final class FormsPlugin extends JavaPlugin {
    void open(Player player) {
        var form = new ActionForm("Zernyth", "Choose an option",
            List.of(new ActionForm.Button("Start"), new ActionForm.Button("Help")));
        player.showForm(form).response().thenAccept(response -> {
            if (response.status() == FormResponse.Status.SUBMITTED) getLogger().info("Answer: " + response.values());
        });
    }
}

Form types

TypePurpose
ActionFormA list of buttons, with optional images.
MessageFormTwo choices.
ModalFormControls: TextField, Toggle, Slider, Dropdown, StepSlider.

Responses

Check status first. It can be SUBMITTED, CLOSED, DISCONNECTED, PLUGIN_DISABLED, INVALID_RESPONSE or CANCELLED. Use returnToServer or a scheduled task before touching game objects if the continuation may run on a worker.

Was this page helpful?