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