Origins-Reborn
  • Contents
  • FAQ
  • Addons
  • Custom origins
    • Origin Powers
    • Layers
  • Placeholders
  • Troubleshooting
  • Configuration
  • Skript
  • Making your own Origins-Reborn addon
    • Creating the addon
    • Custom abilities
    • Ability
    • VisibleAbility
Powered by GitBook
On this page
  • The Ability Key
  • Ability Checks

Was this helpful?

  1. Making your own Origins-Reborn addon

Ability

How to use the basic Ability interface

The Ability Key

All custom Origins-Reborn abilities need to implement the Ability interface, or another interface that extends it.

It has a single, basic method that must be implemented, getKey - this returns the key that is used to give your custom ability to an origin.

Example:

public class ExampleCustomAbility implements Ability {
    @Override
    public @NotNull Key getKey() {
        return Key.key("my_cool_addon", "my_ability");
    }
}

This will give your ability the key my_cool_addon:my_ability

Ability Checks

Next, to run a piece of code dependant on whether a player has an ability, you can use the runForAbility method like this:

public class ExampleCustomAbility implements Ability, Listener {
    @Override
    public @NotNull Key getKey() {
        return Key.key("my_cool_addon", "my_ability");
    }

    @EventHandler
    public void onPlayerJump(PlayerJumpEvent event) {
        runForAbility(event.getPlayer(), player -> {
            player.damage(1);
            player.sendMessage(Component.text("You took damage!"));
        });
    }
}

This means any player who jumps with the ability will take damage, and receive the message "You took damage!" in chat.

You can also use the method hasAbility to check if a player has an ability, returning a boolean value, e.g.

boolean player_has_power = hasAbility(event.getPlayer())

PreviousCustom abilitiesNextVisibleAbility

Last updated 18 days ago

Was this helpful?