Skip to content

plugin integration

goflishMC edited this page Jul 1, 2025 · 1 revision

📦 Registering Enchants from Addons

This page explains how to create a plugin addon that registers custom enchantments using the FabledEnchants API.


🧱 Prerequisites

Your plugin must:

  • Declare a dependency on FabledEnchants in plugin.yml
  • Include FabledEnchants in the classpath (provided scope)
depend: [FabledEnchants]

🔨 Step-by-Step

1. Extend CustomEnchantment

Create your own enchant class:

public class Shadowstep extends CustomEnchantment {
    public Shadowstep() {
        super("Shadowstep", "Dash behind your target");
        setMaxLevel(1);
        setTableEnabled(true);
        addNaturalItems(Material.DIAMOND_SWORD);
    }

    @Override
    public void applyOnHit(LivingEntity user, LivingEntity target, int level, EntityDamageByEntityEvent event) {
        user.teleport(target.getLocation().add(0, 0, -1));
    }
}

2. Register Your Enchant in onEnable()

@Override
public void onEnable() {
    EnchantmentAPI.registerCustomEnchantment(new Shadowstep());
}

You can register multiple enchantments this way.


🧪 Testing

Once compiled and placed in the /plugins folder alongside FabledEnchants:

  • Start your server.
  • Use /enchants add <enchant> <level> to test.
  • Observe expected behavior in-game.

🔁 Reloading

Java/API-based enchantments are loaded on server startup. You must restart the server to add or remove them.


📘 See Also

Clone this wiki locally