diff --git a/src/main/java/com/alttd/frameSpawners/FrameSpawnerLocation.java b/src/main/java/com/alttd/frameSpawners/FrameSpawnerLocation.java
index d9a5a46..c890ac8 100644
--- a/src/main/java/com/alttd/frameSpawners/FrameSpawnerLocation.java
+++ b/src/main/java/com/alttd/frameSpawners/FrameSpawnerLocation.java
@@ -1,5 +1,6 @@
package com.alttd.frameSpawners;
+import com.alttd.AltitudeParticles;
import com.alttd.config.Config;
import com.alttd.objects.Frame;
import com.alttd.util.Logger;
@@ -16,26 +17,33 @@ public class FrameSpawnerLocation extends BukkitRunnable {
private Iterator iterator;
private final Location location;
private final float rotation;
- public FrameSpawnerLocation(int amount, List frames, Location location, float rotation) {
+ private final int frameDelay;
+ public FrameSpawnerLocation(int amount, List frames, int frameDelay, Location location, float rotation) {
this.amount = amount;
this.frames = frames;
this.iterator = frames.iterator();
this.location = location;
this.rotation = rotation;
+ this.frameDelay = frameDelay;
}
@Override
public void run() {
- if (iterator.hasNext())
- iterator.next().spawn(location, rotation);
- else if (amount != 0) {
- iterator = frames.iterator();
- if (amount > 0)
- amount--;
- } else {
+ if (amount == 0){
this.cancel();
if (Config.DEBUG)
Logger.info("Stopped repeating task due to end of frames");
}
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ if (!iterator.hasNext())
+ this.cancel();
+ iterator.next().spawn(location, rotation);
+ }
+ }.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
+ iterator = frames.iterator();
+ if (amount != -1)
+ amount--;
}
}
diff --git a/src/main/java/com/alttd/frameSpawners/FrameSpawnerPlayer.java b/src/main/java/com/alttd/frameSpawners/FrameSpawnerPlayer.java
index 1b2a640..d9a3abe 100644
--- a/src/main/java/com/alttd/frameSpawners/FrameSpawnerPlayer.java
+++ b/src/main/java/com/alttd/frameSpawners/FrameSpawnerPlayer.java
@@ -1,5 +1,6 @@
package com.alttd.frameSpawners;
+import com.alttd.AltitudeParticles;
import com.alttd.config.Config;
import com.alttd.objects.APartType;
import com.alttd.objects.Frame;
@@ -21,7 +22,8 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
private final PlayerSettings playerSettings;
private final APartType aPartType;
private final String uniqueId;
- public FrameSpawnerPlayer(int amount, List frames, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId) {
+ private final int frameDelay;
+ public FrameSpawnerPlayer(int amount, List frames, int frameDelay, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId) {
this.amount = amount;
this.frames = frames;
this.iterator = frames.iterator();
@@ -29,6 +31,7 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
this.playerSettings = playerSettings;
this.aPartType = aPartType;
this.uniqueId = uniqueId;
+ this.frameDelay = frameDelay;
}
@Override
@@ -46,15 +49,21 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
Logger.info("Stopped repeating task due to player switching/disabling particles.");
return;
}
- if (iterator.hasNext())
- iterator.next().spawn(player.getLocation(), player.getLocation().getYaw());
- else if (amount != 0) {
- iterator = frames.iterator();
- amount--;
- } else {
+ if (amount == 0) {
this.cancel();
if (Config.DEBUG)
Logger.info("Stopped repeating task due to end of frames.");
}
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ if (!iterator.hasNext())
+ this.cancel();
+ iterator.next().spawn(player.getLocation(), player.getLocation().getYaw());
+ }
+ }.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
+ iterator = frames.iterator();
+ if (amount != -1)
+ amount--;
}
}
diff --git a/src/main/java/com/alttd/objects/ParticleSet.java b/src/main/java/com/alttd/objects/ParticleSet.java
index 7e798ad..a90572c 100644
--- a/src/main/java/com/alttd/objects/ParticleSet.java
+++ b/src/main/java/com/alttd/objects/ParticleSet.java
@@ -48,8 +48,8 @@ public class ParticleSet {
public void run(Location location, Player player) {
if (tooSoon(player.getUniqueId()) || isVanished(player))
return;
- FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, location, player.getLocation().getYaw());
- frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), frameDelay, repeatDelay);
+ FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, frameDelay, location, player.getLocation().getYaw());
+ frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
}
public void run(Player player, PlayerSettings playerSettings) {
@@ -57,8 +57,8 @@ public class ParticleSet {
return;
if (Config.DEBUG)
Logger.info("Starting particle set % for %.", uniqueId, player.getName());
- FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, frames, player, playerSettings, aPartType, uniqueId);
- frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), frameDelay, repeatDelay);
+ FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, frames, frameDelay, player, playerSettings, aPartType, uniqueId);
+ frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
}
private boolean isVanished(Player player) {