# Create Custom Effects

### Using AE's API for Effect Registration

To integrate custom effects into the AdvancedEnchantments system, developers must utilize the `AEAPI` class from the `net.advancedplugins.ae.api` package. The crucial method in this process is `registerEffect`, defined in the `AEAPI` class.

#### `registerEffect` Method

{% code fullWidth="false" %}

```java
/**
 * Register a new effect.
 *
 * @param plugin Plugin that is registering the effect.
 * @param effect Effect to register.
 * @return true if the effect was registered, false if not.
 */
public static boolean registerEffect(JavaPlugin plugin, AdvancedEffect effect) { }
```

{% endcode %}

This method is pivotal for registering new effects. It requires the plugin instance and the custom effect as arguments. The method returns a boolean indicating the success or failure of the registration process.

### The `AdvancedEffect` Class

To create a custom effect, developers must extend the `AdvancedEffect` class. This class serves as the base for all custom effects and provides several constructors and methods to define the effect's behavior.

#### Constructors

The `AdvancedEffect` class offers multiple constructors, allowing developers to define various aspects of their custom effect:

1. **Basic Constructor:**

   <pre class="language-java" data-full-width="true"><code class="lang-java">public AdvancedEffect(JavaPlugin plugin, String effectName) 
   </code></pre>

   This constructor initializes the effect with a name.
2. **Extended Constructor:**

   <pre class="language-java" data-overflow="wrap" data-full-width="true"><code class="lang-java">public AdvancedEffect(JavaPlugin plugin, String effectName, String description, String usage)
   </code></pre>

   This variant allows adding a description and usage information.
3. **Weighted Constructor:**

   <pre class="language-java" data-overflow="wrap" data-full-width="false"><code class="lang-java">public AdvancedEffect(JavaPlugin plugin, String effectName, String description, String usage, int weight)
   </code></pre>

   Adds an additional parameter for weight, which can influence how the effect is handled or prioritized.

#### Methods

The `AdvancedEffect` class contains methods to execute the effect:

1. **executeEffect (LivingEntity target):**

   <pre class="language-java" data-full-width="true"><code class="lang-java">public boolean executeEffect(ExecutionTask task, LivingEntity target, String[] args) {
       return false;
   }
   </code></pre>

   Triggers the effect for a living entity target.
2. **executeEffect (Location target):**

   <pre class="language-java" data-full-width="true"><code class="lang-java">public boolean executeEffect(ExecutionTask task, Location target, String[] args) {
       return false;
   }
   </code></pre>

   Activates the effect at a specific location.


---

# 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://ae.advancedplugins.net/for-developers/create-custom-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.
