From abda6b652da23392192a3f92f8ec82557ae6a08d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 16:57:48 +0200 Subject: [PATCH] Fix some stuff and implement rest of EasterParticle's --- src/de/steamwar/lobby/LobbySystem.properties | 16 +++++++- .../steamwar/lobby/LobbySystem_de.properties | 13 ++++++- .../steamwar/lobby/particle/ParticleData.java | 3 +- .../lobby/particle/ParticleRequirement.java | 5 ++- .../lobby/particle/elements/Delayed.java | 4 ++ .../lobby/particle/elements/Floor.java | 23 ++++++++++++ .../lobby/particle/elements/Flying.java | 24 ++++++++++++ .../lobby/particle/elements/Group.java | 9 +++++ .../lobby/particle/elements/NonFlying.java | 2 +- .../lobby/particle/elements/Separator.java | 18 +++++++++ .../lobby/particle/elements/Sneaking.java | 2 +- .../lobby/particle/elements/Wing.java | 1 + .../particle/particles/EasterParticle.java | 37 ++++++++++++------- .../particle/particles/PlayerParticle.java | 2 +- 14 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/elements/Floor.java create mode 100644 src/de/steamwar/lobby/particle/elements/Flying.java create mode 100644 src/de/steamwar/lobby/particle/elements/Separator.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 4b3918e..d531706 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -30,13 +30,18 @@ PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF = §fFind 45 Easter Eggs PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY = §fFind all Easter Eggs with difficulty {0} +PARTICLE_ATTRIBUTE = §eAttributes§7: PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Double ring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Cloud PARTICLE_ATTRIBUTE_TICK = §8-§f Always active -PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in air +PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f In air +PARTICLE_ATTRIBUTE_FLOOR = §8-§f On ground +PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Not flying +PARTICLE_ATTRIBUTE_FLYING = §8-§f Flying PARTICLE_ATTRIBUTE_WING = §8-§f Wings -PARTICLE_ATTRIBUTE = §eAttributes§7: +PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Sneaking +PARTICLE_ATTRIBUTE_SEPARATOR = §f PARTICLE_SELECT = §eClick to select PARTICLE_LOCKED = §c§lLocked @@ -85,6 +90,13 @@ PARTICLE_EVENT_RAIN_CLOUD = §fRaincloud PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WARGEARCLASH = §fClash +PARTICLE_EGG_HUNT_EASY = §aGreenery +PARTICLE_EGG_HUNT_MEDIUM = §eHide and Seek +PARTICLE_EGG_HUNT_HARD = §cOrbit +PARTICLE_EGG_HUNT_EXTREME = §5Purple rain +PARTICLE_EGG_HUNT_ADVANCED = §5Lift off +PARTICLE_EGG_HUNT_HALF = §fThe hunt is on + JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §c{2} §7{3} JUMP_AND_RUN_CANCEL = {0} JUMP_AND_RUN_TIME = mm:ss SSS diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index a28262e..d830095 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -34,8 +34,12 @@ PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppelring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke PARTICLE_ATTRIBUTE_TICK = §8-§f Immer aktiv -PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft +PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f In der Luft +PARTICLE_ATTRIBUTE_FLOOR = §8-§f Auf dem Boden +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 = §eAttribute§7: PARTICLE_SELECT = §eZum Auswählen klicken @@ -85,6 +89,13 @@ PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WARGEARCLASH = §fClash +PARTICLE_EGG_HUNT_EASY = §aGrünplfanzen +PARTICLE_EGG_HUNT_MEDIUM = §eVersteckspiel +PARTICLE_EGG_HUNT_HARD = §cOrbit +PARTICLE_EGG_HUNT_EXTREME = §5Lila regen +PARTICLE_EGG_HUNT_ADVANCED = §5Abheben +PARTICLE_EGG_HUNT_HALF = §fDie Jagd ist eröffnet + JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails # Easter Egg Hunt diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java index 01ae549..0bf1b5b 100644 --- a/src/de/steamwar/lobby/particle/ParticleData.java +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -8,7 +8,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -16,7 +15,7 @@ public class ParticleData { private final Material material; private final String name; - private final Set attributes = new LinkedHashSet<>(); + private final List attributes = new ArrayList<>(); @Getter private final ParticleRequirement requirement; diff --git a/src/de/steamwar/lobby/particle/ParticleRequirement.java b/src/de/steamwar/lobby/particle/ParticleRequirement.java index d228a81..f501a75 100644 --- a/src/de/steamwar/lobby/particle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/particle/ParticleRequirement.java @@ -6,6 +6,7 @@ import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; +import de.steamwar.sql.UserGroup; import org.bukkit.entity.Player; import java.util.HashSet; @@ -28,7 +29,7 @@ public interface ParticleRequirement { @Override public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { - return false; + return user.getUserGroup() != UserGroup.Member; } }; @@ -162,7 +163,7 @@ public interface ParticleRequirement { @Override public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { if (eggHuntConfig == null) return false; - return eggs.stream().allMatch(id -> eggHuntConfig.length() >= id && eggHuntConfig.charAt(id) == '1'); + return eggs.stream().allMatch(id -> eggHuntConfig.length() > id && eggHuntConfig.charAt(id) == '1'); } }; } diff --git a/src/de/steamwar/lobby/particle/elements/Delayed.java b/src/de/steamwar/lobby/particle/elements/Delayed.java index f13d9b5..3fb9632 100644 --- a/src/de/steamwar/lobby/particle/elements/Delayed.java +++ b/src/de/steamwar/lobby/particle/elements/Delayed.java @@ -29,6 +29,10 @@ public class Delayed extends DelegatingParticleElement { public Delayed(ParticleElement particleElement, int interval) { super(particleElement); Bukkit.getPluginManager().registerEvents(delayedData, LobbySystem.getPlugin()); + this.interval = interval; + if (interval <= 0) { + throw new IllegalArgumentException("Interval must be greater than 0"); + } } @Override diff --git a/src/de/steamwar/lobby/particle/elements/Floor.java b/src/de/steamwar/lobby/particle/elements/Floor.java new file mode 100644 index 0000000..0b4ef7f --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/Floor.java @@ -0,0 +1,23 @@ +package de.steamwar.lobby.particle.elements; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; + +public class Floor extends DelegatingParticleElement { + + public Floor(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_FLOOR"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (!particleTickData.getWorld().getBlockAt(particleTickData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType().isAir()) { + particleElement.tick(particleTickData); + } + } +} diff --git a/src/de/steamwar/lobby/particle/elements/Flying.java b/src/de/steamwar/lobby/particle/elements/Flying.java new file mode 100644 index 0000000..ed160a5 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/Flying.java @@ -0,0 +1,24 @@ +package de.steamwar.lobby.particle.elements; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; + +public class Flying extends DelegatingParticleElement { + + public Flying(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_FLYING"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (!particleTickData.getPlayer().isGliding()) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/particle/elements/Group.java b/src/de/steamwar/lobby/particle/elements/Group.java index b6fc771..6e567a0 100644 --- a/src/de/steamwar/lobby/particle/elements/Group.java +++ b/src/de/steamwar/lobby/particle/elements/Group.java @@ -1,5 +1,6 @@ package de.steamwar.lobby.particle.elements; +import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleElement; import de.steamwar.lobby.particle.ParticleTickData; @@ -17,6 +18,14 @@ public class Group extends DelegatingParticleElement { return null; } + @Override + public void aggregateAttributes(ParticleData particleData) { + particleElement.aggregateAttributes(particleData); + for (ParticleElement particleElement : rest) { + particleElement.aggregateAttributes(particleData); + } + } + @Override public void tick(ParticleTickData particleTickData) { particleElement.tick(particleTickData); diff --git a/src/de/steamwar/lobby/particle/elements/NonFlying.java b/src/de/steamwar/lobby/particle/elements/NonFlying.java index 2f74f9b..4579e21 100644 --- a/src/de/steamwar/lobby/particle/elements/NonFlying.java +++ b/src/de/steamwar/lobby/particle/elements/NonFlying.java @@ -11,7 +11,7 @@ public class NonFlying extends DelegatingParticleElement { @Override public String attribute() { - return null; + return "PARTICLE_ATTRIBUTE_NON_FLYING"; } @Override diff --git a/src/de/steamwar/lobby/particle/elements/Separator.java b/src/de/steamwar/lobby/particle/elements/Separator.java new file mode 100644 index 0000000..6792b44 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/Separator.java @@ -0,0 +1,18 @@ +package de.steamwar.lobby.particle.elements; + +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; + +public class Separator implements ParticleElement { + + @Override + public void aggregateAttributes(ParticleData particleData) { + particleData.add("PARTICLE_ATTRIBUTE_SEPARATOR"); + } + + @Override + public void tick(ParticleTickData particleTickData) { + // do nothing + } +} diff --git a/src/de/steamwar/lobby/particle/elements/Sneaking.java b/src/de/steamwar/lobby/particle/elements/Sneaking.java index 42bb16c..833e4c1 100644 --- a/src/de/steamwar/lobby/particle/elements/Sneaking.java +++ b/src/de/steamwar/lobby/particle/elements/Sneaking.java @@ -11,7 +11,7 @@ public class Sneaking extends DelegatingParticleElement { @Override public String attribute() { - return null; // TODO: Implement this attribute + return "PARTICLE_ATTRIBUTE_SNEAKING"; } @Override diff --git a/src/de/steamwar/lobby/particle/elements/Wing.java b/src/de/steamwar/lobby/particle/elements/Wing.java index f0f8203..6163382 100644 --- a/src/de/steamwar/lobby/particle/elements/Wing.java +++ b/src/de/steamwar/lobby/particle/elements/Wing.java @@ -13,6 +13,7 @@ public class Wing extends DelegatingParticleElement { public Wing(ParticleElement particleElement, double size, WingDesign wingDesign) { super(particleElement); + this.size = size; this.wingDesign = wingDesign; } diff --git a/src/de/steamwar/lobby/particle/particles/EasterParticle.java b/src/de/steamwar/lobby/particle/particles/EasterParticle.java index 8980995..cecd91b 100644 --- a/src/de/steamwar/lobby/particle/particles/EasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/EasterParticle.java @@ -3,34 +3,45 @@ package de.steamwar.lobby.particle.particles; import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleEnum; import de.steamwar.lobby.particle.ParticleRequirement; -import de.steamwar.lobby.particle.elements.Always; -import de.steamwar.lobby.particle.elements.LocationMutator; -import de.steamwar.lobby.particle.elements.SimpleParticle; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; @AllArgsConstructor public enum EasterParticle implements ParticleEnum { EGG_HUNT_EASY(new ParticleData(Material.LIME_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EASY", ParticleRequirement.EGG_HUNT_EASY, - new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM, 0.2F, 0.1f, 0.2F, 1, 5), 0, 2.2, 0))) + new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM, 0.5F, 0.1f, 0.5F, 1, 1), 0, 2.2, 0))) ), EGG_HUNT_MEDIUM(new ParticleData(Material.YELLOW_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_MEDIUM", ParticleRequirement.EGG_HUNT_MEDIUM, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + new Always(new Floor(new Sneaking(new SimpleParticle(Particle.GLOW_SQUID_INK, 0.4F, 0.9F, 0.4F, 0.01))))) ), - EGG_HUNT_HARD(new ParticleData(Material.ORANGE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD", ParticleRequirement.EGG_HUNT_HARD, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_HARD(new ParticleData(Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD", ParticleRequirement.EGG_HUNT_HARD, + new Always(new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0.01, 1), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0.01, 1)), 0, 0.5, 0))) ), - EGG_HUNT_EXTREME(new ParticleData(Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EXTREME", ParticleRequirement.EGG_HUNT_EXTREME, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_EXTREME(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EXTREME", ParticleRequirement.EGG_HUNT_EXTREME, + new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_OBSIDIAN_TEAR, 0.5F, 0.1F, 0.5F, 1, 1), 0, 2.2, 0))) ), - EGG_HUNT_ADVANCED(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_ADVANCED", ParticleRequirement.EGG_HUNT_ADVANCED, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_ADVANCED(new ParticleData(Material.BLACK_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_ADVANCED", ParticleRequirement.EGG_HUNT_ADVANCED, + new Always(new Sneaking(new LocationMutator(new Group( + new SimpleParticle(Particle.SMOKE_NORMAL, 0.02F, 0, 0.02F, 0.05, 1), + new SimpleParticle(Particle.SMOKE_LARGE, 0.02F, 0, 0.02F, 0.05, 1), + particleTickData -> { + Player player = particleTickData.getPlayer(); + player.setVelocity(player.getVelocity().add(new Vector(0, 0.1, 0))); + } + ), 0, -0.2, 0)))) ), - EGG_HUNT_HALF(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HALF", ParticleRequirement.EGG_HUNT_FOUND_HALF, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_HALF(new ParticleData(Material.EGG, "PARTICLE_EGG_HUNT_HALF", ParticleRequirement.EGG_HUNT_FOUND_HALF, + new Group( + new Always(new Sneaking(new Floor(new LocationMutator(new SimpleParticle(Particle.HEART, 0, 0, 0, 0.01), 0, 1.7, 0)))), + new Separator(), + new Always(new NonFloor(new NonFlying(new LocationMutator(new Cloud(new Circle(new SimpleParticle(Particle.HEART, 0, 0, 0, 0.01))), 0, 0.5, 0)))) + )) ), ; public static ParticleEnum[] particles = values(); diff --git a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java index ed66d8c..f54c516 100644 --- a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java @@ -38,7 +38,7 @@ public enum PlayerParticle implements ParticleEnum { new SimpleParticle(Particle.SNOWBALL, 0.2F, 0.2F ,0.2F, 0.01)) ), EFFECT(new ParticleData(Material.GLASS_BOTTLE, "PARTICLE_EFFECT", - new DustParticle(Particle.REDSTONE, 0, 0.2F, 02F, 0.01, 5)) + new DustParticle(Particle.REDSTONE, 0, 0.2F, 0, 0.01, 5)) ), CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01))