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

import com.elmakers.mine.bukkit.effect.EffectRepeating;
import com.elmakers.mine.bukkit.math.VectorTransform;
import com.elmakers.mine.bukkit.utility.ConfigurationUtils;
import de.slikey.effectlib.util.DynamicLocation;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.Plugin;

public class EffectTransform extends EffectRepeating {
    private VectorTransform positionTransform;
    private long playTime;
    private long lastIteration;

    public EffectTransform() {
    }

    public void play() {
        playTime = 0;
        lastIteration = System.currentTimeMillis();
        super.play();
    }

    @Override
    public void load(Plugin plugin, ConfigurationSection parameters) {
        super.load(plugin, parameters);
        ConfigurationSection transform = ConfigurationUtils.getConfigurationSection(parameters, "position_transform");
        if (transform != null) {
            positionTransform = new VectorTransform(transform);
        } else {
            positionTransform = null;
        }
    }

    public void iterate() {
        if (positionTransform == null) {
            playEffect();
            return;
        }
        Location origin = getOrigin();
        Location target = getTarget();
        if (origin == null) return;
        Location source = origin;
        double t = (double)playTime / 1000;
        if (playAtOrigin) {
            source = source.clone();
            source.add(positionTransform.get(source, t));
        }
        if (target != null && playAtTarget) {
            target = target.clone();
            target.add(positionTransform.get(target, t));
        }
        long now = System.currentTimeMillis();
        playTime += (now - lastIteration);
        lastIteration = now;
        playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
    }
}

@@ -538,16 +538,69 @@
 eration;
+%0A    private long totalSteps;%0A    private long steps;
 %0A%0A    pu
@@ -678,16 +678,40 @@
 me = 0;%0A
+        totalSteps = 0;%0A
         
@@ -1185,24 +1185,783 @@
 ;%0A        %7D%0A
+        steps = parameters.getInt(%22steps%22, 0);%0A    %7D%0A%0A    public void iterateSteps(Location originalOrigin, Location originalTarget) %7B%0A        for (int i = 0; i %3C steps; i++) %7B%0A            Location source = originalOrigin;%0A            Location target = originalTarget;%0A            if (playAtOrigin) %7B%0A                source = source.clone();%0A                source.add(positionTransform.get(source, totalSteps));%0A            %7D%0A            if (target != null && playAtTarget) %7B%0A                target = target.clone();%0A                target.add(positionTransform.get(target, totalSteps));%0A            %7D%0A            playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));%0A            totalSteps++;%0A        %7D%0A
     %7D%0A%0A    p
@@ -2154,24 +2154,24 @@
 etTarget();%0A
-
         if (
@@ -2186,32 +2186,130 @@
 = null) return;%0A
+        if (steps %3E 0) %7B%0A            iterateSteps(origin, target);%0A            return;%0A        %7D%0A%0A
         Location

Add "steps" option to EffectTransform - it's like custom effectlib!