Action packages
Action packages
Action Packages let administrators define reusable actions in plugins/DialogMaster/actions/ and call them from multiple menu buttons. They are useful when the same command chain, condition, or feedback sequence appears in more than one menu.
Create a package
Create actions/buy_item.yml:
actions:
- if: "%vault_eco_balance% >= $(price)"
then:
- "console: eco take %player_name% $(price)"
- "console: give %player_name% $(item) $(amount|1)"
- "sound: ENTITY_PLAYER_LEVELUP"
- "message: <green>Purchased $(item)!"
else:
- "sound: ENTITY_VILLAGER_NO"
- "message: <red>You do not have enough money."
Call a package
Reference the package from a button:
buttons:
- label: "<gold>Buy a diamond sword"
action: "package: buy_item price=500 item=diamond_sword amount=1"
Arguments
Packages support positional arguments such as $(0) and named arguments such as $(price). Use $(key|fallback) to provide a default when an argument is omitted. Named arguments are recommended for maintainability because the call site remains readable when the package evolves.
Conditions and safety
A package can branch with if, then, and else. Packages may invoke other packages, but recursion is limited to a maximum depth of five to prevent infinite loops. Keep destructive commands inside a clear condition and provide a user-facing success or failure message.
Recommended pattern
For a purchase flow, validate the requirement first, perform the economy and item operations second, and send feedback last. Test the package in a non-production environment before using it in a public shop.
See Requirements and logic and Menu types for the surrounding concepts.