Skip to content

Development API: Spells

Naomi edited this page May 11, 2020 · 1 revision

Example of a custom spell

public class ExampleSpell extends SpellBase {
    @Override
    public void castSpell(Player player) {
        new Cooldown(player, this, 10000); //The method for creating a cooldown. The first variable is the player object,
                                           // second value is spell class and third value is the cooldown time in MS
        Block targetBlock = player.getTargetBlock(null, 50);
        targetBlock.breakNaturally();
        targetBlock.getWorld().spawnParticle(Particle.CLOUD, targetBlock.getLocation(), 10);
    }

    @Override
    public Optional<String> getCastMessage(boolean bool) {
        return Optional.of("Hi you casted this spell");
    }

    @Override
    public boolean isToggleSpell() {
        return false; //Is this spell a toggle spell? (Click to enable, click again to disable)
    }

    @Override
    public boolean isActive(Player player) {
        return false; //Is this toggle spell currently active?
    }

    @Override
    public String[] getSpellType() {
        return new String[] {"NOTHINGNESS"}; //Spell element types, these types will be used to bind them to the correct wand
    }

    @Override
    public String getSpellName() {
        return "&fThis spell is nothing";
    }

    @Override
    public String getPlainName() {
        return "ThisSpellIsNothing";
    }

    @Override
    public boolean isDeveloperMode() {
        return true; //Is this spell only usable by the developer?
    }

    @Override
    public UUID getDeveloper() {
        return UUID.fromString("6fe60af2-fc0d-48a3-9c65-9069d904903b"); //UUID of the spell developer
    }
}

Clone this wiki locally