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.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
}
|