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

/**
 * 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) { }

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:

    public AdvancedEffect(JavaPlugin plugin, String effectName) 

    This constructor initializes the effect with a name.

  2. Extended Constructor:

    public AdvancedEffect(JavaPlugin plugin, String effectName, String description, String usage)

    This variant allows adding a description and usage information.

  3. Weighted Constructor:

    public AdvancedEffect(JavaPlugin plugin, String effectName, String description, String usage, int weight)

    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):

    public boolean executeEffect(ExecutionTask task, LivingEntity target, String[] args) {
        return false;
    }

    Triggers the effect for a living entity target.

  2. executeEffect (Location target):

    public boolean executeEffect(ExecutionTask task, Location target, String[] args) {
        return false;
    }

    Activates the effect at a specific location.

Last updated