> For the complete documentation index, see [llms.txt](https://docs.eliteminecraftplugins.com/eliteenchantments/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eliteminecraftplugins.com/eliteenchantments/general-information/developer-api/creating-effects.md).

# Creating Effects

You can use the API to create your own effects for this plugin

#### Create your own effect class

```java
public class Example extends CustomEffect {
    public Example(Plugin plugin) {
        super(plugin, "EXAMPLE", "This is an example effect", "EXAMPLE:[VALUE]");
    }

    @Override
    public void run(LivingEntity player, @Nullable LivingEntity target, String[] arguments, Event event) {
        player.sendMessage("HELLO");
    }
}
```

You can also call events (as long as they are called using an effect type related, ie. if you want to call BlockBreakEvent. The effect type has to be MINE)\
Here is an example of an effect that sends the message "BROKEN" to the player once they break a block and it also cancel them from being able to break said block

```java
public class Example extends CustomEffect {
    public Example(Plugin plugin) {
        super(plugin, "EXAMPLE", "This is an example effect", "EXAMPLE:[VALUE]");
    }

    @Override
    public void run(LivingEntity player, @Nullable LivingEntity target, String[] arguments, Event event) {
        if (!(event instanceof BlockBreakEvent)) return;
        BlockBreakEvent breakEvent = (BlockBreakEvent) event;

        Player breaker = breakEvent.getPlayer();
        if (breaker.getUniqueId() != player.getUniqueId()) return;
        breakEvent.setCancelled(true);

        breaker.sendMessage("BROKEN");
    }
}
```

#### Registering effect

You will then need to add the following to your onEnable (Preferably with a delay)\
You can register multiple effects by separating them with a comma as shown below

```java
    @Override
    public void onEnable() {
        if (getServer().getPluginManager().isPluginEnabled("EliteEnchantments")) {
            EliteEnchantmentsAPI.getAPI().registerEffects(Example.class, Potion.class);
        }
    }
```
