package com.elmakers.mine.bukkit.action;

import com.elmakers.mine.bukkit.api.action.ActionHandler;
import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.spell.SpellResult;

public abstract class CheckAction extends CompoundAction {

    protected abstract boolean isAllowed(CastContext context);

    @Override
    public SpellResult step(CastContext context) {
        boolean allowed = isAllowed(context);
        ActionHandler actions = getHandler("actions");
        if (actions == null || actions.size() == 0) {
            return allowed ? SpellResult.CAST : SpellResult.STOP;
        }

        if (!allowed) {
            return SpellResult.NO_TARGET;
        }
        return startActions();
    }
}
@@ -35,16 +35,71 @@
 ction;%0A%0A
+import org.bukkit.configuration.ConfigurationSection;%0A%0A
 import c
@@ -204,16 +204,65 @@
 ontext;%0A
+import com.elmakers.mine.bukkit.api.spell.Spell;%0A
 import c
@@ -456,99 +456,470 @@
    p
-ublic SpellResult step(CastContext context) %7B%0A        boolean allowed = isAllowed(context);
+rotected void addHandlers(Spell spell, ConfigurationSection parameters) %7B%0A        addHandler(spell, %22actions%22);%0A        addHandler(spell, %22fail%22);%0A    %7D%0A%0A    @Override%0A    public SpellResult step(CastContext context) %7B%0A        boolean allowed = isAllowed(context);%0A        if (!allowed) %7B%0A            ActionHandler fail = getHandler(%22fail%22);%0A            if (fail != null && fail.size() != 0) %7B%0A                return startActions(%22fail%22);%0A            %7D%0A        %7D
 %0A   

Add optional "fail" action handler to Check actions