πŸ‘‹
Actions
View how to create & manage Menu Actions.
Relevant Classes: MenuItem​
​MenuAction​
Menu Actions allow you to do various things when a Menu Item is clicked. Though currently this functionality is limited from the configuration standpoint, you have complete freedom when using the Menu Action API via code.
There are currently two forms of actions for a Menu Item. The first form is a menu action that runs code defined by the Developer. The second form is an internal action, which given an input, parses that input and runs a specific action based on the action type.
The only accessible form of action from configuration is the internal action. Eventually I wish to expand this to a point which allows for vast systems to be done using purely the internal actions.
You can define one Menu Action per Menu Item. A Menu Action can only be defined using code, and cannot be accessed via a configuration file.
MenuAction is an interface that has a single method, which is executed when the Menu Item is clicked, if the Menu Action is not null. The method method provides the InventoryClickEvent, which should provide the Developer with everything they would need to know.

Example Use

MenuItem item;
​
item.setAction(event -> {
Bukkit.getLogger().log(Level.INFO,
event.getWhoClicked().getName() + " clicked my item!");
});

Internal Action

You can define multiple internal actions per Menu Item. An internal action can be defined via code, or a configuration file.
Internal actions are predefined variables with required arguments for execution. Each internal action runs once per Menu Item click.

Valid Internal Actions

More Internal Actions will be added in the future, if you have a suggestion for an action, please join the Discord!
It's currently known that you can only have one internal action per action type. This will change in a future update!
ID
Description
Syntax
RUN_CONSOLE_COMMAND
Run a command as console.
RUN_CONSOLE_COMMAND:<COMMAND>
RUN_PLAYER_COMMAND
Run a command as the player who clicked.
RUN_PLAYER_COMMAND:<COMMAND>
SEND_MESSAGE
Send the player who clicked a message.
SEND_MESSAGE:<MESSAGE>

Examples

Configuration
Code
"Actions" must be spelled case-sensitive to be recognized.
​
For an action to be defined in a configuration file, it must be defined on a valid Menu Item.
​
Example-Item:
Slot: 0
Material: "GRAY_STAINED_GLASS_PANE"
Name: "&cExample"
Lore:
- "&7Example Item"
- ""
- "&aSecond Line"
# These are a set of actions that run when
# clicking on the ItemStack.
Actions:
# This action runs a command as the player
- "RUN_PLAYER_COMMAND:examplecommand withargs"
​
Once this Menu Item is loaded into the Menu, if a player clicks on the Menu Item, the defined actions will execute.
​
Adding internal actions to a Menu Item via code is super easy!
​
MenuItem item;
​
item.getInternalActions().
put(MenuClickActionType.RUN_PLAYER_COMMAND,
"examplecommand withargs");
​
Once this Menu Item is loaded into the Menu, if a player clicks on the Menu Item, the defined actions will execute.
Last modified 7mo ago
Copy link
On this page
Menu Action
Internal Action