Skip to content

Developers

Endxxr edited this page Jul 15, 2023 · 2 revisions

Build

To build the plugin, you need to have Java 8 or higher and Maven installed on your computer. Run the following command in the root directory of the project:

mvn clean package

The .jar file will be in the \target folder.

API

AdvancedAbilities has an API that allows you to interact with the plugin. The jar of the API is downloadable through GitHub Releases.
Make sure to add the plugin as a dependency in your project.

The API consists in 6 main objects:

  • Ability, rapresents a simple ability without any function.
  • ClickableAbility inheritor of Ability, rapresents an ability executed on when interacted (PlayerInteractEvent).
  • TargetAbility inheritor of Ability, rapresents an ability executed when used to damage a player.
  • ThrowableAbility inheritor of Ability, rapresents an ability executed when its item is thrown.
  • AbilityManager to register and manage the abilities.
  • ItemGenerator used by the Ability class to create the item of a specific ability.

Note: You can override the method ThrowableAbility#onHit and use it to listen when your ability projectile hits someone.

Get the API

AdvancedAPI api = AdvancedProvider.getApi();

Events

Work in progress...

Create and register a custom ability

Before creating a custom ability, I suggest to check out all the classes mentioned above to understand which one suits better for your ability.

Remember to define AdvancedAbilities as dependecy or soft-dependency of your plugin.

Creating your own ability is similar to register an EventHandler or a command with Bukkit and BungeeCord. First, you need to create a class which extends Ability of one or its inheritors. You can implements a Bukkit Listener to add more features to your ability.

package me.coolperson.mycoolplugin.abilities;

import me.delected.advancedabilities.api.objects.ability.ClickableAbility;
import org.bukkit.entity.Player;

public class CoolAbility extends ClickableAbility {
    
    //ID to identify the ability
    @Override
    public String getId() {
        return "CoolAbility";
    }
    
    // Should the item be removed when the ability is executed?
    @Override
    public boolean removeItem() {
        return true;
    }
    
    // Code executed on interact
    @Override
    public void run(Player player) {
       // Stuff
    }
}

Now it's time to register your ability. Calling this method will also register the ability's Bukkit Listeners.

AdvancedProvider.getAPI().getAbilityManager().registerAbility(new CoolAbility());

Clone this wiki locally