Fix bug with celebration style in fixed effects after player logs off

This commit is contained in:
Esophose 2020-02-13 06:03:32 -07:00
parent 13686f72e2
commit 1c834c7bb6
8 changed files with 15 additions and 11 deletions

View file

@ -10,7 +10,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
group = 'dev.esophose'
version = '7.0'
version = '7.1'
java {
withJavadocJar()

View file

@ -21,6 +21,7 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -178,13 +179,14 @@ public class ParticleManager extends Manager implements Listener, Runnable {
/**
* An alternative method used for event styles
*
* @param player The player the particles are spawning from
* @param player The player the particles are spawning from, nullable for special cases
* @param world The world the particles are spawning in
* @param particle The ParticlePair to use for getting particle settings
* @param particles The particles to display
*/
public void displayParticles(Player player, ParticlePair particle, List<PParticle> particles) {
public void displayParticles(Player player, World world, ParticlePair particle, List<PParticle> particles) {
PermissionManager permissionManager = this.playerParticles.getManager(PermissionManager.class);
if (player.getGameMode() == GameMode.SPECTATOR || !permissionManager.isWorldEnabled(player.getWorld().getName()))
if ((player != null && player.getGameMode() == GameMode.SPECTATOR) || !permissionManager.isWorldEnabled(world.getName()))
return;
for (PParticle pparticle : particles)

View file

@ -66,7 +66,7 @@ public class ParticleStyleBlockBreak extends DefaultParticleStyle implements Lis
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.BLOCKBREAK)) {
Location loc = event.getBlock().getLocation().clone();
particleManager.displayParticles(player, particle, DefaultStyles.BLOCKBREAK.getParticles(particle, loc));
particleManager.displayParticles(player, player.getWorld(), particle, DefaultStyles.BLOCKBREAK.getParticles(particle, loc));
}
}
}

View file

@ -66,7 +66,7 @@ public class ParticleStyleBlockPlace extends DefaultParticleStyle implements Lis
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.BLOCKPLACE)) {
Location loc = event.getBlock().getLocation().clone();
particleManager.displayParticles(player, particle, DefaultStyles.BLOCKPLACE.getParticles(particle, loc));
particleManager.displayParticles(player, player.getWorld(), particle, DefaultStyles.BLOCKPLACE.getParticles(particle, loc));
}
}
}

View file

@ -123,7 +123,7 @@ public class ParticleStyleCelebration extends DefaultParticleStyle {
trail.setEffect(ParticleStyleCelebration.this.fuseEffect);
trail.setStyle(DefaultStyles.CELEBRATION);
particleManager.displayParticles(player, trail, Collections.singletonList(new PParticle(this.location)));
particleManager.displayParticles(player, this.location.getWorld(), trail, Collections.singletonList(new PParticle(this.location)));
this.location.add(0, ParticleStyleCelebration.this.fuseSpacing, 0);
} else {
@ -140,7 +140,7 @@ public class ParticleStyleCelebration extends DefaultParticleStyle {
particles.add(new PParticle(this.location.clone().add(dx, dy, dz)));
}
particleManager.displayParticles(player, particle, particles);
particleManager.displayParticles(player, this.location.getWorld(), particle, particles);
this.cancel();
}

View file

@ -49,7 +49,7 @@ public class ParticleStyleHurt extends DefaultParticleStyle implements Listener
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.HURT)) {
Location loc = player.getLocation().clone().add(0, 1, 0);
particleManager.displayParticles(player, particle, DefaultStyles.HURT.getParticles(particle, loc));
particleManager.displayParticles(player, player.getWorld(), particle, DefaultStyles.HURT.getParticles(particle, loc));
}
}
}

View file

@ -10,6 +10,7 @@ import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -57,7 +58,8 @@ public class ParticleStyleMove extends DefaultParticleStyle implements Listener
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.MOVE)) {
Location loc = event.getPlayer().getLocation().clone();
loc.setY(loc.getY() + 0.05);
particleManager.displayParticles(event.getPlayer(), particle, DefaultStyles.MOVE.getParticles(particle, loc));
Player player = event.getPlayer();
particleManager.displayParticles(player, player.getWorld(), particle, DefaultStyles.MOVE.getParticles(particle, loc));
}
}
}

View file

@ -69,7 +69,7 @@ public class ParticleStyleSwords extends DefaultParticleStyle implements Listene
if (pplayer != null && SWORD_NAMES.contains(player.getInventory().getItemInMainHand().getType().name())) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.SWORDS)) {
Location loc = entity.getLocation().clone().add(0, 1, 0);
particleManager.displayParticles(player, particle, DefaultStyles.SWORDS.getParticles(particle, loc));
particleManager.displayParticles(player, player.getWorld(), particle, DefaultStyles.SWORDS.getParticles(particle, loc));
}
}
}