Fixed frames not properly repeating at the right speed
This commit is contained in:
parent
77dcd8862c
commit
be97b45833
|
|
@ -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<Frame> iterator;
|
||||
private final Location location;
|
||||
private final float rotation;
|
||||
public FrameSpawnerLocation(int amount, List<Frame> frames, Location location, float rotation) {
|
||||
private final int frameDelay;
|
||||
public FrameSpawnerLocation(int amount, List<Frame> 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--;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Frame> frames, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId) {
|
||||
private final int frameDelay;
|
||||
public FrameSpawnerPlayer(int amount, List<Frame> 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--;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user