From 11d448aabacdfd19fe867b04fa5c4d8eb02a307a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 8 Oct 2022 15:21:31 +0200 Subject: [PATCH] Hotfix ParticleListener --- src/de/steamwar/lobby/listener/ParticleListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 984c3e9..13a90d1 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -33,12 +33,17 @@ import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import java.sql.BatchUpdateException; + public class ParticleListener extends BasicListener { + private static final int PLAYER_MAX_SIZE = 20; + private static double deg = 0; public ParticleListener() { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; deg += 0.1; if (deg > 360) deg = 0; Bukkit.getOnlinePlayers().forEach(player -> { @@ -55,6 +60,7 @@ public class ParticleListener extends BasicListener { @EventHandler(priority = EventPriority.NORMAL) public void handlePlayerInteract(PlayerInteractEvent event) { + if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; Player player = event.getPlayer(); if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return; event.setCancelled(true); @@ -64,6 +70,7 @@ public class ParticleListener extends BasicListener { @EventHandler public void handlePlayerMove(PlayerMoveEvent event) { + if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; Player player = event.getPlayer(); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); ParticleEnum particle = lobbyPlayer.getParticle();