# 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);
        }
    }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eliteminecraftplugins.com/eliteenchantments/general-information/developer-api/creating-effects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
