Fixed frame delay
This commit is contained in:
parent
0a7b583424
commit
33d95226a7
|
|
@ -12,14 +12,12 @@ import java.util.List;
|
||||||
public class FrameSpawnerLocation extends BukkitRunnable {
|
public class FrameSpawnerLocation extends BukkitRunnable {
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private final long repeatDelay;
|
|
||||||
private final List<Frame> frames;
|
private final List<Frame> frames;
|
||||||
private Iterator<Frame> iterator;
|
private Iterator<Frame> iterator;
|
||||||
private final Location location;
|
private final Location location;
|
||||||
private final float rotation;
|
private final float rotation;
|
||||||
public FrameSpawnerLocation(int amount, int repeatDelay, List<Frame> frames, Location location, float rotation) {
|
public FrameSpawnerLocation(int amount, List<Frame> frames, Location location, float rotation) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.repeatDelay = (repeatDelay * 1000L) / 20;
|
|
||||||
this.frames = frames;
|
this.frames = frames;
|
||||||
this.iterator = frames.iterator();
|
this.iterator = frames.iterator();
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,14 @@ import java.util.List;
|
||||||
public class FrameSpawnerPlayer extends BukkitRunnable {
|
public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
private final long repeatDelay;
|
|
||||||
private final List<Frame> frames;
|
private final List<Frame> frames;
|
||||||
private Iterator<Frame> iterator;
|
private Iterator<Frame> iterator;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final PlayerSettings playerSettings;
|
private final PlayerSettings playerSettings;
|
||||||
private final APartType aPartType;
|
private final APartType aPartType;
|
||||||
private final String uniqueId;
|
private final String uniqueId;
|
||||||
public FrameSpawnerPlayer(int amount, int repeatDelay, List<Frame> frames, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId) {
|
public FrameSpawnerPlayer(int amount, List<Frame> frames, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.repeatDelay = (repeatDelay * 1000L) / 20;
|
|
||||||
this.frames = frames;
|
this.frames = frames;
|
||||||
this.iterator = frames.iterator();
|
this.iterator = frames.iterator();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
@ -53,13 +51,6 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||||
else if (amount != 0) {
|
else if (amount != 0) {
|
||||||
iterator = frames.iterator();
|
iterator = frames.iterator();
|
||||||
amount--;
|
amount--;
|
||||||
if (repeatDelay <= 0)
|
|
||||||
return;
|
|
||||||
try { //Wait before repeating the frames
|
|
||||||
Thread.sleep(repeatDelay); //TODO figure out why this doesn't work and fix it
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
if (Config.DEBUG)
|
if (Config.DEBUG)
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ public class ParticleSet {
|
||||||
public void run(Location location, Player player) {
|
public void run(Location location, Player player) {
|
||||||
if (tooSoon(player.getUniqueId()) || isVanished(player))
|
if (tooSoon(player.getUniqueId()) || isVanished(player))
|
||||||
return;
|
return;
|
||||||
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, repeatDelay, frames, location, player.getLocation().getYaw());
|
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, location, player.getLocation().getYaw());
|
||||||
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
|
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), frameDelay, repeatDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Player player, PlayerSettings playerSettings) {
|
public void run(Player player, PlayerSettings playerSettings) {
|
||||||
|
|
@ -57,8 +57,8 @@ public class ParticleSet {
|
||||||
return;
|
return;
|
||||||
if (Config.DEBUG)
|
if (Config.DEBUG)
|
||||||
Logger.info("Starting particle set % for %.", uniqueId, player.getName());
|
Logger.info("Starting particle set % for %.", uniqueId, player.getName());
|
||||||
FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, repeatDelay, frames, player, playerSettings, aPartType, uniqueId);
|
FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, frames, player, playerSettings, aPartType, uniqueId);
|
||||||
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
|
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), frameDelay, repeatDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVanished(Player player) {
|
private boolean isVanished(Player player) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user