Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
player: @minecraft/server.Player
The player to show this message box to.
title: ObservableString | ObservableUIRawMessage | string | UIRawMessage
The title text to display at the top of the message box.
Returns MessageBox
Notes:
- This function can throw errors.
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
body: ObservableString | ObservableUIRawMessage | string | UIRawMessage
The body text to display. Accepts either a plain string or an ObservableString.
Returns MessageBox
Notes:
- This function can't be called in restricted-execution mode.
- This function can throw errors.
- Throws InvalidFormModificationError
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
label: ObservableString | ObservableUIRawMessage | string | UIRawMessage
The text label to display on the first button.
tooltip?: ObservableString | ObservableUIRawMessage | string | UIRawMessage =
nullOptional tooltip text shown when hovering over the first button.
Returns MessageBox
Notes:
- This function can't be called in restricted-execution mode.
- This function can throw errors.
- Throws InvalidFormModificationError
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
label: ObservableString | ObservableUIRawMessage | string | UIRawMessage
The text label to display on the first button.
options?: MessageBoxButtonOptions =
nullOptional configuration for the first button, such as tooltip and image.
Returns MessageBox
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
- This function can throw errors.
- Throws InvalidFormModificationError
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
label: ObservableString | ObservableUIRawMessage | string | UIRawMessage
The text label to display on the second button.
tooltip?: ObservableString | ObservableUIRawMessage | string | UIRawMessage =
nullOptional tooltip text shown when hovering over the second button.
Returns MessageBox
Notes:
- This function can't be called in restricted-execution mode.
- This function can throw errors.
- Throws InvalidFormModificationError
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
label: ObservableString | ObservableUIRawMessage | string | UIRawMessage
The text label to display on the second button.
options?: MessageBoxButtonOptions =
nullOptional configuration for the second button, such as tooltip and image.
Returns MessageBox
Caution
This function is still in pre-release. Its signature may change or it may be removed in future releases.
Notes:
- This function can't be called in restricted-execution mode.
- This function can throw errors.
- Throws InvalidFormModificationError
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:
- This function can't be called in restricted-execution mode.
- This function can throw errors.
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:
- This function can't be called in restricted-execution mode.
- This function can throw errors.