diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index d531706..d9e5f33 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -41,6 +41,7 @@ PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Not flying PARTICLE_ATTRIBUTE_FLYING = §8-§f Flying PARTICLE_ATTRIBUTE_WING = §8-§f Wings PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Sneaking +PARTICLE_ATTRIBUTE_NON_MOVING = §8-§f Not moving PARTICLE_ATTRIBUTE_SEPARATOR = §f PARTICLE_SELECT = §eClick to select @@ -81,6 +82,8 @@ PARTICLE_WATER_FIRE = §bWater§7/§cFire PARTICLE_MAGIC_ENCHANTING = §5Magic/Enchantment PARTICLE_WINGS_EVIL = §5Purple wings +PARTICLE_PLAYER_HAYLIM_AURA = §fHaylim\'s Aura + PARTICLE_EVENT_ENCHANTING = §cEnchantment PARTICLE_EVENT_CLOUD = §fClouds PARTICLE_EVENT_SMOKE = §7Smoke diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index d830095..c2a3225 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -40,6 +40,7 @@ PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Nicht am Fliegen PARTICLE_ATTRIBUTE_FLYING = §8-§f Am Fliegen PARTICLE_ATTRIBUTE_WING = §8-§f Flügel PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Ducken +PARTICLE_ATTRIBUTE_NON_MOVING = §8-§f Beim Stehen PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_SELECT = §eZum Auswählen klicken diff --git a/src/de/steamwar/lobby/particle/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java index 8253353..8b92071 100644 --- a/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -31,6 +31,10 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Set; public class ParticleListener extends BasicListener { @@ -38,9 +42,14 @@ public class ParticleListener extends BasicListener { private static double deg = 0; + private static Set movingPlayers = new HashSet<>(); + public ParticleListener() { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { - if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; + if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) { + movingPlayers.clear(); + return; + } deg += 0.1; if (deg > 360) deg = 0; Bukkit.getOnlinePlayers().forEach(player -> { @@ -51,9 +60,10 @@ public class ParticleListener extends BasicListener { ParticleData particleData = particle.getParticle(); ParticleElement particleElement = particleData.getParticleElement(); if (particleElement.tickType() == ParticleTickType.ALWAYS) { - particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, movingPlayers.contains(player))); } }); + movingPlayers.clear(); }, 0, 1); } @@ -80,8 +90,16 @@ public class ParticleListener extends BasicListener { ParticleData particleData = particle.getParticle(); ParticleElement particleElement = particleData.getParticleElement(); if (particleElement.tickType() == ParticleTickType.MOVE) { - particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, true)); } + if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getY() != event.getTo().getY() || event.getFrom().getZ() != event.getTo().getZ()) { + movingPlayers.add(player); + } + } + + @EventHandler(ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + movingPlayers.remove(event.getPlayer()); } @EventHandler diff --git a/src/de/steamwar/lobby/particle/ParticleTickData.java b/src/de/steamwar/lobby/particle/ParticleTickData.java index ef55973..b85da90 100644 --- a/src/de/steamwar/lobby/particle/ParticleTickData.java +++ b/src/de/steamwar/lobby/particle/ParticleTickData.java @@ -16,6 +16,7 @@ public class ParticleTickData { private final Player player; private Location location; private final double deg; + private final boolean isMoving; public ParticleTickData withLocation(Location location) { ParticleTickData particleTickData = copy(); @@ -31,6 +32,6 @@ public class ParticleTickData { } public ParticleTickData copy() { - return new ParticleTickData(world, player, location, deg); + return new ParticleTickData(world, player, location, deg, isMoving); } } diff --git a/src/de/steamwar/lobby/particle/elements/custom/NonMoving.java b/src/de/steamwar/lobby/particle/elements/custom/NonMoving.java new file mode 100644 index 0000000..6490958 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/custom/NonMoving.java @@ -0,0 +1,25 @@ +package de.steamwar.lobby.particle.elements.custom; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.elements.DelegatingParticleElement; + +public class NonMoving extends DelegatingParticleElement { + + public NonMoving(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_NON_MOVING"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (particleTickData.isMoving()) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/particle/elements/custom/YOffset.java b/src/de/steamwar/lobby/particle/elements/custom/YOffset.java new file mode 100644 index 0000000..1be8242 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/custom/YOffset.java @@ -0,0 +1,47 @@ +package de.steamwar.lobby.particle.elements.custom; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.elements.DelegatingParticleElement; + +public class YOffset extends DelegatingParticleElement { + + private double multiplication; + private double minY; + private double maxY; + private boolean inverted; + + public YOffset(ParticleElement particleElement, double speed, double minY, double maxY, boolean inverted) { + super(particleElement); + this.multiplication = speed; + this.minY = minY; + this.maxY = maxY; + this.inverted = inverted; + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + double value = ((particleTickData.getDeg() * multiplication) % 360) / 180; + double y; + if (inverted) { + if (value <= 1) { + y = maxY - (maxY - minY) * value; + } else { + y = minY + (maxY - minY) * (value - 1); + } + } else { + if (value <= 1) { + y = minY + (maxY - minY) * value; + } else { + y = maxY - (maxY - minY) * (value - 1); + } + } + ParticleTickData current = particleTickData.withLocation(particleTickData.getLocation().clone().add(0, y, 0)); + particleElement.tick(current); + } +} diff --git a/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java index 910008e..be4ee67 100644 --- a/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java @@ -2,12 +2,24 @@ package de.steamwar.lobby.particle.particles.custom; import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.elements.*; +import de.steamwar.lobby.particle.elements.custom.NonMoving; +import de.steamwar.lobby.particle.elements.custom.YOffset; import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; @AllArgsConstructor public enum CustomPlayerParticle implements ParticleEnum { + Haylim_(new ParticleData(Material.WHITE_CANDLE, "PARTICLE_PLAYER_HAYLIM_AURA", ParticleRequirement.specificPlayer(9426), + new Always(new NonMoving(new NonFlying(new Group( + new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 40, 0, 2, false), new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.0,1), 40, 0, 2, true)), + new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 40, 0, 2, true), new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.0,1), 40, 0, 2, false)) + ))))) + ), ; public static ParticleEnum[] particles = values();