package com.elmakers.mine.bukkit.action.builtin;

import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;

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

public class AggroAction extends BaseSpellAction
{
    @Override
    public SpellResult perform(CastContext context)
    {
        Entity target = context.getTargetEntity();
        if (!(target instanceof Creature))
        {
            return SpellResult.NO_TARGET;
        }
        LivingEntity source = context.getLivingEntity();
        if (source == null)
        {
            return SpellResult.NO_TARGET;
        }

        Creature creatureTarget = (Creature)target;
        LivingEntity current = creatureTarget.getTarget();
        if (source == current)
        {
            return SpellResult.NO_ACTION;
        }

        ((Creature) target).setTarget(source);
        return SpellResult.CAST;
    }

    @Override
    public boolean isUndoable()
    {
        return false;
    }

    @Override
    public boolean requiresTargetEntity()
    {
        return true;
    }
}

@@ -43,16 +43,70 @@
 iltin;%0A%0A
+import org.bukkit.configuration.ConfigurationSection;%0A
 import o
@@ -432,219 +432,795 @@
     
-@Override%0A    public SpellResult perform(CastContext context)%0A    %7B%0A        Entity target = context.getTargetEntity();%0A        if (!(target instanceof Creature))%0A        %7B%0A            return SpellResult.NO_TARGE
+private boolean clearTarget;%0A%0A    @Override%0A    public void prepare(CastContext context, ConfigurationSection parameters) %7B%0A        super.prepare(context, parameters);%0A        clearTarget = parameters.getBoolean(%22clear_target%22, false);%0A    %7D%0A%0A    @Override%0A    public SpellResult perform(CastContext context)%0A    %7B%0A        Entity target = context.getTargetEntity();%0A        if (!(target instanceof Creature))%0A        %7B%0A            return SpellResult.NO_TARGET;%0A        %7D%0A%0A        Creature creatureTarget = (Creature)target;%0A        if (clearTarget) %7B%0A            LivingEntity current = creatureTarget.getTarget();%0A            if (current == null) %7B%0A                return SpellResult.NO_TARGET;%0A            %7D%0A            creatureTarget.setTarget(null);%0A            return SpellResult.CAS
 T;%0A 
@@ -1380,60 +1380,8 @@
  %7D%0A%0A
-        Creature creatureTarget = (Creature)target;%0A
     

Add clear_target parameter to Aggro action