From 35862998ee474f35c3eb4166942c734db7b327ad Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Wed, 3 May 2023 04:12:13 +0100 Subject: [PATCH] Do not spawn particles for invisible or spectator players (#5) --- .../java/pw/kaboom/particletrails/Main.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/pw/kaboom/particletrails/Main.java b/src/main/java/pw/kaboom/particletrails/Main.java index 6f217bc..8bf658a 100644 --- a/src/main/java/pw/kaboom/particletrails/Main.java +++ b/src/main/java/pw/kaboom/particletrails/Main.java @@ -6,13 +6,13 @@ import java.util.Collections; import java.util.List; import java.util.HashSet; import java.util.Set; -import java.util.UUID; import com.destroystokyo.paper.event.server.ServerTickStartEvent; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.World; +import org.bukkit.GameMode; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -22,12 +22,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -85,6 +80,16 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener } for (Player player: Bukkit.getOnlinePlayers()) { + if (player.isInvisible()) { + continue; + } + + final GameMode gameMode = player.getGameMode(); + + if (gameMode.equals(GameMode.SPECTATOR)) { + continue; + } + final String playerUuid = player.getUniqueId().toString(); if (!config.contains(playerUuid)) {