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.

Requirements

Example code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public void setMiddleClickActions( Player player ) {
    // List of all action menu entries
    JsonArray array = new JsonArray();

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

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

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

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

    // Send to LabyMod using the API
    LabyModPlugin.getInstance().sendServerMessage( player, "user_menu_actions", array );
}

Action types

1
2
3
4
5
6
7
enum EnumActionType {
    NONE,
    CLIPBOARD,
    RUN_COMMAND,
    SUGGEST_COMMAND,
    OPEN_BROWSER
}