package de.slikey.effectlib.effect;

import de.slikey.effectlib.Effect;
import de.slikey.effectlib.EffectManager;
import de.slikey.effectlib.EffectType;
import de.slikey.effectlib.util.ParticleEffect;
import org.bukkit.Location;
import org.bukkit.util.Vector;

public class LineEffect extends Effect {

    /**
     * ParticleType of spawned particle
     */
    public ParticleEffect particle = ParticleEffect.FLAME;

    /**
     * Should it do a zig zag?
     */
    public boolean isZigZag = false;

    /**
     * Number of zig zags in the line
     */
    public int zigZags = 10;

    /**
     * Particles per arc
     */
    public int particles = 100;

    /**
     * Internal boolean
     */
    protected boolean zag = false;

    /**
     * Internal counter
     */
    protected int step = 0;

    public LineEffect(EffectManager effectManager) {
        super(effectManager);
        type = EffectType.INSTANT;
        period = 5;
        iterations = 200;
    }

    @Override
    public void onRun() {
        Location location = getLocation();
        Location target = getTarget();
        double amount = particles / zigZags;
        if (target == null) {
            cancel();
            return;
        }
        Vector link = target.toVector().subtract(location.toVector());
        float length = (float) link.length();
        link.normalize();

        float ratio = length / particles;
        Vector v = link.multiply(ratio);
        Location loc = location.clone().subtract(v);
        for (int i = 0; i < particles; i++) {
            if (isZigZag) {
                if (zag)
                    loc.add(0, .1, 0);
                else
                    loc.subtract(0, .1, 0);
            }
            if (step >= amount) {
                if (zag)
                    zag = false;
                else
                    zag = true;
                step = 0;
            }
            step++;
            loc.add(v);
            display(particle, loc);
        }
    }

}

@@ -651,24 +651,167 @@
 les = 100;%0A%0A
+    /**%0A     * Length of arc%0A     * A non-zero value here will use a length instead of the target endpoint%0A     */%0A    public int length = 0;%0A%0A
     /**%0A    
@@ -1056,15 +1056,17 @@
 ype.
-INSTANT
+REPEATING
 ;%0A  
@@ -1108,11 +1108,9 @@
 s = 
-200
+1
 ;%0A  
@@ -1222,16 +1222,280 @@
 target =
+ null;%0A        if (length %3E 0) %7B%0A            org.bukkit.Bukkit.getLogger().info(%22Line Direction: %22 + location.getDirection().normalize());%0A            target = location.clone().add(location.getDirection().normalize().multiply(length));%0A        %7D else %7B%0A           
  getTarg
@@ -1496,24 +1496,34 @@
 etTarget();%0A
+        %7D%0A
         doub

Add a length option to LineEffect, allow it to repeat