Create a Enchantment

Create a custom enchantment.

Start by creating a new file in the enchantments directory of the plugin folder, such file must be a valid YAML file.

Next, add the required attributes for the enchantment:

Enchantment file structure

  • id The unique id that will be used for commands and internal usage, that id must not be in other enchantments.

  • display How the enchantment will be displayed in item lore.

  • description A brief description explaining what the enchantment does.

  • minLevel The minimum level of the enchantment.

  • maxLevel The maximum level of the enchantment.

  • applies-to To which the enchantment applies to.

  • levels Optional data for extra behaviour.

  • events The list of "queries" to run the enchantment.

Levels

Levels are enclosed in a section called levels, followed by default or the level number for which this level data will be used, in the example below, we have a data for level 3 and default, it means that when the enchantment is executed if the level is not 3, default will be used, otherwise 3 will be used.

Metadata

The optional metadata that will be merged with the variables when executing the enchantment, can be used at any time in the events constraints or functions.

Enchanting Table

see here

Applies To

What kind of items the enchantment can be used/enchanted on:

Name

HELMETS

CHESTPLATES

LEGGINGS

BOOTS

ALL_ARMOR

SWORDS

AXES

BOWS

PICKAXES

ALL_WEAPONS

Full example:

id: example_enchantment
display: 'Example Enchantment'
description: 'This is a example enchantment.'
minLevel: 1
maxLevel: 1
appliesTo:
- PICKAXES
rarity: COMMON
events:
  1:
    name: 'BlockBreakEvent'
    constraints: |
      event.getBlock().getType() == STONE
    functions: |
      self.sendMessage("You mined a stone block")
      self.playSound(self.getLocation(), ENTITY_PLAYER_LEVELUP, 0.3, 0.5)

Last updated