import * as mcui from '@minecraft/server-ui';

export default class ActionForm {
    _ui = new mcui.ActionFormData();
    constructor() {
        
    }
    title(text) {
        this._ui.title(text);
        return this;
    }
    
    body(text) {
        this._ui.body(text);
        return this;
    }
    
    button(text, icon = null) {
        if (icon === null) {
            this._ui.button(text);
        } else {
            this._ui.button(text, icon);
        }
        return this;
    }
    
    show(player, def) {
        this._ui.show(player).then(ui => {
            return def(ui.selection,ui.canceled);
        });
    }
    
}
