Skip to content

Enchantment structure

Roughly_ edited this page Dec 17, 2022 · 1 revision

Enchantment structure: crash course

name: 'Parkour'
trigger: 'PLAYERGOTHURT'
applicable: 'ARMOR_FEET'
forbid-on:
  - LEATHER_BOOTS
  - CHAINMAIL_BOOTS
conditions:
  - CAUSED-BY-FALLING
levels:
  '1':
    conditions:
      - DAMAGE-NON-LETHAL
    chance: 15
    cooldown: 5
    action:
      - 'player-set-health %player_health%+%damage% delay:1'
  '2':
    chance: 15
    cooldown: 7
    action:
      - 'player-set-health %player_health%+%damage%+1 delay:1'

Name

name: 'Parkour'

This is the line that indicates the name of the enchantment and will be used everywhere. This field is mandatory.

Trigger

trigger: 'PLAYERGOTHURT'

This is the line that indicates the enchantment trigger - in other words, that is what should happen for the enchantment to activate. All of them with their respective actions and conditions are on this Wiki. This field is mandatory.

Applicable

applicable: 'ARMOR_FEET'

This is what the enchantment can be applied to when using an enchantment table. The list of applicables can be found here. This field is mandatory.

Forbidden materials

forbid-on:
  - LEATHER_BOOTS
  - CHAINMAIL_BOOTS

This is the list of materials that will not activate the enchantment. This means that you can still enchant them with this enchantment, but it will never activate. This can be misleading to players that use the enchantment table, so it's not something you should use often and without explanation. The list of materials can be found here. This field is optional.

Global conditions

conditions:
  - CAUSED-BY-FALLING

This is the list of conditions that must be met for the enchantment to be activated. The list of global conditions can be found here, but per-trigger conditions can also be used, and they can be found on this Wiki. This field is optional.

Levels

levels:

This is a start of a configuration section, containing the enchantment levels. This field is mandatory.

Level index - first level

  '1':

This is the level number. It's best to keep them in order (1, 2, 3, 4, etc.), because otherwise the plugin behaviour is unpredictable. The first level is mandatory.

Per-level conditions

    conditions:
      - DAMAGE-NON-LETHAL

This is the list of conditions for the respective level (here - the first level) that must be met for the enchantment to be activated. The list of global conditions can be found here, but per-trigger conditions can also be used, and they can be found on this Wiki. This field is optional.

Chance

    chance: 15

This is the chance of the enchantment activating. chance: 15 means that there's a 15% chance for it to be activated. This field is optional, and not using it will just make the enchantment have a 100% chance to activate.

Cooldown

    cooldown: 5

This is a cooldown in seconds. More information about it here. This field is optional.

Actions

    action:
      - 'player-set-health %player_health%+%damage% delay:1'

This is the list of actions for a level. Everything here will be done as long as the conditions are met, the cooldown is over and the chance is fulfilled. For every level, this field is mandatory.

Level index - second level

  '2':

This is the second level, and it is optional - an enchantment can have from 1 to any amount of levels (as long as you have enough storage, memory and the number is in integer limit bounds, of course).


You might have noticed some gimmicks, such as placeholders (%player_health%), arithmetic expressions (%damage%+1) and delays (delay:1). To learn more, check this page out.

Guides:

Triggers:

API:

Clone this wiki locally