mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2024-12-28 02:14:15 +00:00
Don't display particles if the player is invisible
This commit is contained in:
parent
d2de109103
commit
f94e87960f
2 changed files with 12 additions and 5 deletions
|
@ -12,7 +12,7 @@ import dev.esophose.playerparticles.particles.ParticlePair;
|
|||
import dev.esophose.playerparticles.particles.data.NoteColor;
|
||||
import dev.esophose.playerparticles.particles.data.OrdinaryColor;
|
||||
import dev.esophose.playerparticles.styles.DefaultStyles;
|
||||
import dev.esophose.playerparticles.util.NMSUtil;
|
||||
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||
import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
@ -22,7 +22,6 @@ import java.util.Random;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -190,9 +189,9 @@ public class ParticleManager extends Manager implements Listener, Runnable {
|
|||
for (PPlayer pplayer : this.particlePlayers.values()) {
|
||||
Player player = pplayer.getPlayer();
|
||||
|
||||
// Don't show their particles if they are in spectator mode
|
||||
// Don't show their particles if they are invisible
|
||||
// Don't spawn particles if the world doesn't allow it
|
||||
if (player != null && (NMSUtil.getVersionNumber() < 8 || player.getGameMode() != GameMode.SPECTATOR) && permissionManager.isWorldEnabled(player.getWorld().getName()))
|
||||
if (player != null && ParticleUtils.isPlayerVisible(player) && permissionManager.isWorldEnabled(player.getWorld().getName()))
|
||||
for (ParticlePair particles : pplayer.getActiveParticles())
|
||||
this.displayParticles(pplayer, particles, player.getLocation().clone().add(0, 1, 0));
|
||||
|
||||
|
@ -285,7 +284,7 @@ public class ParticleManager extends Manager implements Listener, Runnable {
|
|||
player = pplayer.getPlayer();
|
||||
}
|
||||
|
||||
if ((player != null && (NMSUtil.getVersionNumber() < 8 || player.getGameMode() == GameMode.SPECTATOR)) || !permissionManager.isWorldEnabled(world.getName()))
|
||||
if ((player != null && !ParticleUtils.isPlayerVisible(player)) || !permissionManager.isWorldEnabled(world.getName()))
|
||||
return;
|
||||
|
||||
for (PParticle pparticle : particles)
|
||||
|
|
|
@ -6,9 +6,12 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public final class ParticleUtils {
|
||||
|
||||
|
@ -128,4 +131,9 @@ public final class ParticleUtils {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlayerVisible(Player player) {
|
||||
return (NMSUtil.getVersionNumber() <= 8 || player.getGameMode() != GameMode.SPECTATOR)
|
||||
&& !player.hasPotionEffect(PotionEffectType.INVISIBILITY);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue