Requirement

The criteria to check before doing actions.

Subsections of Requirement

Overview

  • Requirement is one of the interesting parts of the plugin.
  • It is used when you want to check if the player meets some sort of requirements before doing anything (Check the level before opening the menu, etc).
  • There are many built-in types of requirements (Check the sidebar). A developer can also make his own requirement type and register it to the plugin.
Info

What you see in the examples & set in your Menu is actually Requirement Set.

Make sure to check Requirement Set to understand how to correctly set requirements in your Menu (Particularly, how to set multiple requirements & set Actions when the requirements are met / failed to met).

Example

permission-list:
  slot: 1
  type: predicate
  CLICK-REQUIREMENT: # Click Requirement
    default: # Click type
      we-permission: # The name of the Requirement set
        PERMISSION: # Here we are
        - bettergui.test
        - bettergui.test.1
        fail-command: "tell: &cYou don''t have the correct permission!"
  button:
    COMMAND: "tell: &a[v] You have the correct permission!"
    NAME: '&8Permission test'
    LORE:
      - 'To use this item, you need the'
      - 'required permissions.'
      - 'Otherwise, a configurable error'
      - 'message will be displayed.'
    ID: iron bars

Requirement Set

  • A requirement set is a set of requirements that the player are required to pass before doing actions.
  • It consists of:
    • The Requirements.
    • success-action (success-command): the Action when the player passes all requirements.
    • fail-action (fail-command): the Action when the player doesn’t pass any of the requirements.
  • You can set multiple sets of requirements.
    • The plugin will check for one set that the player meet its requirements. If none of the sets is matched, these are simply passed as failed and the actions will not be executed.

Format

requirement-set-name: # The name of the Requirement Set
  requirement-1: value-1 # The first requirement
  requirement-2: value-2 # The second requirement
  requirement-3: value-3 # The third requirement
  <requirement..>: <value..> # More requirements

  success-action: # The actions when the requirements are met
  - action1
  - action2
  - action3

  fail-action: # The actions when the requirements are not met
  - action1
  - action2
  - action3

Example

check-condition:
  slot: 1
  type: predicate
  CLICK-REQUIREMENT: # Click Requirement
    default: # Click type
      we-permission: # The name of the Requirement Set
        permission: # The permission requirement
        - bettergui.test
        - bettergui.test.1
        level: 10 # The level requirement
        fail-command: "tell: &cYou don''t meet the requirements!"
        success-command: "tell: &a[v] You passed the requirements!"
  button:
    NAME: '&8Requirement Test'
    LORE:
      - 'To use this item, you need to pass all requirements.'
      - 'Otherwise, a configurable error'
      - 'message will be displayed.'
    ID: iron bars

Cooldown Requirement

The requirement to check if the player is not in a cooldown timer (seconds). After checking successfully, the cooldown timer will start for the player.

Format

cooldown: <seconds>

Example

cooldown:
  slot: 1
  type: predicate
  button:
    COMMAND: "tell: &e You will need to wait 10 seconds to click again"
    NAME: '&aCooldown'
    LORE:
      - 'This is a example of icon with cooldown'
    ID: paper
  click-requirement: # Click Requirement
    default: # Click type
      test-cooldown: # Requirement Set name
        cooldown: 10 # Here we are
      fail-command:
        - "tell: &cWait until the cooldown is finished"

Level Requirement

The requirement to check if the level of the player is higher or equal to the specific level

Format

level: <level>
level:
  value: <level>
  take: <true/false>

Note

  • You can specify the take value (true or false) to allow/disallow the plugin to take the level of the player alter checking successfully

Example

test-view-requirement:
  type: predicate
  slot: 1
  button:
    id: exp_bottle
    name: "&cA exp bottle"
    lore:
      - "You will see this icon when the level is higher than 5"
  view-requirement: # View Requirement
    level: # Requirement Set name
      level: 5 # Here we are
test-click-requirement:
  type: predicate
  slot: 1
  button:
    id: exp_bottle
    name: "&cA level checker"
    command: "tell: &aYou reached level 5"
  click-requirement: # Click Requirement
    default: # Click type
      test-level: # Requirement Set name
        level: # Here we are
          value: 5
          take: true # Take the level
      fail-command:
        - "tell: &cTrain more"

Permission Requirement

The requirement to check if the player has the specific permission

Format

permission: <permission>
permission:
- <permission>
- <permission>
- <permission>
...

Note

  • You can add - before <permission> to indicate that the plugin should check if the player doesn’t have the <permission>

Example

permission:
  slot: 1
  type: predicate
  CLICK-REQUIREMENT: # Click Requirement
    default: # Click type
      permission: # Requirement set name
        PERMISSION: bettergui.test # Here we are
        fail-command: "tell: &cYou don''t have the correct permission!"
  button:
    COMMAND: "tell: &a[v] You have the correct permission!"
    NAME: '&8Permission test'
    LORE:
      - 'To use this item, you need the'
      - 'permission "bettergui.test".'
      - 'Otherwise, a configurable error'
      - 'message will be displayed.'
    ID: iron bars
permission-list:
  slot: 2
  type: predicate
  CLICK-REQUIREMENT: # Click Requirement
    default: # Click type
      permission: # Requirement set name
        PERMISSION: # Here we are
        - bettergui.test
        - bettergui.test.1
        fail-command: "tell: &cYou don''t have the correct permission!"
  button:
    COMMAND: "tell: &a[v] You have the correct permission!"
    NAME: '&8Permission test'
    LORE:
      - 'To use this item, you need the'
      - 'required permissions.'
      - 'Otherwise, a configurable error'
      - 'message will be displayed.'
    ID: iron bars

Condition Requirement

The requirement to check on conditions & expressions (Mainly Math extension)

Tip

If you want more advanced expressions, check out Eval Extra

Format

condition: <condition>

Note

  • This requirement will check if <condition> is true, yes, on or 0

Example

test-view-requirement:
  type: predicate
  slot: 1
  button:
    id: exp_bottle
    name: "&cA exp bottle"
    lore:
      - "You will see this icon when the level is 0"
  view-requirement: # View Requirement
    level: # Requirement Set name
      condition: "%math_{level} >= 0%" # Here we are

Version Requirement

The requirement to check if the server is at a specific version or higher.

Format

version: <value>

Note

  • The <value> is the major part of the version of Minecraft.
    • 1.12.2 will be 12
    • 1.18.2 will be 18
    • 1.8.8 will be 8

Example

test-xp:
  slot: 0
  id:
    - EXPERIENCE_BOTTLE
    - EXP_BOTTLE
  name: "&eGive &f10 XP"
  lore:
    - ""
    - "&fThis is a test template button"
    - "&fLevel: {level}"
  click-requirement:
    old-version:
      version: 13 # Check if the server is at 1.13.X
      success-action: "console: xp add {player} 10 points"
      fail-action: "console: xp 10 {player}"