Skip to content

Arguments

aBooDyy edited this page Aug 1, 2019 · 16 revisions

"Arguments" are a customization option which you can use within your menus, meaning it allows you to use specific "args" from a set command in that menu. 1.12.0+

args:
  target: 1
  time: 1
  reason: -1

The keys in this config section are the placeholders and will be parsed when using for example {target} (the value in the config section will indicate how many words the the argument will require). In the example below we can use /punish <target> <time> <reason> and there must be at least 3 arguments after open command. Setting a value of an argument key to -1 will handle all the words/arguments at the end.

/punish HelpChat 15min Example

Target = HelpChat
Time = 15min
Reason = Example

Values specified in the command will be display when using the argument's placeholder

NOTE: The -1 can only be used as the last "arg" in your arg list in the config which means the arg spans from the start of the "reason" until the end of the string provided. If you want the reason to only contain a specific amount of words change the value to: reason: 1 (reason will be 1 word only), reason: 2 (reason will be 2 words).

If you add this args option to a menu, the menu will not open if the required amount of arguments is not provided in the command. You must also specify an args_usage_message to tell the person opening the menu the correct usage: (in this case being the correct punish command)

args_usage_message: "/punish <player> <time> <reason>"

The args section of the menu should be placed in the "menu-defining" section:

menu_title: '<name>'
open_command: <command>
size: #
args:
  target: 1
  time: 1
  reason: -1
args_usage_message: "/punish <player> <time> <reason>"
items:

Due to how arguments are parsed means you can have unlimited amount of them, to achieve this just add the argument you want to your args section of the menu and use that argument wherever you want in your menu.
NOTE By adding new arguments to the menu -1 should always be the last argument

args:
  target: 1
  time: 1
  reason: 1 # (Using spaces in your reason will not work with this example)
  silent: 1

Your new argument now being {silent}

From here, you can use the new "arg" placeholders in any of your "click commands".

NOTE: As of right now arg placeholders are not parsed in requirements. The only place they are parsed are in material, display_name, lore and "click command".

Example: (Punishment menu)

items:
  '1':
    material: Barrier
    amount: 1
    slot: 11
    display_name: '&8&l> &aMute'
    lore:
    - '&r'
    - '&8» &bTarget&8: &7{target}'
    - '&8» &bTime&8: &7{time}'
    - '&8» &bPunishment&8: &7{reason}'
    - '&r'
    left_click_commands:
    - '[player] warn {target} {reason}'
    - '[close]'
    - '[broadcast] &b{target}&7 has been warned for&8: &b{reason}'
    right_click_commands:
    - '[player] warn {target} {reason}'
    - '[close]'
    - '[broadcast] &b{target}&7 has been warned for&8: &b{reason}'

Punishment Menu

Clone this wiki locally