Events
Perfom (conditional) actions when opening/closing the menu

Example

1
Events:
2
#Open events
3
Open:
4
#Condition which requires the player to have the permission trmenu.use to open it
5
#OR if he reopened the menu because of the auto-reload
6
#OR if the console opened the menu for the player.
7
- condition: 'hasPerm.trmenu.use or is.{reason}.RELOAD or is.{reason}.CONSOLE'
8
#Actions executed if the player has the permission trmenu.use.
9
actions:
10
- 'sound: BLOCK_CHEST_OPEN-1-0'
11
#Actions executed if the player doesn't have the permission trmenu.use.
12
deny:
13
- 'sound: ENTITY_ITEM_BREAK-1-0'
14
- 'title: <title=&c&lPermission Required><subtitle=&7&lYou need permission &6&ltrmenu.use &7&lto open this menu>'
15
#The return action won't let the menu open.
16
- 'return'
17
#Close events
18
Close:
19
#A simple sound action
20
- 'sound: BLOCK_CHEST_CLOSE-1-0'
Copied!

Note

  • The conditions will be explained in details later
  • In the open menu event, the {reason} variable will return
    1
    me.arasple.mc.trmenu.api.events.MenuOpenEvent.Reason
    Copied!
    You can see how it is used in the example above, we check if the menu has been opened for the player by the console or if it was reopen for the player because of a reload.
  • If the return action is executed, the event will be canceled. You can see that we use this in the open event of the example in the deny commands of the condition. This way, if the player doesn't met the condition, it won't open the menu.
  • Check this section of the wiki to get all Menu Events (and their reasons for the Open and Close events).
Last modified 1yr ago
Copy link
Contents
Example
Note