Argument Processor

The unit that handles the arguments of a Menu.

Info

Some menus support multiple argument processors. The argument processors are executed in the order they are specified in the setting.

Subsections of Argument Processor

Overview

  • Argument Processor is a special unit that handles the arguments of a menu, mainly from Open Menu Command and Open Menu Action
  • The arguments are splitted and handled by multiple processors in the configured order.
  • The processors are specified in the argument-processor section of the menu-settings.
  • There are many built-in types of processors (Check the sidebar). A developer can also create his own processor and register to this plugin.

Example

menu-settings:
  command: testargs
  argument-processor:
    hello:
      length: 2
      suggest:
      - Hello you
      - Welcome back
      action: "tell: &cHello is required"
    message:
      take-remaining: true
      suggest:
      - HSGamer
      - Minecraft World
      action: "tell: &cMessage is required"

button:
  slot: 0
  id: stone
  name: "&bTest Arguments"
  lore:
  - "{arg_hello}, {arg_message}"

Variable

  • Each processor provide its own variable to be used in the menu.
  • The format: {arg_<processor_name>}
  • For example: {arg_hello}, {arg_message}

Store Argument

This is a processor to store the arguments and provide them as Variables

Format

menu-settings:
  argument-processor: # Add the processor to the menu
    <name>:
      type: store # Not needed as it's the default type
      action:
      - action
      - action
      - action
      - action
      invalid-action:
      - action
      - action
      - action
      length: <number>
      take-remaining: <true/false>
      suggest:
      - string1
      - string2
      - string3
      check-suggest: <true/false>

Note

  • length: the required length of the argument
  • take-remaining: whether to take all remaining arguments
  • suggest: the list of suggestions when the player uses tab-completion
  • check-suggest: whether to check the argument against the suggest list
  • action: the Action to be called when the argument length is not enough
  • invalid-action: the Action to be called when the argument is invalid

Example

menu-settings:
  command: testargs
  argument-processor:
    hello:
      length: 2
      suggest:
      - Hello you
      - Welcome back
      action: "tell: &cHello is required"
    message:
      take-remaining: true
      suggest:
      - HSGamer
      - Minecraft World
      action: "tell: &cMessage is required"

button:
  slot: 0
  id: stone
  name: "&bTest Arguments"
  lore:
  - "{arg_hello}, {arg_message}"

Player Argument

This is a processor to handle the argument for Player Name

Format

menu-settings:
  argument-processor: # Add the processor to the menu
    <name>:
      type: player
      action:
      - action
      - action
      - action
      - action
      invalid-action:
      - action
      - action
      - action
      online-only: <true/false>

Note

  • online-only: whether to check if the player is online. If true, then only the online players are given to the suggestion list
  • action: the Action to be called when the argument length is not enough
  • invalid-action: the Action to be called when the argument is invalid

Example

menu-settings:
  command: confirmteleport
  argument-processor:
    player:
      type: player
      action: "tell: &cPlayer is required"
    target:
      type: player
      action: "tell: &cTarget is required"

button:
  slot: 0
  id: ender_pearl
  name: "&bTeleport"
  command: "console: tp {arg_player} {arg_target}"

Number Argument

This is a processor to handle the numeric argument

Format

menu-settings:
  argument-processor: # Add the processor to the menu
    <name>:
      type: number
      action:
      - action
      - action
      - action
      - action
      invalid-action:
      - action
      - action
      - action
      suggest:
      - 0
      - 1
      - 2

Note

  • suggest: the list of suggestions when the player uses tab-completion
  • action: the Action to be called when the argument length is not enough
  • invalid-action: the Action to be called when the argument is invalid

Example

menu-settings:
  command: giveapple
  argument-processor:
    amount:
      type: number
      action: "tell: &cAmount is required"

button:
  slot: 0
  id: apple
  name: "&bGive apple"
  command: "console: give {player} apple {arg_amount}"

Decimal Argument

This is a processor to handle the decimal argument

Format

menu-settings:
  argument-processor: # Add the processor to the menu
    <name>:
      type: decimal
      action:
      - action
      - action
      - action
      - action
      invalid-action:
      - action
      - action
      - action
      suggest:
      - 0
      - 1
      - 2

Note

  • suggest: the list of suggestions when the player uses tab-completion
  • action: the Action to be called when the argument length is not enough
  • invalid-action: the Action to be called when the argument is invalid

Example

menu-settings:
  command: teleportcoords
  argument-processor:
    x:
      type: decimal
      action: "tell: &cX is required"
    y:
      type: decimal
      action: "tell: &cY is required"
    z:
      type: decimal
      action: "tell: &cZ is required"

button:
  slot: 0
  id: ender_pearl
  name: "&bTeleport"
  command: "console: tp {player} {arg_x} {arg_y} {arg_z}"

Material Argument

This is a processor to handle the argument of Material

Format

menu-settings:
  argument-processor: # Add the processor to the menu
    <name>:
      type: material
      action:
      - action
      - action
      - action
      - action
      invalid-action:
      - action
      - action
      - action

Note

  • action: the Action to be called when the argument length is not enough
  • invalid-action: the Action to be called when the argument is invalid

Example

menu-settings:
  command: materialview
  argument-processor:
    material:
      type: material
      action: "tell: &cMaterial is required"

button:
  slot: 0
  id: "{arg_material}"
  name: "&bMaterial"

Entity Argument

This is a processor to handle the argument of Entity

Format

menu-settings:
  argument-processor: # Add the processor to the menu
    <name>:
      type: entity
      action:
      - action
      - action
      - action
      - action
      invalid-action:
      - action
      - action
      - action

Note

  • action: the Action to be called when the argument length is not enough
  • invalid-action: the Action to be called when the argument is invalid

Example

menu-settings:
  command: spawnentity
  argument-processor:
    entity:
      type: entity
      action: "tell: &cEntity is required"

button:
  slot: 0
  id: "egg"
  name: "&bSpawn Entity"
  command: "op: spawn {arg_entity}"