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();