Skip to content

Commit

Permalink
Fix bug with celebration style in fixed effects after player logs off
Browse files Browse the repository at this point in the history
  • Loading branch information
Esophose committed Feb 13, 2020
1 parent 13686f7 commit 1c834c7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -178,13 +179,14 @@ private void displayParticles(PPlayer pplayer, ParticlePair particle, Location l
/**
* 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onBlockBreak(BlockBreakEvent event) {
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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void run() {
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 {
Expand All @@ -140,7 +140,7 @@ public void run() {

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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onEntityDamage(EntityDamageEvent event) {
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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand Down Expand Up @@ -57,7 +58,8 @@ public void onPlayerMove(PlayerMoveEvent event) {
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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onEntityDamageEntity(EntityDamageByEntityEvent event) {
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));
}
}
}
Expand Down

0 comments on commit 1c834c7

Please sign in to comment.