13
0

Hotfix ParticleListener

Dieser Commit ist enthalten in:
yoyosource 2022-10-08 15:21:31 +02:00
Ursprung 3d5dc2e07e
Commit 11d448aaba

Datei anzeigen

@ -33,12 +33,17 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import java.sql.BatchUpdateException;
public class ParticleListener extends BasicListener { public class ParticleListener extends BasicListener {
private static final int PLAYER_MAX_SIZE = 20;
private static double deg = 0; private static double deg = 0;
public ParticleListener() { public ParticleListener() {
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return;
deg += 0.1; deg += 0.1;
if (deg > 360) deg = 0; if (deg > 360) deg = 0;
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
@ -55,6 +60,7 @@ public class ParticleListener extends BasicListener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {
if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return; if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return;
event.setCancelled(true); event.setCancelled(true);
@ -64,6 +70,7 @@ public class ParticleListener extends BasicListener {
@EventHandler @EventHandler
public void handlePlayerMove(PlayerMoveEvent event) { public void handlePlayerMove(PlayerMoveEvent event) {
if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
ParticleEnum particle = lobbyPlayer.getParticle(); ParticleEnum particle = lobbyPlayer.getParticle();