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

import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.spell.SpellResult;
import com.elmakers.mine.bukkit.action.BaseSpellAction;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;

public class KillAction extends BaseSpellAction
{
	@Override
	public SpellResult perform(CastContext context)
	{
        Entity entity = context.getTargetEntity();
		if (!(entity instanceof LivingEntity))
		{
			return SpellResult.NO_TARGET;
		}

        LivingEntity targetEntity = (LivingEntity)entity;
        // Overkill to bypass protection
		targetEntity.damage(targetEntity.getMaxHealth() * 100);
		return SpellResult.CAST;
	}

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

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

@@ -629,18 +629,66 @@
 tection%0A
-%09%09
+        if (!targetEntity.isDead()) %7B%0A            
 targetEn
@@ -735,16 +735,26 @@
 * 100);%0A
+        %7D%0A
 %09%09return

Avoid damaging a dead Entity