Skip to content

Input Prompt


Available for LabyMod users with version greater than 3.7.7 (LabyMod 4 included)


With this feature it is possible to request a text input from a player. The server can send any text with any pre-entered input to the client.



Example code

 * @param player The input prompt receiver
 * @param promptSessionId A unique id for each packet, use a static number and increase it for each prompt request
 * @param message The message above the text field
 * @param value The value inside of the text field
 * @param placeholder A placeholder text inside of the text field if there is no value given
 * @param maxLength Max amount of characters of the text field value
public void sendInputPrompt( Player player, int promptSessionId, String message, String value, String placeholder, int maxLength ) {
    JsonObject object = new JsonObject();
    object.addProperty( "id", promptSessionId );
    object.addProperty( "message", message );
    object.addProperty( "value", value );
    object.addProperty( "placeholder", placeholder );
    object.addProperty( "max_length", maxLength );

    // If you want to use the new text format in 1.16+
    // object.add("raw_json_text", textObject );

    LabyModProtocol.sendLabyModMessage( player, "input_prompt", object );

The client will send the following response with the input_prompt key after closing the GUI:

    "id": <promptSessionId as integer>,
    "value": "<The given input of the player>"