From fa9a359270089e18df4667c38f3303c12e1ce2c1 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 10:09:03 +0100 Subject: [PATCH] Update some stuff --- .../lobby/listener/ParticleListener.java | 8 +++-- .../steamwar/lobby/particle/BaseParticle.java | 36 +++++++++++++++++++ .../lobby/particle/SpecialParticle.java | 1 - 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/BaseParticle.java diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 9d37e92..9b408e2 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -38,6 +38,12 @@ public class ParticleListener extends BasicListener { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { deg += 0.1; if (deg > 360) deg = 0; + Bukkit.getOnlinePlayers().forEach(player -> { + LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); + SpecialParticle particle = lobbyPlayer.getParticle(); + if (particle == null) return; + particle.execute(player.getWorld(), player, deg); + }); }, 0, 1); } @@ -58,6 +64,4 @@ public class ParticleListener extends BasicListener { if (particle == null) return; particle.execute(player.getWorld(), player, deg); } - - } diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java new file mode 100644 index 0000000..8bf9162 --- /dev/null +++ b/src/de/steamwar/lobby/particle/BaseParticle.java @@ -0,0 +1,36 @@ +package de.steamwar.lobby.particle; + +import de.steamwar.inventory.SWItem; +import org.bukkit.Color; +import org.bukkit.Particle; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public interface BaseParticle { + List EMPTY_LORE = new ArrayList<>(); + Random RANDOM = new Random(); + + default Color randomColor() { + return Color.fromRGB(RANDOM.nextInt(256), RANDOM.nextInt(256), RANDOM.nextInt(256)); + } + + default float randomSize() { + return RANDOM.nextFloat() / 2 + 1; + } + + default Particle.DustOptions getParticleDust() { + return new Particle.DustOptions(randomColor(), randomSize()); + } + + SWItem getItem(); + + default boolean tickable() { + return false; + } + + void particle(World world, Player player, double deg); +} diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java index 6ba8e21..3a81325 100644 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ b/src/de/steamwar/lobby/particle/SpecialParticle.java @@ -80,5 +80,4 @@ public abstract class SpecialParticle { } public abstract void particle(World world, Player player, double deg); - }