Extra null checks for arrows style

This commit is contained in:
Esophose 2022-01-03 10:29:41 -07:00
parent 619fc29755
commit 2d86ba65af
No known key found for this signature in database
GPG key ID: DE0E013CAE5C630A

View file

@ -35,7 +35,7 @@ public class ParticleStyleArrows extends DefaultParticleStyle implements Listene
Bukkit.getScheduler().runTaskTimer(PlayerParticles.getInstance(), () -> {
for (int i = this.projectiles.size() - 1; i >= 0; i--) {
Projectile projectile = this.projectiles.get(i);
if ((this.arrowTrackingTime != -1 && projectile.getTicksLived() >= this.arrowTrackingTime) || !projectile.isValid() || projectile.getShooter() == null)
if (projectile == null || (this.arrowTrackingTime != -1 && projectile.getTicksLived() >= this.arrowTrackingTime) || !projectile.isValid() || projectile.getShooter() == null)
this.projectiles.remove(i);
}
}, 0L, 5L);
@ -49,6 +49,9 @@ public class ParticleStyleArrows extends DefaultParticleStyle implements Listene
List<Projectile> listCopy = new ArrayList<>(this.projectiles); // Copy in case of modification while looping due to async
for (int i = listCopy.size() - 1; i >= 0; i--) { // Loop backwards so the last-fired projectiles are the ones that have particles if they go over the max
Projectile projectile = listCopy.get(i);
if (projectile == null) // This shouldn't even be possible yet somebody sent me a stacktrace with the projectile null anyway
continue;
if (this.onlySpawnIfFlying && projectile.isOnGround())
continue;