Skip to content

Action Menu

Overview

In version 3.3.1, we introduced a middle click menu for players. It features custom actions that are executed for the player that has been clicked on. Using the LabyMod API, a server can add custom buttons to that list of actions.

example action menu

Requirements

Example code

public void setMiddleClickActions( Player player ) {
    // List of all action menu entries
    JsonArray array = new JsonArray();

    // Add entries
    JsonObject entry = new JsonObject();
    entry.addProperty( "displayName", "Kick player" );
    entry.addProperty( "type", EnumActionType.RUN_COMMAND.name() );
    entry.addProperty( "value", "kick {name}" ); // {name} will be replaced with the players name
    array.add(entry);

    entry = new JsonObject();
    entry.addProperty( "displayName", "Open shop" );
    entry.addProperty( "type", EnumActionType.OPEN_BROWSER.name() );
    entry.addProperty( "value", "https://shop.example.com" );
    array.add(entry);

    entry = new JsonObject();
    entry.addProperty( "displayName", "Copy stats profile url" );
    entry.addProperty( "type", EnumActionType.CLIPBOARD.name() );
    entry.addProperty( "value", "https://example.com/stats/{name}" );
    array.add(entry);

    entry = new JsonObject();
    entry.addProperty( "displayName", "Create report" );
    entry.addProperty( "type", EnumActionType.SUGGEST_COMMAND.name() );
    entry.addProperty( "value", "report {name} >reason<" );
    array.add(entry);

    // Send to LabyMod using the API
    LabyModProtocol.sendLabyModMessage( player, "user_menu_actions", array );
}

Action types

enum EnumActionType {
    NONE,
    CLIPBOARD,
    RUN_COMMAND,
    SUGGEST_COMMAND,
    OPEN_BROWSER
}