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

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.ComplexEntityPart;
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;
import com.elmakers.mine.bukkit.utility.DeprecatedUtils;

public class MountAction extends BaseSpellAction {
    private boolean eject = false;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters) {
        eject = parameters.getBoolean("eject", false);
    }

    @Override
    public SpellResult perform(CastContext context) {
        LivingEntity source = context.getLivingEntity();
        if (source == null) {
            return SpellResult.LIVING_ENTITY_REQUIRED;
        }

        // Make it so this spell can be used to get someone off of you
        if (eject) {
            source.eject();
            return SpellResult.CAST;
        }

        Entity current = source.getVehicle();
        if (current != null) {
            current.eject();
        }
        Entity targetEntity = context.getTargetEntity();
        if (targetEntity == null) {
            return SpellResult.NO_TARGET;
        }

        if (targetEntity == DeprecatedUtils.getPassenger(source)
            || source == DeprecatedUtils.getPassenger(targetEntity)) {
            return SpellResult.NO_TARGET;
        }

        while (targetEntity instanceof ComplexEntityPart) {
            targetEntity = ((ComplexEntityPart)targetEntity).getParent();
        }
        DeprecatedUtils.setPassenger(targetEntity, source);

        return SpellResult.CAST;
    }
}

@@ -524,16 +524,54 @@
 = false;
+%0A    private boolean dismount = false;
 %0A%0A    @O
@@ -713,16 +713,77 @@
 false);%0A
+        dismount = parameters.getBoolean(%22dismount%22, false);%0A
     %7D%0A%0A 
@@ -1278,32 +1278,145 @@
 ct();%0A        %7D%0A
+        if (dismount) %7B%0A            return current != null ? SpellResult.CAST : SpellResult.NO_TARGET;%0A        %7D%0A
         Entity t

Add "dismount" option to Mount action