Registering Enchantments

In order for your enchantments to work, you must register them. This is done very simply. First, make your plugin extend EnchantPlugin instead of JavaPlugin (EnchantPlugin extends JavaPlugin so you don't need to change anything)

public class ExamplePlugin extends EnchantPlugin

Now the only thing left to do is override the registerEnchantments() method and use the EnchantmentAPI.registerCustomEnchantment(CustomEnchantment) method on each of your enchantments.

    @Override
    public void registerEnchantments() {
        EnchantmentAPI.registerCustomEnchantment(new LifestealEnchantment());
    }

If you ever want to unregister one or more of your enchantments (if you want to clear them on onDisable() or to just stop their effects from happening for awhile), simply use the static method:

EnchantmentAPI.unregisterCustomEnchantment(String enchantName);

And that's it! Once registered, your enchantments will be able to apply their effects and result from enchantment table usage!


Comments

Posts Quoted:
Reply
Clear All Quotes