Edit

MessageBox Class

A simple message form with two buttons and a text body. Use this class to show a basic dialog to a player and handle the player's button selection.

Methods

constructor

new MessageBox(player: minecraftserver.Player, title: ObservableString | ObservableUIRawMessage | string | UIRawMessage)

Creates a new MessageBox for the specified player with the given title.

Parameters

Returns MessageBox

Notes:

body

body(body: ObservableString | ObservableUIRawMessage | string | UIRawMessage): MessageBox

Sets the body text displayed in the message box. Returns the message box instance to allow method chaining.

Parameters

Returns MessageBox

Notes:

button1

button1(label: ObservableString | ObservableUIRawMessage | string | UIRawMessage, tooltip?: ObservableString | ObservableUIRawMessage | string | UIRawMessage): MessageBox

Sets the label for the first button of the message box. Returns the message box instance to allow method chaining.

Parameters

Returns MessageBox

Notes:

button1WithOptions

button1WithOptions(label: ObservableString | ObservableUIRawMessage | string | UIRawMessage, options?: MessageBoxButtonOptions): MessageBox

Sets the label and options for the first button of the message box. Returns the message box instance to allow method chaining.

Parameters

Returns MessageBox

Caution

This function is still in pre-release. Its signature may change or it may be removed in future releases.

Notes:

button2

button2(label: ObservableString | ObservableUIRawMessage | string | UIRawMessage, tooltip?: ObservableString | ObservableUIRawMessage | string | UIRawMessage): MessageBox

Sets the label for the second button of the message box. Returns the message box instance to allow method chaining.

Parameters

Returns MessageBox

Notes:

button2WithOptions

button2WithOptions(label: ObservableString | ObservableUIRawMessage | string | UIRawMessage, options?: MessageBoxButtonOptions): MessageBox

Sets the label and options for the second button of the message box. Returns the message box instance to allow method chaining.

Parameters

Returns MessageBox

Caution

This function is still in pre-release. Its signature may change or it may be removed in future releases.

Notes:

close

close(): void

Closes the message box if it is currently being shown to the player. Throws a FormVisibilityError if the form is not currently open.

Notes:

isShowing

isShowing(): boolean

Returns true if the message box is currently being shown to the player, false otherwise.

Returns boolean

Notes:

  • This function can't be called in restricted-execution mode.

show

show(): Promise<MessageBoxResult>

Shows the message box to the player. Returns a promise that resolves with a MessageBoxResult containing the close reason and the player's button selection.

Returns Promise<MessageBoxResult>

Notes: