# Create Custom Targets

### Using AE's API for Target Registration

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

#### `registerTarget` Method

{% code fullWidth="false" %}

```java
/**
 * Register a new target type.
 *
 * @param plugin Plugin that is registering the target type.
 * @param type   Target type to register.
 * @return true if the target type was registered, false if not.
 */
public static boolean registerTarget(JavaPlugin plugin, TargetType type) { }
```

{% endcode %}

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

### The `TargetType` Class

To create a custom target, developers must extend the `TargetType` class. This class serves as the base for all custom targets and provides several constructors and methods to define the targets' behavior.

All you need to do is return the target list. This is how an `ADD` target would look:

```java
public class AddTarget extends TargetType {

    public AddTarget() {
        super("Add");
    }

    @Override
    public TargetResults getTargets(String effect, String target, ExecutionTask task) {
        double x = Double.parseDouble(classifyTarget(target).getOrDefault(TargetArgument.X, "0.0"));
        double y = Double.parseDouble(classifyTarget(target).getOrDefault(TargetArgument.Y, "0.0"));
        double z = Double.parseDouble(classifyTarget(target).getOrDefault(TargetArgument.Z, "0.0"));

        Location loc = task.getBuilder().getMain().getLocation().clone().add(x, y, z);
        return TargetResults.builder().targetLocations(Collections.singletonList(loc)).build();
    }

}
```

Do note tht the classifyTarget method will work only for internal parameters. If you want any custom one's you will need to parse the arguments yourself


---

# 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-2.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.
