package com.elmakers.mine.bukkit.plugins.magic.spells;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.bukkit.entity.Arrow;

import com.elmakers.mine.bukkit.plugins.magic.Spell;
import com.elmakers.mine.bukkit.utilities.borrowed.ConfigurationNode;

public class ArrowSpell extends Spell
{ 
	@Override
	public boolean onCast(ConfigurationNode parameters) 
	{
	    int arrowCount = 1;
	    arrowCount = parameters.getInt("count", arrowCount);
		
		for (int ai = 0; ai < arrowCount; ai++)
		{
		    Arrow arrow = player.launchProjectile(Arrow.class);
		    if (arrow == null)
		    {
		        sendMessage(player, "One of your arrows fizzled");
		        return false;
		    }
		    // Hackily make this an infinite arrow
		    try {
		    	Method getHandleMethod = arrow.getClass().getMethod("getHandle");
		    	Object handle = getHandleMethod.invoke(arrow);
		    	Field fromPlayerField = handle.getClass().getField("fromPlayer");
		    	fromPlayerField.setInt(handle, 2);
		    } catch (Throwable ex) {
		    	ex.printStackTrace();
		    }
		    arrow.setTicksLived(1150);
		}
	
		castMessage(player, "You fire some magical arrows");
		
		return true;
	}

    @Override
    public void onLoad(ConfigurationNode node)
    {
        disableTargeting();
    }
}

@@ -137,20 +137,79 @@
 kit.
-entity.Arrow
+Location;%0Aimport org.bukkit.entity.Arrow;%0Aimport org.bukkit.util.Vector
 ;%0A%0Ai
@@ -528,113 +528,824 @@
 );%0A%09
-%09%0A%09%09for (int ai = 0; ai %3C arrowCount; ai++)%0A%09%09%7B%0A%09%09    Arrow arrow = player.launchProjectile(Arrow.class);
+    boolean useFire = parameters.getBoolean(%22fire%22, true);%0A%09    %0A%09    Arrow firstArrow = null;%0A%09    float speed = 3;%0A%09    float spread = 0.1f;%0A%09%09for (int ai = 0; ai %3C arrowCount; ai++)%0A%09%09%7B%0A%09%09    Arrow arrow = null;%0A%09%09    if (firstArrow == null) %7B%0A%09%09    %09arrow = player.launchProjectile(Arrow.class);%0A%09%09    %09firstArrow = arrow;%0A%09%09    %7D else %7B%0A%09%09    %09Location location = firstArrow.getLocation();%0A%09%09    %09Vector velocity = firstArrow.getVelocity();%0A%09%09    %09location.setX(location.getX() + velocity.getX() * (1 + Math.random() * arrowCount));%0A%09%09    %09location.setY(location.getY() + velocity.getY() * (1 + Math.random() * arrowCount));%0A%09%09    %09location.setZ(location.getZ() + velocity.getZ() * (1 + Math.random() * arrowCount));%0A%09%09    %09arrow = player.getWorld().spawnArrow(location, velocity, speed, spread);%0A%09%09    %7D%0A%09%09    
 %0A%09%09 
@@ -1463,24 +1463,99 @@
 se;%0A%09%09    %7D%0A
+%09%09    %0A%09%09    if (useFire) %7B%0A%09%09    %09arrow.setFireTicks(300);%0A%09%09    %7D%0A%09%09    %0A
 %09%09    // Hac
@@ -1939,11 +1939,10 @@
 ved(
-115
+30
 0);%0A

Add fire parameter to arrow, and fix arrow spread.