From 438b336535e4ea6ad9d4ac07da8c3623aaeb67ae Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 14:54:38 +0200 Subject: [PATCH] Remove old particle system --- .../lobby/otherparticle/ParticleData.java | 75 ---------- .../otherparticle/ParticleInventory.java | 97 ------------ .../particles/EventParticle.java | 29 ---- .../particles/EventParticleParticipation.java | 45 ------ .../particles/EventParticlePlacement.java | 51 ------- .../particles/PlayerParticle.java | 63 -------- .../particles/ServerTeamParticle.java | 99 ------------- .../otherparticle/particles/TeamParticle.java | 50 ------- .../steamwar/lobby/particle/BaseParticle.java | 49 ------ .../lobby/particle/DustSimpleParticle.java | 60 -------- .../lobby/particle/EventParticleItem.java | 74 --------- .../lobby/particle/ParticleBuilder.java | 15 -- .../steamwar/lobby/particle/ParticleData.java | 105 ++++++++----- .../ParticleElement.java | 2 +- .../ParticleEnum.java | 2 +- .../lobby/particle/ParticleInventory.java | 131 +++++++--------- .../steamwar/lobby/particle/ParticleItem.java | 69 --------- .../lobby/particle/ParticleListener.java | 18 ++- .../ParticleRequirement.java | 51 ++++--- .../ParticleTickData.java | 2 +- .../ParticleTickType.java | 3 +- .../lobby/particle/SimpleParticle.java | 82 ---------- .../WingDesign.java | 5 +- .../particle/decorator/CircleParticle.java | 75 ---------- .../particle/decorator/CloudParticle.java | 59 -------- .../particle/decorator/NonFloorParticle.java | 46 ------ .../particle/decorator/TickParticle.java | 49 ------ .../particle/decorator/WingParticle.java | 116 --------------- .../elements/Always.java | 8 +- .../elements/Circle.java | 6 +- .../elements/Cloud.java | 6 +- .../elements/Delayed.java | 6 +- .../elements/DelegatingParticleElement.java | 8 +- .../elements/DoubleCircle.java | 8 +- .../elements/DustParticle.java | 6 +- .../elements/Group.java | 6 +- .../elements/LocationMutator.java | 6 +- .../elements/NonFloor.java | 6 +- .../elements/NonFlying.java | 6 +- .../elements/SimpleParticle.java | 6 +- .../elements/Sneaking.java | 12 +- .../elements/Wing.java | 8 +- .../lobby/particle/group/ParticleGroup.java | 47 ------ .../mutator/LocationParticleMutator.java | 54 ------- .../particles/EasterParticle.java | 14 +- .../particle/particles/EventParticle.java | 45 ++---- .../particles/EventParticleParticipation.java | 77 +++++----- .../particles/EventParticlePlacement.java | 84 +++++------ .../particle/particles/ParticleEnum.java | 26 ---- .../particle/particles/PlayerParticle.java | 89 ++++++----- .../particles/ServerTeamParticle.java | 140 +++++++++++------- .../particles/SpecialTeamParticle.java | 43 ------ .../particle/particles/TeamParticle.java | 72 +++++---- .../custom/CustomEasterParticle.java | 6 +- .../custom/CustomPlayerParticle.java | 6 +- .../particles/custom/CustomTeamParticle.java | 12 +- src/de/steamwar/lobby/util/LobbyPlayer.java | 36 +---- 57 files changed, 489 insertions(+), 1882 deletions(-) delete mode 100644 src/de/steamwar/lobby/otherparticle/ParticleData.java delete mode 100644 src/de/steamwar/lobby/otherparticle/ParticleInventory.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticle.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java delete mode 100644 src/de/steamwar/lobby/particle/BaseParticle.java delete mode 100644 src/de/steamwar/lobby/particle/DustSimpleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/EventParticleItem.java delete mode 100644 src/de/steamwar/lobby/particle/ParticleBuilder.java rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleElement.java (96%) rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleEnum.java (62%) delete mode 100644 src/de/steamwar/lobby/particle/ParticleItem.java rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleRequirement.java (90%) rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleTickData.java (95%) rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleTickType.java (54%) delete mode 100644 src/de/steamwar/lobby/particle/SimpleParticle.java rename src/de/steamwar/lobby/{otherparticle => particle}/WingDesign.java (90%) delete mode 100644 src/de/steamwar/lobby/particle/decorator/CircleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/CloudParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/TickParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/WingParticle.java rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Always.java (68%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Circle.java (81%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Cloud.java (86%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Delayed.java (89%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/DelegatingParticleElement.java (75%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/DoubleCircle.java (85%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/DustParticle.java (87%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Group.java (77%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/LocationMutator.java (83%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/NonFloor.java (76%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/NonFlying.java (73%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/SimpleParticle.java (91%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Sneaking.java (59%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Wing.java (84%) delete mode 100644 src/de/steamwar/lobby/particle/group/ParticleGroup.java delete mode 100644 src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java rename src/de/steamwar/lobby/{otherparticle => particle}/particles/EasterParticle.java (79%) delete mode 100644 src/de/steamwar/lobby/particle/particles/ParticleEnum.java delete mode 100644 src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java rename src/de/steamwar/lobby/{otherparticle => particle}/particles/custom/CustomEasterParticle.java (60%) rename src/de/steamwar/lobby/{otherparticle => particle}/particles/custom/CustomPlayerParticle.java (60%) rename src/de/steamwar/lobby/{otherparticle => particle}/particles/custom/CustomTeamParticle.java (63%) diff --git a/src/de/steamwar/lobby/otherparticle/ParticleData.java b/src/de/steamwar/lobby/otherparticle/ParticleData.java deleted file mode 100644 index 8a70c08..0000000 --- a/src/de/steamwar/lobby/otherparticle/ParticleData.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.steamwar.lobby.otherparticle; - -import de.steamwar.inventory.SWItem; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; -import lombok.Getter; -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; - -public class ParticleData { - - private final Material material; - private final String name; - private final Set attributes = new LinkedHashSet<>(); - - @Getter - private final ParticleRequirement requirement; - - @Getter - private final ParticleElement particleElement; - - public ParticleData(Material material, String name, ParticleElement particleElement) { - this.material = material; - this.name = name; - this.requirement = ParticleRequirement.NO_REQUIRMENT; - this.particleElement = particleElement; - particleElement.aggregateAttributes(this); - } - - public ParticleData(Material material, String name, ParticleRequirement requirement, ParticleElement particleElement) { - this.material = material; - this.name = name; - this.requirement = requirement; - this.particleElement = particleElement; - particleElement.aggregateAttributes(this); - } - - public ParticleData add(String attribute) { - attributes.add(attribute); - return this; - } - - public SWItem toSWItem(Player player, SteamwarUser user, Set eventTeilnahme, String eggHuntConfig) { - String translatedName = LobbySystem.getMessage().parse(name, player); - List lore = new ArrayList<>(); - lore.add(""); - if (!attributes.isEmpty()) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player)); - attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); - lore.add(""); - } - - boolean selectable = requirement.getRequirement().test(user, eventTeilnahme, eggHuntConfig); - selectable |= user.getUserGroup() != UserGroup.Member; - - String unlockedBy = requirement.getRequirementName(player); - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(unlockedBy); - lore.add(""); - } - if (selectable) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); - } else { - lore.add(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player)); - } - return new SWItem(material, translatedName, lore, false, clickType -> {}); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleInventory.java b/src/de/steamwar/lobby/otherparticle/ParticleInventory.java deleted file mode 100644 index 252a140..0000000 --- a/src/de/steamwar/lobby/otherparticle/ParticleInventory.java +++ /dev/null @@ -1,97 +0,0 @@ -package de.steamwar.lobby.otherparticle; - -import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.otherparticle.particles.*; -import de.steamwar.lobby.otherparticle.particles.custom.CustomEasterParticle; -import de.steamwar.lobby.otherparticle.particles.custom.CustomPlayerParticle; -import de.steamwar.lobby.otherparticle.particles.custom.CustomTeamParticle; -import de.steamwar.lobby.special.easter.EggHunt; -import de.steamwar.lobby.util.LobbyPlayer; -import de.steamwar.sql.*; -import lombok.experimental.UtilityClass; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -@UtilityClass -public class ParticleInventory { - - private final Class[] PARTICLES = { - PlayerParticle.class, - CustomPlayerParticle.class, - TeamParticle.class, - CustomTeamParticle.class, - ServerTeamParticle.class, - EventParticle.class, - EventParticlePlacement.class, - EventParticleParticipation.class, - EasterParticle.class, - CustomEasterParticle.class, - }; - - public String convertToString(ParticleEnum particleEnum) { - return particleEnum.getClass().getSimpleName() + "@" + ((Enum)particleEnum).name(); - } - - public ParticleEnum convertFromString(String string) { - String[] split = string.split("@"); - Class clazz = null; - for (Class aClass : PARTICLES) { - if (aClass.getSimpleName().equals(split[0])) { - clazz = aClass; - break; - } - } - if (clazz != null) { - try { - return (ParticleEnum) Enum.valueOf((Class) clazz, split[1]); - } catch (Exception e) { - return null; - } - } - // TODO: Add conversion from last version - return null; - } - - public void openInventory(Player player) { - LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - Set events = user.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(user.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); - String eggHuntConfig = UserConfig.getConfig(user.getId(), EggHunt.EGG_HUNT_CONFIG_KEY); - - List> particleList = new ArrayList<>(); - for (Class clazz : PARTICLES) { - addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, user, events, eggHuntConfig); - } - - SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { - if (particle == null) return; - // lobbyPlayer.setParticle(particle); // TODO: Update this - player.closeInventory(); - }); - particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> { - lobbyPlayer.setParticle(null); - }); - particleSWListInv.open(); - } - - private void addParticles(List> particleList, ParticleEnum[] particleEnums, Player player, SteamwarUser user, Set events, String eggHuntConfig) { - for (ParticleEnum particle : particleEnums) { - ParticleData particleData = particle.getParticle(); - SWItem swItem = particleData.toSWItem(player, user, events, eggHuntConfig); - if (particleData.getRequirement().test(user, events, eggHuntConfig) || user.getUserGroup() != UserGroup.Member) { - particleList.add(new SWListInv.SWListEntry<>(swItem, particle)); - } else { - particleList.add(new SWListInv.SWListEntry<>(swItem, null)); - } - } - } -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java deleted file mode 100644 index abaa6bd..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.elements.Always; -import de.steamwar.lobby.otherparticle.elements.Circle; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum EventParticle implements ParticleEnum { - - WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", ParticleRequirement.EVENT_PARTICIPATION, - new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_WATER), 0, 1.1, 0)))) - ), - LAVA(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", ParticleRequirement.EVENT_PARTICIPATION, - new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA), 0, 1.1, 0)))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java deleted file mode 100644 index a55a3bd..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum EventParticleParticipation implements ParticleEnum { - - WarGearSeason(new ParticleData(Material.BOOK, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventParticipation(22), - new SimpleParticle(Particle.ENCHANTMENT_TABLE)) - ), - AirshipEvent(new ParticleData(Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventParticipation(26), - new SimpleParticle(Particle.CLOUD)) - ), - HellsBellsWs(new ParticleData(Material.TNT, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventParticipation(28), - new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))) - ), - Underwater(new ParticleData(Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(31), - new SimpleParticle(Particle.DRIP_WATER)) - ), - AdventWarShip(new ParticleData(Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(32), - new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))) - ), - MiniWarGearLiga(new ParticleData(Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(33), - new Circle(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0))) - ), - UnderwaterMWG(new ParticleData(Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventParticipation(35), - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, 0.2, 0)), 0, 2.2, 0))) - ), - WarGearSeason2022(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventParticipation(37), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingDesign.COMPLEX)), 20))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java deleted file mode 100644 index e339e72..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum EventParticlePlacement implements ParticleEnum { - - WarGearSeason(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventPlacement(22, 12, 285, 54), - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 0, 1.1, 0))) - )), - AirshipEvent(new ParticleData(Material.SNOWBALL, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), - new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)) - )), - HellsBellsWs(new ParticleData(Material.TNT_MINECART, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventPlacement(28, 205, 9, 11), - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))) - )), - Underwater(new ParticleData(Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 210, 520), - new Cloud(new SimpleParticle(Particle.DRIP_WATER))) - ), - AdventWarShip(new ParticleData(Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 205, 210), - new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) - ), - MiniWarGearLiga(new ParticleData(Material.IRON_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(33, 9, 34, 205), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) - ), - Absturz(new ParticleData(Material.FEATHER, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(34, 210, 205, 527, 286), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) - ), - UnderwaterMWG(new ParticleData(Material.CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventPlacement(35, 9, 210), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) - ), - WarGearSeason2022(new ParticleData(Material.DIAMOND_HELMET, "PARTICLE_EVENT_WGS", ParticleRequirement.eventPlacement(37, 285, 210, 122), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) - ), - WargearClash(new ParticleData(Material.GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java b/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java deleted file mode 100644 index 88d095e..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.elements.DustParticle; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum PlayerParticle implements ParticleEnum { - - SNEEZE(new ParticleData(Material.SLIME_BLOCK, "PARTICLE_SNEEZE", - new SimpleParticle(Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)) - ), - SMOKE(new ParticleData(Material.COBWEB, "PARTICLE_SMOKE", - new SimpleParticle(Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)) - ), - FIRE(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", - new SimpleParticle(Particle.DRIP_LAVA)) - ), - WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", - new SimpleParticle(Particle.DRIP_WATER)) - ), - HEARTH(new ParticleData(Material.RED_DYE, "PARTICLE_HEART", - new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0)) - ), - NOTES(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", - new LocationMutator(new SimpleParticle(Particle.NOTE), 0, 2.2, 0)) - ), - NAUTILUS(new ParticleData(Material.NAUTILUS_SHELL, "PARTICLE_NAUTILUS", - new SimpleParticle(Particle.NAUTILUS, 0.2F, 0.2F ,0.2F, 0.01)) - ), - SNOWBALL(new ParticleData(Material.SNOWBALL, "PARTICLE_SNOWBALL", - 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)) - ), - CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", - new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) - ), - MAGIC(new ParticleData(Material.CAULDRON, "PARTICLE_MAGIC", - new SimpleParticle(Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)) - ), - ANGRY(new ParticleData(Material.REDSTONE_BLOCK, "PARTICLE_ANGRY", - new SimpleParticle(Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)) - ), - SLIME(new ParticleData(Material.SLIME_BALL, "PARTICLE_SLIME", - new SimpleParticle(Particle.SLIME)) - ), - MOB(new ParticleData(Material.ZOMBIE_HEAD, "PARTICLE_MOB", - new SimpleParticle(Particle.SPELL_MOB)) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java deleted file mode 100644 index ada98bf..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java +++ /dev/null @@ -1,99 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum ServerTeamParticle implements ParticleEnum { - - WITCH(new ParticleData(Material.EXPERIENCE_BOTTLE, "PARTICLE_WITCH", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.SPELL_WITCH)) - ), - ENCHANTING(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.ENCHANTMENT_TABLE)) - ), - HAPPY(new ParticleData(Material.EMERALD_BLOCK, "PARTICLE_HAPPY", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.HEART, 0.2F, 0.2F, 0.2F, 0.01)) - ), - FLAME(new ParticleData(Material.FLINT_AND_STEEL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.FLAME, 0, 0.2F, 0, 0.01)) - ), - END_ROD(new ParticleData(Material.END_ROD, "PARTICLE_END_ROD", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)) - ), - CLOUD(new ParticleData(Material.WHITE_WOOL, "PARTICLE_CLOUD", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.CLOUD))) - ), - TOTEM(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_TOTEM", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))) - ), - ENCHANTING_CLOUD(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.ENCHANTMENT_TABLE))) - ), - FLAME_CLOUD(new ParticleData(Material.FIRE_CORAL_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.FLAME))) - ), - SNEEZE_CLOUD(new ParticleData(Material.LIME_SHULKER_BOX, "PARTICLE_SNEEZE", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.SNEEZE))) - ), - SLIME_CLOUD(new ParticleData(Material.GREEN_SHULKER_BOX, "PARTICLE_SLIME", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.SLIME))) - ), - SMOKE_CLOUD(new ParticleData(Material.DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))) - ), - TOWN_CLOUD(new ParticleData(Material.FIREWORK_STAR, "PARTICLE_TOWN", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.TOWN_AURA))) - ), - FLAME_CIRCLE(new ParticleData(Material.MAGMA_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0))) - ), - ENCHANTING_CIRCLE(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) - ), - NOTES_CIRCLE(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.NOTE, 0, 0, 0, 0.01), 0, 2.2, 0))) - ), - WATER_FIRE(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) - ), - WATER_FIRE_ALWAYS(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) - ), - MAGIC_ENCHANTING(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0)) - ), - MAGIC_ENCHANTING_ALWAYS(new ParticleData(Material.WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0))) - ), - MAGIC_CLOUD_CIRCLE(new ParticleData(Material.GLOWSTONE_DUST, "PARTICLE_MAGIC", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - FLAME_CLOUD_CIRCLE(new ParticleData(Material.FIRE_CORAL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - FIREWORK_CLOUD_CIRCLE(new ParticleData(Material.FIREWORK_ROCKET, "PARTICLE_FIREWORK", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - WATER_CLOUD_CIRCLE(new ParticleData(Material.CYAN_DYE, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - ENCHANTING_DOUBLE_CIRCLE(new ParticleData(Material.BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 2.2, 0))) - ), - EVIL_WINGS(new ParticleData(Material.PURPUR_SLAB, "PARTICLE_WINGS_EVIL", ParticleRequirement.SERVER_TEAM, - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java deleted file mode 100644 index 12bcd2c..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.elements.Circle; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.NonFloor; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum TeamParticle implements ParticleEnum { - - SQUID(new ParticleData(Material.INK_SAC, "PARTICLE_SQUID", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)) - ), - BUBBLE(new ParticleData(Material.TUBE_CORAL, "PARTICLE_BUBBLE", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)) - ), - HONEY(new ParticleData(Material.HONEY_BOTTLE, "PARTICLE_HONEY", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)) - ), - NECTAR(new ParticleData(Material.HONEYCOMB, "PARTICLE_NECTAR", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)) - ), - FIREWORK(new ParticleData(Material.FIRE_CHARGE, "PARTICLE_FIREWORK", ParticleRequirement.HAS_TEAM, - new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) - ), - DRAGON_BREATH(new ParticleData(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)) - ), - DAMAGE(new ParticleData(Material.SPIDER_EYE, "PARTICLE_DAMAGE", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DAMAGE_INDICATOR, 0.2F, 0, 0.2F, 0.01)) - ), - DOLPHIN(new ParticleData(Material.BLUE_DYE, "PARTICLE_DOLPHIN", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DOLPHIN, 0.2F, 0, 0.2F, 0.01)) - ), - HEART(new ParticleData(Material.RED_CONCRETE, "PARTICLE_HEART", ParticleRequirement.HAS_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java deleted file mode 100644 index 9d1a183..0000000 --- a/src/de/steamwar/lobby/particle/BaseParticle.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle; - -import org.bukkit.Color; -import org.bukkit.Particle; - -import java.util.Random; - -public interface BaseParticle { - 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()); - } - - ParticleItem getItem(); - - default boolean needsTick() { - return false; - } - - void particle(ParticleData particleData); -} diff --git a/src/de/steamwar/lobby/particle/DustSimpleParticle.java b/src/de/steamwar/lobby/particle/DustSimpleParticle.java deleted file mode 100644 index 417b6ad..0000000 --- a/src/de/steamwar/lobby/particle/DustSimpleParticle.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Particle; - -public class DustSimpleParticle implements BaseParticle { - - private final ParticleItem particleItem; - private final Particle particle; - private float vx; - private float vy; - private float vz; - private double time = 1; - private int count = 5; - - public DustSimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) { - this.particleItem = particleItem; - this.particle = particle; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - } - - @Override - public ParticleItem getItem() { - return particleItem; - } - - @Override - public void particle(ParticleData particleData) { - Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - Bukkit.getOnlinePlayers().forEach(player -> { - int viewDistance = player.getClientViewDistance() * 16; - if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) { - player.spawnParticle(particle, location, count, vx, vy, vz, time, getParticleDust()); - } - }); - } -} diff --git a/src/de/steamwar/lobby/particle/EventParticleItem.java b/src/de/steamwar/lobby/particle/EventParticleItem.java deleted file mode 100644 index 2c679b9..0000000 --- a/src/de/steamwar/lobby/particle/EventParticleItem.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle; - -import de.steamwar.inventory.SWItem; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.sql.Event; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; - -public class EventParticleItem extends ParticleItem { - - public static EventParticleItem participation(Material material, String name, int eventId) { - return new EventParticleItem(material, name, "PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION", eventId); - } - - public static EventParticleItem placement(Material material, String name, int eventId) { - return new EventParticleItem(material, name, "PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT", eventId); - } - - private final String eventName; - - public EventParticleItem(Material material, String name, int eventId) { - this(material, name, null, eventId); - } - - public EventParticleItem(Material material, String name, String unlockedBy, int eventId) { - super(material, name, unlockedBy); - eventName = Event.get(eventId).getEventName(); - } - - public EventParticleItem addAttribute(String attribute) { - super.addAttribute(attribute); - return this; - } - - public SWItem toSWItem(Player player) { - String translatedName = LobbySystem.getMessage().parse(name, player); - List lore = new ArrayList<>(); - lore.add(""); - if (!attributes.isEmpty()) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player)); - attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); - lore.add(""); - } - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(LobbySystem.getMessage().parse(unlockedBy, player, eventName)); - lore.add(""); - } - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); - return new SWItem(material, translatedName, lore, false, clickType -> {}); - } -} diff --git a/src/de/steamwar/lobby/particle/ParticleBuilder.java b/src/de/steamwar/lobby/particle/ParticleBuilder.java deleted file mode 100644 index 0b8b589..0000000 --- a/src/de/steamwar/lobby/particle/ParticleBuilder.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.steamwar.lobby.particle; - -public class ParticleBuilder { - - public ParticleBuilder() { - } - - public void cloud() {} - - public void offset() {} - - public void rotated() {} - - public void build() {} -} diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java index 8a4523b..01ae549 100644 --- a/src/de/steamwar/lobby/particle/ParticleData.java +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -1,54 +1,77 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle; -import lombok.AllArgsConstructor; +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.SteamwarUser; import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.bukkit.Location; -import org.bukkit.World; +import org.bukkit.Material; import org.bukkit.entity.Player; -@RequiredArgsConstructor -@AllArgsConstructor -@Getter +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + public class ParticleData { - private final World world; - private final Player player; - private Location location; - private final double deg; - public ParticleData withLocation(Location location) { - ParticleData particleData = copy(); - particleData.location = location; - return particleData; + private final Material material; + private final String name; + private final Set attributes = new LinkedHashSet<>(); + + @Getter + private final ParticleRequirement requirement; + + @Getter + private final ParticleElement particleElement; + + public ParticleData(Material material, String name, ParticleElement particleElement) { + this.material = material; + this.name = name; + this.requirement = ParticleRequirement.NO_REQUIRMENT; + this.particleElement = particleElement; + particleElement.aggregateAttributes(this); } - public Location getLocation() { - if (location == null) { - return player.getLocation(); + public ParticleData(Material material, String name, ParticleRequirement requirement, ParticleElement particleElement) { + this.material = material; + this.name = name; + this.requirement = requirement; + this.particleElement = particleElement; + particleElement.aggregateAttributes(this); + } + + public ParticleData add(String attribute) { + attributes.add(attribute); + return this; + } + + public SWItem toSWItem(Player player, SteamwarUser user, Set eventTeilnahme, String eggHuntConfig) { + String translatedName; + try { + translatedName = LobbySystem.getMessage().parse(name, player); + } catch (Exception e) { + translatedName = name; } - return location; - } - public ParticleData copy() { - return new ParticleData(world, player, location, deg); + List lore = new ArrayList<>(); + lore.add(""); + if (!attributes.isEmpty()) { + lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player)); + attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); + lore.add(""); + } + + String unlockedBy = requirement.getRequirementName(player); + if (unlockedBy != null) { + lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); + lore.add(unlockedBy); + lore.add(""); + } + if (requirement.test(user, eventTeilnahme, eggHuntConfig)) { + lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); + } else { + lore.add(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player)); + } + return new SWItem(material, translatedName, lore, false, clickType -> {}); } } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleElement.java b/src/de/steamwar/lobby/particle/ParticleElement.java similarity index 96% rename from src/de/steamwar/lobby/otherparticle/ParticleElement.java rename to src/de/steamwar/lobby/particle/ParticleElement.java index 470f92d..3b14c14 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleElement.java +++ b/src/de/steamwar/lobby/particle/ParticleElement.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; import org.bukkit.Bukkit; import org.bukkit.Color; diff --git a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java b/src/de/steamwar/lobby/particle/ParticleEnum.java similarity index 62% rename from src/de/steamwar/lobby/otherparticle/ParticleEnum.java rename to src/de/steamwar/lobby/particle/ParticleEnum.java index ef4c4b5..6721442 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java +++ b/src/de/steamwar/lobby/particle/ParticleEnum.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; public interface ParticleEnum { ParticleData getParticle(); diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index cfc4d6c..945b13c 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -1,34 +1,19 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle; -import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.particle.particles.*; +import de.steamwar.lobby.particle.particles.custom.CustomEasterParticle; +import de.steamwar.lobby.particle.particles.custom.CustomPlayerParticle; +import de.steamwar.lobby.particle.particles.custom.CustomTeamParticle; +import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.TeamTeilnahme; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.UserConfig; +import lombok.experimental.UtilityClass; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -38,49 +23,56 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +@UtilityClass public class ParticleInventory { - private ParticleInventory() { + private final Class[] PARTICLES = { + PlayerParticle.class, + CustomPlayerParticle.class, + TeamParticle.class, + CustomTeamParticle.class, + ServerTeamParticle.class, + EventParticle.class, + EventParticlePlacement.class, + EventParticleParticipation.class, + EasterParticle.class, + CustomEasterParticle.class, + }; + + public String convertToString(ParticleEnum particleEnum) { + return particleEnum.getClass().getSimpleName() + "@" + ((Enum)particleEnum).name(); } - private static void calculateParticles(ParticleEnum[] particles, Player player, List> particleList) { - for (ParticleEnum particle : particles) { - particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle)); + public ParticleEnum convertFromString(String string) { + String[] split = string.split("@"); + Class clazz = null; + for (Class aClass : PARTICLES) { + if (aClass.getSimpleName().equals(split[0])) { + clazz = aClass; + break; + } } + if (clazz != null) { + try { + return (ParticleEnum) Enum.valueOf((Class) clazz, split[1]); + } catch (Exception e) { + return null; + } + } + // TODO: Add conversion from last version + return null; } - private static SWInventory createInventory(Player player) { + public void openInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - UserGroup userGroup = steamwarUser.getUserGroup(); + + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Set events = user.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(user.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); + String eggHuntConfig = UserConfig.getConfig(user.getId(), EggHunt.EGG_HUNT_CONFIG_KEY); List> particleList = new ArrayList<>(); - calculateParticles(PlayerParticle.particles, player, particleList); - if (steamwarUser.getTeam() != 0 || userGroup != UserGroup.Member) { - calculateParticles(TeamParticle.particles, player, particleList); - } - if (userGroup != UserGroup.Member) { - calculateParticles(ServerTeamParticle.particles, player, particleList); - } - - Set events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); - if (!events.isEmpty()) { - calculateParticles(EventParticle.particles, player, particleList); - } - for (EventParticlePlacement particle : EventParticlePlacement.particles) { - boolean clickable = userGroup.isTeamGroup(); - clickable |= (steamwarUser.getTeam() != 0 && contains(particle.getPlacementTeams(), steamwarUser.getTeam())); - addParticle(particleList, particle, clickable, player); - } - for (EventParticleParticipation particle : EventParticleParticipation.particles) { - boolean clickable = userGroup.isTeamGroup(); - clickable |= events.contains(particle.getEvent()); - addParticle(particleList, particle, clickable, player); - } - for (SpecialTeamParticle particle : SpecialTeamParticle.particles) { - if (particle.getTeamId() == 0 || steamwarUser.getTeam() == particle.getTeamId() || steamwarUser.getUserGroup() != UserGroup.Member) { - addParticle(particleList, particle, true, player); - } + for (Class clazz : PARTICLES) { + addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, user, events, eggHuntConfig); } SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { @@ -91,29 +83,18 @@ public class ParticleInventory { particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> { lobbyPlayer.setParticle(null); }); - - return particleSWListInv; + particleSWListInv.open(); } - private static void addParticle(List> particleList, ParticleEnum particle, boolean clickable, Player player) { - if (clickable) { - particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle)); - } else { - SWItem swItem = particle.getParticle().getItem().toSWItem(player); - swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName())); - particleList.add(new SWListInv.SWListEntry<>(swItem, null)); + private void addParticles(List> particleList, ParticleEnum[] particleEnums, Player player, SteamwarUser user, Set events, String eggHuntConfig) { + for (ParticleEnum particle : particleEnums) { + ParticleData particleData = particle.getParticle(); + SWItem swItem = particleData.toSWItem(player, user, events, eggHuntConfig); + if (particleData.getRequirement().test(user, events, eggHuntConfig)) { + particleList.add(new SWListInv.SWListEntry<>(swItem, particle)); + } else { + particleList.add(new SWListInv.SWListEntry<>(swItem, null)); + } } } - - private static boolean contains(int[] ints, int element) { - for (int i : ints) { - if (i == element) return true; - } - return false; - } - - public static void openParticleInventory(Player player) { - createInventory(player).open(); - } } - diff --git a/src/de/steamwar/lobby/particle/ParticleItem.java b/src/de/steamwar/lobby/particle/ParticleItem.java deleted file mode 100644 index 50744d9..0000000 --- a/src/de/steamwar/lobby/particle/ParticleItem.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle; - -import de.steamwar.inventory.SWItem; -import de.steamwar.lobby.LobbySystem; -import lombok.RequiredArgsConstructor; -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; - -@RequiredArgsConstructor -public class ParticleItem { - - protected final Material material; - protected final String name; - protected final Set attributes = new LinkedHashSet<>(); - protected String unlockedBy; - - public ParticleItem(Material material, String name, String unlockedBy) { - this.material = material; - this.name = name; - this.unlockedBy = unlockedBy; - } - - public ParticleItem addAttribute(String attribute) { - this.attributes.add(attribute); - return this; - } - - public SWItem toSWItem(Player player) { - String translatedName = LobbySystem.getMessage().parse(name, player); - List lore = new ArrayList<>(); - lore.add(""); - if (!attributes.isEmpty()) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player)); - attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); - lore.add(""); - } - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(LobbySystem.getMessage().parse(unlockedBy, player)); - lore.add(""); - } - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); - return new SWItem(material, translatedName, lore, false, clickType -> {}); - } -} diff --git a/src/de/steamwar/lobby/particle/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java index 5c9c8f5..8253353 100644 --- a/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -23,7 +23,6 @@ import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.PlayerSpawn; -import de.steamwar.lobby.particle.particles.ParticleEnum; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -49,9 +48,10 @@ public class ParticleListener extends BasicListener { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); ParticleEnum particle = lobbyPlayer.getParticle(); if (particle == null) return; - BaseParticle baseParticle = particle.getParticle(); - if (baseParticle.needsTick()) { - baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); + ParticleData particleData = particle.getParticle(); + ParticleElement particleElement = particleData.getParticleElement(); + if (particleElement.tickType() == ParticleTickType.ALWAYS) { + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); } }); }, 0, 1); @@ -65,7 +65,7 @@ public class ParticleListener extends BasicListener { if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return; event.setCancelled(true); - ParticleInventory.openParticleInventory(player); + ParticleInventory.openInventory(player); } @EventHandler @@ -77,9 +77,11 @@ public class ParticleListener extends BasicListener { ParticleEnum particle = lobbyPlayer.getParticle(); if (particle == null) return; - BaseParticle baseParticle = particle.getParticle(); - if (baseParticle.needsTick()) return; - baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); + ParticleData particleData = particle.getParticle(); + ParticleElement particleElement = particleData.getParticleElement(); + if (particleElement.tickType() == ParticleTickType.MOVE) { + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); + } } @EventHandler diff --git a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java b/src/de/steamwar/lobby/particle/ParticleRequirement.java similarity index 90% rename from src/de/steamwar/lobby/otherparticle/ParticleRequirement.java rename to src/de/steamwar/lobby/particle/ParticleRequirement.java index 71f404d..d228a81 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/particle/ParticleRequirement.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.special.easter.EggDifficulty; @@ -20,6 +20,18 @@ public interface ParticleRequirement { String getRequirementName(Player player); boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); + ParticleRequirement SERVER_TEAM = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player); + } + + @Override + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return false; + } + }; + ParticleRequirement NO_REQUIRMENT = new ParticleRequirement() { @Override public String getRequirementName(Player player) { @@ -41,7 +53,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return user.getTeam() != 0; } - }; + }.or(SERVER_TEAM); ParticleRequirement EVENT_PARTICIPATION = new ParticleRequirement() { @Override public String getRequirementName(Player player) { @@ -52,18 +64,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return !eventTeilname.isEmpty(); } - }; - ParticleRequirement SERVER_TEAM = new ParticleRequirement() { - @Override - public String getRequirementName(Player player) { - return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player); - } - - @Override - public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { - return false; - } - }; + }.or(SERVER_TEAM); ParticleRequirement EGG_HUNT_EASY = _easterEggHuntDifficulty(EggDifficulty.EASY); ParticleRequirement EGG_HUNT_MEDIUM = _easterEggHuntDifficulty(EggDifficulty.MEDIUM); ParticleRequirement EGG_HUNT_HARD = _easterEggHuntDifficulty(EggDifficulty.HARD); @@ -101,7 +102,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return user.getTeam() == teamId; } - }; + }.or(SERVER_TEAM); } static ParticleRequirement eventParticipation(int eventId) { @@ -116,7 +117,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return eventTeilname.contains(eventId); } - }; + }.or(SERVER_TEAM); } static ParticleRequirement eventPlacement(int eventId, int... placementTeams) { @@ -134,7 +135,7 @@ public interface ParticleRequirement { if (!eventTeilname.contains(eventId)) return false; return teams.contains(user.getTeam()); } - }; + }.or(SERVER_TEAM); } static ParticleRequirement _easterEggHuntDifficulty(EggDifficulty difficulty) { @@ -178,10 +179,20 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return user.getId() == userId; } - }; + }.or(SERVER_TEAM); } - interface ParticleRequirementPredicate { - boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); + default ParticleRequirement or(ParticleRequirement particleRequirement) { + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return ParticleRequirement.this.getRequirementName(player); + } + + @Override + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return ParticleRequirement.this.test(user, eventTeilname, eggHuntConfig) || particleRequirement.test(user, eventTeilname, eggHuntConfig); + } + }; } } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleTickData.java b/src/de/steamwar/lobby/particle/ParticleTickData.java similarity index 95% rename from src/de/steamwar/lobby/otherparticle/ParticleTickData.java rename to src/de/steamwar/lobby/particle/ParticleTickData.java index b2aa909..ef55973 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleTickData.java +++ b/src/de/steamwar/lobby/particle/ParticleTickData.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/otherparticle/ParticleTickType.java b/src/de/steamwar/lobby/particle/ParticleTickType.java similarity index 54% rename from src/de/steamwar/lobby/otherparticle/ParticleTickType.java rename to src/de/steamwar/lobby/particle/ParticleTickType.java index ac54999..adc25e4 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleTickType.java +++ b/src/de/steamwar/lobby/particle/ParticleTickType.java @@ -1,9 +1,8 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; public enum ParticleTickType { ALWAYS, MOVE, - SNEAK, ; } diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java deleted file mode 100644 index 0f42271..0000000 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Particle; - -public class SimpleParticle implements BaseParticle { - - private final ParticleItem particleItem; - private final Particle particle; - private boolean customVelocity = false; - private float vx; - private float vy; - private float vz; - private double time = 1; - private int count = 5; - - public SimpleParticle(ParticleItem particleItem, Particle particle) { - this.particleItem = particleItem; - this.particle = particle; - } - - public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) { - this.particleItem = particleItem; - this.particle = particle; - this.customVelocity = true; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - } - - public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time, int count) { - this.particleItem = particleItem; - this.particle = particle; - this.customVelocity = true; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - this.count = count; - } - - @Override - public ParticleItem getItem() { - return particleItem; - } - - @Override - public void particle(ParticleData particleData) { - Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - Bukkit.getOnlinePlayers().forEach(player -> { - int viewDistance = player.getClientViewDistance() * 16; - if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) { - if (customVelocity) { - player.spawnParticle(particle, location, count, vx, vy, vz, time); - } else { - player.spawnParticle(particle, location, count); - } - } - }); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/WingDesign.java b/src/de/steamwar/lobby/particle/WingDesign.java similarity index 90% rename from src/de/steamwar/lobby/otherparticle/WingDesign.java rename to src/de/steamwar/lobby/particle/WingDesign.java index c1687ed..dccb208 100644 --- a/src/de/steamwar/lobby/otherparticle/WingDesign.java +++ b/src/de/steamwar/lobby/particle/WingDesign.java @@ -1,6 +1,5 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; -import de.steamwar.lobby.particle.decorator.WingParticle; import lombok.SneakyThrows; import org.bukkit.util.Vector; @@ -15,7 +14,7 @@ public interface WingDesign { @SneakyThrows static Vector[] create(String resource) { List vectors = new ArrayList<>(); - BufferedImage bufferedImage = ImageIO.read(WingParticle.class.getResourceAsStream(resource)); + BufferedImage bufferedImage = ImageIO.read(WingDesign.class.getResourceAsStream(resource)); for (int x = 0; x < bufferedImage.getWidth(); x++) { for (int y = 0; y < bufferedImage.getHeight(); y++) { int rgb = bufferedImage.getRGB(x, y); diff --git a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java deleted file mode 100644 index f46a09c..0000000 --- a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import org.bukkit.Location; -import org.bukkit.util.Vector; - -public class CircleParticle implements BaseParticle { - - private ParticleItem particleItem = null; - private BaseParticle particle; - private BaseParticle particle2; - - public CircleParticle(BaseParticle particle) { - this.particle = particle; - } - - public CircleParticle(ParticleItem particleItem, BaseParticle particle, BaseParticle particle2) { - this.particleItem = particleItem; - this.particle = particle; - this.particle2 = particle2; - } - - @Override - public ParticleItem getItem() { - if (particleItem != null) { - return particleItem.addAttribute("PARTICLE_ATTRIBUTE_BI_CIRCLE"); - } - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_CIRCLE"); - } - - @Override - public boolean needsTick() { - return particle.needsTick() || (particle2 != null && particle2.needsTick()); - } - - @Override - public void particle(ParticleData particleData) { - Location location = particleData.getLocation(); - - Vector vector = new Vector(1, 0, 0); - vector.rotateAroundY(particleData.getDeg()); - ParticleData nData = particleData.withLocation(location.clone().add(vector)); - particle.particle(nData); - - if (particle2 == null) { - return; - } - vector.setX(-vector.getX()); - vector.setZ(-vector.getZ()); - - nData = particleData.withLocation(location.clone().add(vector)); - particle2.particle(nData); - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java deleted file mode 100644 index 773f741..0000000 --- a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import lombok.NonNull; -import org.bukkit.Material; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class CloudParticle implements BaseParticle { - - private BaseParticle particle; - - public CloudParticle(@NonNull BaseParticle particle) { - this.particle = particle; - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_CLOUD"); - } - - @Override - public boolean needsTick() { - return particle.needsTick(); - } - - @Override - public void particle(ParticleData particleData) { - if (particleData.getWorld().getBlockAt(particleData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType() == Material.AIR) { - particleData.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); - } else { - particleData.getPlayer().removePotionEffect(PotionEffectType.SLOW_FALLING); - return; - } - ParticleData nData = particleData.withLocation(particleData.getLocation().subtract(0, -0.2, 0)); - particle.particle(nData); - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java b/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java deleted file mode 100644 index f0a090a..0000000 --- a/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import org.bukkit.Material; - -public class NonFloorParticle implements BaseParticle { - - private BaseParticle particle; - - public NonFloorParticle(BaseParticle particle) { - this.particle = particle; - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_NON_FLOOR"); - } - - @Override - public void particle(ParticleData particleData) { - if (particleData.getWorld().getBlockAt(particleData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType() == Material.AIR) { - particle.particle(particleData); - } - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/TickParticle.java b/src/de/steamwar/lobby/particle/decorator/TickParticle.java deleted file mode 100644 index 1eee74e..0000000 --- a/src/de/steamwar/lobby/particle/decorator/TickParticle.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import lombok.NonNull; - -public class TickParticle implements BaseParticle { - - private BaseParticle particle; - - public TickParticle(@NonNull BaseParticle particle) { - this.particle = particle; - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_TICK"); - } - - @Override - public boolean needsTick() { - return true; - } - - @Override - public void particle(ParticleData particleData) { - particle.particle(particleData); - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/WingParticle.java b/src/de/steamwar/lobby/particle/decorator/WingParticle.java deleted file mode 100644 index e12ed44..0000000 --- a/src/de/steamwar/lobby/particle/decorator/WingParticle.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.decorator; - -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import lombok.SneakyThrows; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.util.Vector; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WingParticle implements BaseParticle, Listener { - - private Map playerMap = new HashMap<>(); - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - playerMap.remove(event.getPlayer()); - } - - public enum WingDesign { - SIMPLE("WingSimple4.png"), - COMPLEX("WingSimple2.png"), - SWORD("WingSword.png"), - SW("WingSW.png"), - WGS("WingWGS.png"), - SWORD_CROSSED("WingSwordCrossed.png"), - MWGL("MWGL.png"), - ECLIPSE("ECLIPSE-Logo.png"), - ; - - private List vectors = new ArrayList<>(); - - @SneakyThrows - WingDesign(String wingResource) { - BufferedImage bufferedImage = ImageIO.read(WingParticle.class.getResourceAsStream(wingResource)); - for (int x = 0; x < bufferedImage.getWidth(); x++) { - for (int y = 0; y < bufferedImage.getHeight(); y++) { - int rgb = bufferedImage.getRGB(x, y); - if (Color.WHITE.getRGB() != rgb) { - vectors.add(new Vector(x - bufferedImage.getWidth() / 2.0, bufferedImage.getHeight() - y - 1.0, 0)); - } - } - } - } - } - - private BaseParticle particle; - private double size; - private WingDesign wingDesign; - - public WingParticle(BaseParticle particle, double size, WingDesign wingDesign) { - this.particle = particle; - this.size = size; - this.wingDesign = wingDesign; - - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_WING"); - } - - @Override - public void particle(ParticleData particleData) { - int currentNumber = playerMap.getOrDefault(particleData.getPlayer(), 0) % 20; - playerMap.put(particleData.getPlayer(), currentNumber + 1); - if (currentNumber != 0) { - return; - } - if (particleData.getPlayer().isGliding()) { - return; - } - wingDesign.vectors.forEach(dVector -> { - Vector vector = new Vector(dVector.getX() * size, 0.6 + dVector.getY() * size - (particleData.getPlayer().isSneaking() ? 0.5 : 0) , 0.5); - vector.rotateAroundY(Math.toRadians(particleData.getPlayer().getLocation().getYaw() * -1)); - vector.setX(-vector.getX()); - vector.setZ(-vector.getZ()); - Location location = particleData.getPlayer().getLocation().clone().add(vector); - ParticleData current = particleData.withLocation(location); - particle.particle(current); - }); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Always.java b/src/de/steamwar/lobby/particle/elements/Always.java similarity index 68% rename from src/de/steamwar/lobby/otherparticle/elements/Always.java rename to src/de/steamwar/lobby/particle/elements/Always.java index f35738d..0eeb41e 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Always.java +++ b/src/de/steamwar/lobby/particle/elements/Always.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleTickType; public class Always extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/Circle.java b/src/de/steamwar/lobby/particle/elements/Circle.java similarity index 81% rename from src/de/steamwar/lobby/otherparticle/elements/Circle.java rename to src/de/steamwar/lobby/particle/elements/Circle.java index fd1f864..a086e4a 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Circle.java +++ b/src/de/steamwar/lobby/particle/elements/Circle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import org.bukkit.util.Vector; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Cloud.java b/src/de/steamwar/lobby/particle/elements/Cloud.java similarity index 86% rename from src/de/steamwar/lobby/otherparticle/elements/Cloud.java rename to src/de/steamwar/lobby/particle/elements/Cloud.java index 3ad3834..f7b91e7 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Cloud.java +++ b/src/de/steamwar/lobby/particle/elements/Cloud.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Material; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Delayed.java b/src/de/steamwar/lobby/particle/elements/Delayed.java similarity index 89% rename from src/de/steamwar/lobby/otherparticle/elements/Delayed.java rename to src/de/steamwar/lobby/particle/elements/Delayed.java index 472f339..f13d9b5 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Delayed.java +++ b/src/de/steamwar/lobby/particle/elements/Delayed.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java b/src/de/steamwar/lobby/particle/elements/DelegatingParticleElement.java similarity index 75% rename from src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java rename to src/de/steamwar/lobby/particle/elements/DelegatingParticleElement.java index e961f29..55d6e10 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java +++ b/src/de/steamwar/lobby/particle/elements/DelegatingParticleElement.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickType; public abstract class DelegatingParticleElement implements ParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java b/src/de/steamwar/lobby/particle/elements/DoubleCircle.java similarity index 85% rename from src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java rename to src/de/steamwar/lobby/particle/elements/DoubleCircle.java index dbb838e..926f5f2 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java +++ b/src/de/steamwar/lobby/particle/elements/DoubleCircle.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleTickType; import org.bukkit.Location; import org.bukkit.util.Vector; diff --git a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java b/src/de/steamwar/lobby/particle/elements/DustParticle.java similarity index 87% rename from src/de/steamwar/lobby/otherparticle/elements/DustParticle.java rename to src/de/steamwar/lobby/particle/elements/DustParticle.java index 96b37c1..24ef229 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java +++ b/src/de/steamwar/lobby/particle/elements/DustParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import org.bukkit.Particle; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Group.java b/src/de/steamwar/lobby/particle/elements/Group.java similarity index 77% rename from src/de/steamwar/lobby/otherparticle/elements/Group.java rename to src/de/steamwar/lobby/particle/elements/Group.java index 8f0e9a7..b6fc771 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Group.java +++ b/src/de/steamwar/lobby/particle/elements/Group.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class Group extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java b/src/de/steamwar/lobby/particle/elements/LocationMutator.java similarity index 83% rename from src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java rename to src/de/steamwar/lobby/particle/elements/LocationMutator.java index 2de8f8a..41fd342 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java +++ b/src/de/steamwar/lobby/particle/elements/LocationMutator.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import java.util.function.UnaryOperator; diff --git a/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java b/src/de/steamwar/lobby/particle/elements/NonFloor.java similarity index 76% rename from src/de/steamwar/lobby/otherparticle/elements/NonFloor.java rename to src/de/steamwar/lobby/particle/elements/NonFloor.java index f99dc71..ebc01eb 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java +++ b/src/de/steamwar/lobby/particle/elements/NonFloor.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class NonFloor extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java b/src/de/steamwar/lobby/particle/elements/NonFlying.java similarity index 73% rename from src/de/steamwar/lobby/otherparticle/elements/NonFlying.java rename to src/de/steamwar/lobby/particle/elements/NonFlying.java index 85d7037..2f74f9b 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java +++ b/src/de/steamwar/lobby/particle/elements/NonFlying.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class NonFlying extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java b/src/de/steamwar/lobby/particle/elements/SimpleParticle.java similarity index 91% rename from src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java rename to src/de/steamwar/lobby/particle/elements/SimpleParticle.java index d8e1204..fc678b0 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/elements/SimpleParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import org.bukkit.Particle; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java b/src/de/steamwar/lobby/particle/elements/Sneaking.java similarity index 59% rename from src/de/steamwar/lobby/otherparticle/elements/Sneaking.java rename to src/de/steamwar/lobby/particle/elements/Sneaking.java index a087ba5..42bb16c 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java +++ b/src/de/steamwar/lobby/particle/elements/Sneaking.java @@ -1,8 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class Sneaking extends DelegatingParticleElement { @@ -10,11 +9,6 @@ public class Sneaking extends DelegatingParticleElement { super(particleElement); } - @Override - public ParticleTickType tickType() { - return ParticleTickType.SNEAK; - } - @Override public String attribute() { return null; // TODO: Implement this attribute diff --git a/src/de/steamwar/lobby/otherparticle/elements/Wing.java b/src/de/steamwar/lobby/particle/elements/Wing.java similarity index 84% rename from src/de/steamwar/lobby/otherparticle/elements/Wing.java rename to src/de/steamwar/lobby/particle/elements/Wing.java index 46b91d0..f0f8203 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Wing.java +++ b/src/de/steamwar/lobby/particle/elements/Wing.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.WingDesign; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.WingDesign; import org.bukkit.Location; import org.bukkit.util.Vector; diff --git a/src/de/steamwar/lobby/particle/group/ParticleGroup.java b/src/de/steamwar/lobby/particle/group/ParticleGroup.java deleted file mode 100644 index 1d837c4..0000000 --- a/src/de/steamwar/lobby/particle/group/ParticleGroup.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.group; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; - -public class ParticleGroup implements BaseParticle { - - private ParticleItem particleItem; - private BaseParticle[] particles; - - public ParticleGroup(ParticleItem particleItem, BaseParticle... particles) { - this.particleItem = particleItem; - this.particles = particles; - } - - @Override - public ParticleItem getItem() { - return particleItem; - } - - @Override - public void particle(ParticleData particleData) { - for (BaseParticle particle : particles) { - particle.particle(particleData.copy()); - } - } -} diff --git a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java deleted file mode 100644 index 602fd85..0000000 --- a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.mutator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import org.bukkit.Location; - -import java.util.function.UnaryOperator; - -public class LocationParticleMutator implements BaseParticle { - - private BaseParticle particle; - private UnaryOperator mutator; - - public LocationParticleMutator(BaseParticle particle, UnaryOperator mutator) { - this.particle = particle; - this.mutator = mutator; - } - - @Override - public ParticleItem getItem() { - return particle.getItem(); - } - - @Override - public boolean needsTick() { - return particle.needsTick(); - } - - @Override - public void particle(ParticleData particleData) { - ParticleData nData = particleData.withLocation(mutator.apply(particleData.getLocation())); - particle.particle(nData); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java b/src/de/steamwar/lobby/particle/particles/EasterParticle.java similarity index 79% rename from src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java rename to src/de/steamwar/lobby/particle/particles/EasterParticle.java index 6ea1ca4..8980995 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/EasterParticle.java @@ -1,11 +1,11 @@ -package de.steamwar.lobby.otherparticle.particles; +package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.elements.Always; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; +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 lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; diff --git a/src/de/steamwar/lobby/particle/particles/EventParticle.java b/src/de/steamwar/lobby/particle/particles/EventParticle.java index 016ac02..a1d097f 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticle.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticle.java @@ -1,46 +1,29 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.NonFloorParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +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.Circle; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum EventParticle implements ParticleEnum { - WATER(new TickParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(WATER_BUCKET, "PARTICLE_WATER", "PARTICLE_UNLOCKED_BY_EVENT"), Particle.DRIP_WATER), location -> location.add(0, 1.1, 0))))), - LAVA(new TickParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(LAVA_BUCKET, "PARTICLE_FIRE", "PARTICLE_UNLOCKED_BY_EVENT"), Particle.DRIP_LAVA), location -> location.add(0, 1.1, 0))))), + WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", ParticleRequirement.EVENT_PARTICIPATION, + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_WATER), 0, 1.1, 0)))) + ), + LAVA(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", ParticleRequirement.EVENT_PARTICIPATION, + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA), 0, 1.1, 0)))) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java index 83689ac..a128623 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java @@ -1,56 +1,45 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.EventParticleItem; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import de.steamwar.lobby.particle.group.ParticleGroup; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor -@Getter public enum EventParticleParticipation implements ParticleEnum { - WarGearSeason(22, new SimpleParticle(EventParticleItem.participation(BOOK, "PARTICLE_EVENT_ENCHANTING", 22), Particle.ENCHANTMENT_TABLE)), - AirshipEvent(26, new SimpleParticle(EventParticleItem.participation(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", 26), Particle.CLOUD)), - HellsBellsWs(28, new CircleParticle(new SimpleParticle(EventParticleItem.participation(TNT, "PARTICLE_EVENT_SMOKE", 28), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))), - Underwater(31, new SimpleParticle(EventParticleItem.participation(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", 31), Particle.DRIP_WATER)), - AdventWarShip(32, new ParticleGroup(EventParticleItem.participation(PRISMARINE_WALL, "PARTICLE_EVENT_WATER", 32), new SimpleParticle(null, Particle.DRIP_WATER), new SimpleParticle(null, Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), - MiniWarGearLiga(33, new CircleParticle(new SimpleParticle(EventParticleItem.participation(PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", 33), Particle.WATER_WAKE, 0, 0, 0, 0))), - // Absturz(34, null), - UnderwaterMWG(35, new TickParticle(new LocationParticleMutator(new ParticleGroup(EventParticleItem.participation(BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", 35), new SimpleParticle(null, Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(null, Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationParticleMutator(new SimpleParticle(null, Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), location -> location.subtract(0, 0.2, 0))), location -> location.add(0, 2.2, 0)))), - WarGearSeason2022(37, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.participation(DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", 37), Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.COMPLEX))), - // WargearClash(38, null), + WarGearSeason(new ParticleData(Material.BOOK, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventParticipation(22), + new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + ), + AirshipEvent(new ParticleData(Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventParticipation(26), + new SimpleParticle(Particle.CLOUD)) + ), + HellsBellsWs(new ParticleData(Material.TNT, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventParticipation(28), + new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))) + ), + Underwater(new ParticleData(Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(31), + new SimpleParticle(Particle.DRIP_WATER)) + ), + AdventWarShip(new ParticleData(Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(32), + new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))) + ), + MiniWarGearLiga(new ParticleData(Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(33), + new Circle(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0))) + ), + UnderwaterMWG(new ParticleData(Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventParticipation(35), + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, 0.2, 0)), 0, 2.2, 0))) + ), + WarGearSeason2022(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventParticipation(37), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingDesign.COMPLEX)), 20))) + ), ; - public static EventParticleParticipation[] particles = values(); + public static ParticleEnum[] particles = values(); - private int event; - private BaseParticle particle; + @Getter + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java index 187572f..e050730 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java @@ -1,57 +1,51 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.EventParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.CloudParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import de.steamwar.lobby.particle.group.ParticleGroup; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor -@Getter public enum EventParticlePlacement implements ParticleEnum { - WarGearSeason(22, new int[]{12, 285, 54}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(EventParticleItem.placement(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", 22), Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), location -> location.add(0, 1.1, 0))))), - AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(new LocationParticleMutator(new SimpleParticle(EventParticleItem.placement(SNOWBALL, "PARTICLE_EVENT_CLOUD", 26), Particle.CLOUD, 0, 0, 0, 0.01), location -> location.add(0, 2.2, 0)))), - HellsBellsWs(28, new int[]{205, 9, 11}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(EventParticleItem.placement(TNT_MINECART, "PARTICLE_EVENT_SMOKE", 28), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), location -> location.add(0, 2.2, 0))))), - Underwater(31, new int[]{9, 210, 520}, new CloudParticle(new SimpleParticle(EventParticleItem.placement(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", 31), Particle.DRIP_WATER))), - AdventWarShip(32, new int[]{9, 205, 210}, new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleGroup(EventParticleItem.placement(PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", 32), new SimpleParticle(null, Particle.DRIP_WATER), new SimpleParticle(null, Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), location -> location.add(0, 1.1, 0)))), - MiniWarGearLiga(33, new int[]{9, 34, 205}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(IRON_SWORD, "PARTICLE_EVENT_WINGS", 33), Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.MWGL))), - Absturz(34, new int[]{210, 205, 527, 286}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(FEATHER, "PARTICLE_EVENT_WINGS", 34), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SIMPLE))), - UnderwaterMWG(35, new int[]{9, 210}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", 35), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SW))), - WarGearSeason2022(37, new int[]{285, 210, 122}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(DIAMOND_HELMET, "PARTICLE_EVENT_WGS", 37), Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.WGS))), - WargearClash(38, new int[]{210, 158, 167, 286}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", 38), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingParticle.WingDesign.SWORD_CROSSED))), + WarGearSeason(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventPlacement(22, 12, 285, 54), + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 0, 1.1, 0))) + )), + AirshipEvent(new ParticleData(Material.SNOWBALL, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), + new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)) + )), + HellsBellsWs(new ParticleData(Material.TNT_MINECART, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventPlacement(28, 205, 9, 11), + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))) + )), + Underwater(new ParticleData(Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 210, 520), + new Cloud(new SimpleParticle(Particle.DRIP_WATER))) + ), + AdventWarShip(new ParticleData(Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 205, 210), + new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) + ), + MiniWarGearLiga(new ParticleData(Material.IRON_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(33, 9, 34, 205), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) + ), + Absturz(new ParticleData(Material.FEATHER, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(34, 210, 205, 527, 286), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + ), + UnderwaterMWG(new ParticleData(Material.CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventPlacement(35, 9, 210), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) + ), + WarGearSeason2022(new ParticleData(Material.DIAMOND_HELMET, "PARTICLE_EVENT_WGS", ParticleRequirement.eventPlacement(37, 285, 210, 122), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) + ), + WargearClash(new ParticleData(Material.GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) + ), ; - public static EventParticlePlacement[] particles = values(); + public static ParticleEnum[] particles = values(); - private int event; - private int[] placementTeams; - private BaseParticle particle; + @Getter + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/ParticleEnum.java b/src/de/steamwar/lobby/particle/particles/ParticleEnum.java deleted file mode 100644 index db97369..0000000 --- a/src/de/steamwar/lobby/particle/particles/ParticleEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.particles; - -import de.steamwar.lobby.particle.BaseParticle; - -public interface ParticleEnum { - BaseParticle getParticle(); -} diff --git a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java index 9bbbe1f..ed66d8c 100644 --- a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java @@ -1,56 +1,63 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.DustSimpleParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.elements.DustParticle; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum PlayerParticle implements ParticleEnum { - SNEEZE(new SimpleParticle(new ParticleItem(SLIME_BLOCK, "PARTICLE_SNEEZE"), Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)), - SMOKE(new SimpleParticle(new ParticleItem(COBWEB, "PARTICLE_SMOKE"), Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)), - FIRE(new SimpleParticle(new ParticleItem(LAVA_BUCKET, "PARTICLE_FIRE"), Particle.DRIP_LAVA)), - WATER(new SimpleParticle(new ParticleItem(WATER_BUCKET, "PARTICLE_WATER"), Particle.DRIP_WATER)), - HEART(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_DYE, "PARTICLE_HEART"), Particle.HEART), location -> location.add(0, 2.2, 0))), - NOTES(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES"), Particle.NOTE), location -> location.add(0, 2.2, 0))), - NAUTILUS(new SimpleParticle(new ParticleItem(NAUTILUS_SHELL, "PARTICLE_NAUTILUS"), Particle.NAUTILUS, 0.2F, 0.2F, 0.2F, 0.01)), - SNOWBALL(new SimpleParticle(new ParticleItem(Material.SNOWBALL, "PARTICLE_SNOWBALL"), Particle.SNOWBALL, 0.2F, 0.2F, 0.2F, 0.01)), - EFFECT(new DustSimpleParticle(new ParticleItem(GLASS_BOTTLE, "PARTICLE_EFFECT"), Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)), - CAMPFIRE(new SimpleParticle(new ParticleItem(Material.CAMPFIRE, "PARTICLE_CAMPFIRE"), Particle.CAMPFIRE_COSY_SMOKE, 0F, 0.2F, 0F, 0.01)), - MAGIC(new SimpleParticle(new ParticleItem(CAULDRON, "PARTICLE_MAGIC"), Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)), - ANGRY(new SimpleParticle(new ParticleItem(REDSTONE_BLOCK, "PARTICLE_ANGRY"), Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)), - SLIME(new SimpleParticle(new ParticleItem(SLIME_BALL, "PARTICLE_SLIME"), Particle.SLIME)), - MOB(new SimpleParticle(new ParticleItem(ZOMBIE_HEAD, "PARTICLE_MOB"), Particle.SPELL_MOB)), + SNEEZE(new ParticleData(Material.SLIME_BLOCK, "PARTICLE_SNEEZE", + new SimpleParticle(Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)) + ), + SMOKE(new ParticleData(Material.COBWEB, "PARTICLE_SMOKE", + new SimpleParticle(Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)) + ), + FIRE(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", + new SimpleParticle(Particle.DRIP_LAVA)) + ), + WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", + new SimpleParticle(Particle.DRIP_WATER)) + ), + HEARTH(new ParticleData(Material.RED_DYE, "PARTICLE_HEART", + new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0)) + ), + NOTES(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", + new LocationMutator(new SimpleParticle(Particle.NOTE), 0, 2.2, 0)) + ), + NAUTILUS(new ParticleData(Material.NAUTILUS_SHELL, "PARTICLE_NAUTILUS", + new SimpleParticle(Particle.NAUTILUS, 0.2F, 0.2F ,0.2F, 0.01)) + ), + SNOWBALL(new ParticleData(Material.SNOWBALL, "PARTICLE_SNOWBALL", + 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)) + ), + CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", + new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) + ), + MAGIC(new ParticleData(Material.CAULDRON, "PARTICLE_MAGIC", + new SimpleParticle(Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)) + ), + ANGRY(new ParticleData(Material.REDSTONE_BLOCK, "PARTICLE_ANGRY", + new SimpleParticle(Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)) + ), + SLIME(new ParticleData(Material.SLIME_BALL, "PARTICLE_SLIME", + new SimpleParticle(Particle.SLIME)) + ), + MOB(new ParticleData(Material.ZOMBIE_HEAD, "PARTICLE_MOB", + new SimpleParticle(Particle.SPELL_MOB)) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index fc9d000..0a7bc9d 100644 --- a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -1,71 +1,99 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.CloudParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum ServerTeamParticle implements ParticleEnum { - WITCH(new SimpleParticle(new ParticleItem(EXPERIENCE_BOTTLE, "PARTICLE_WITCH", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SPELL_WITCH)), - ENCHANTING(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE)), - HAPPY(new SimpleParticle(new ParticleItem(EMERALD_BLOCK, "PARTICLE_HAPPY", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)), - FLAME(new SimpleParticle(new ParticleItem(FLINT_AND_STEEL, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0F, 0.2F, 0F, 0.01)), - END_ROD(new SimpleParticle(new ParticleItem(Material.END_ROD, "PARTICLE_END_ROD", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)), - CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_WOOL, "PARTICLE_CLOUD", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CLOUD))), - TOTEM(new CloudParticle(new SimpleParticle(new ParticleItem(TOTEM_OF_UNDYING, "PARTICLE_TOTEM", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))), - ENCHANTING_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE))), - FLAME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIRE_CORAL_BLOCK, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME))), - SNEEZE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(LIME_SHULKER_BOX, "PARTICLE_SNEEZE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SNEEZE))), - SLIME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(GREEN_SHULKER_BOX, "PARTICLE_SLIME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SLIME))), - SMOKE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))), - TOWN_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIREWORK_STAR, "PARTICLE_TOWN", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.TOWN_AURA))), - FLAME_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(MAGMA_BLOCK, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0F, 0F, 0F, 0.01), location -> location.add(0, 1.1, 0)))), - ENCHANTING_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), location -> location.add(0, 1.1, 0)))), - NOTES_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.NOTE, 0F, 0F, 0F, 0.01), location -> location.add(0, 2.2, 0)))), - WATER_FIRE(new LocationParticleMutator(new CircleParticle(new ParticleItem(GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.DRIP_WATER, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.DRIP_LAVA, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0))), - WATER_FIRE_ALWAYS(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(MAGMA_CUBE_SPAWN_EGG, "PARTICLE_WATER_FIRE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null,Particle.DRIP_WATER, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null,Particle.DRIP_LAVA, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0)))), - MAGIC_ENCHANTING(new LocationParticleMutator(new CircleParticle(new ParticleItem(DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0))), - MAGIC_ENCHANTING_ALWAYS(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0)))), - MAGIC_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(GLOWSTONE_DUST, "PARTICLE_MAGIC", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - FLAME_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(FIRE_CORAL, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - FIREWORK_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(FIREWORK_ROCKET, "PARTICLE_FIREWORK", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FIREWORKS_SPARK, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - WATER_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(CYAN_DYE, "PARTICLE_WATER", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.WATER_WAKE, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - ENCHANTING_DOUBLE_CIRCLE(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 2.2, 0)))), - EVIL_WINGS(new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(PURPUR_SLAB, "PARTICLE_WINGS_EVIL", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SIMPLE))), + WITCH(new ParticleData(Material.EXPERIENCE_BOTTLE, "PARTICLE_WITCH", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.SPELL_WITCH)) + ), + ENCHANTING(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + ), + HAPPY(new ParticleData(Material.EMERALD_BLOCK, "PARTICLE_HAPPY", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.HEART, 0.2F, 0.2F, 0.2F, 0.01)) + ), + FLAME(new ParticleData(Material.FLINT_AND_STEEL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.FLAME, 0, 0.2F, 0, 0.01)) + ), + END_ROD(new ParticleData(Material.END_ROD, "PARTICLE_END_ROD", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)) + ), + CLOUD(new ParticleData(Material.WHITE_WOOL, "PARTICLE_CLOUD", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.CLOUD))) + ), + TOTEM(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_TOTEM", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))) + ), + ENCHANTING_CLOUD(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.ENCHANTMENT_TABLE))) + ), + FLAME_CLOUD(new ParticleData(Material.FIRE_CORAL_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.FLAME))) + ), + SNEEZE_CLOUD(new ParticleData(Material.LIME_SHULKER_BOX, "PARTICLE_SNEEZE", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.SNEEZE))) + ), + SLIME_CLOUD(new ParticleData(Material.GREEN_SHULKER_BOX, "PARTICLE_SLIME", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.SLIME))) + ), + SMOKE_CLOUD(new ParticleData(Material.DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))) + ), + TOWN_CLOUD(new ParticleData(Material.FIREWORK_STAR, "PARTICLE_TOWN", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.TOWN_AURA))) + ), + FLAME_CIRCLE(new ParticleData(Material.MAGMA_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0))) + ), + ENCHANTING_CIRCLE(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) + ), + NOTES_CIRCLE(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.NOTE, 0, 0, 0, 0.01), 0, 2.2, 0))) + ), + WATER_FIRE(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) + ), + WATER_FIRE_ALWAYS(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) + ), + MAGIC_ENCHANTING(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0)) + ), + MAGIC_ENCHANTING_ALWAYS(new ParticleData(Material.WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0))) + ), + MAGIC_CLOUD_CIRCLE(new ParticleData(Material.GLOWSTONE_DUST, "PARTICLE_MAGIC", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + FLAME_CLOUD_CIRCLE(new ParticleData(Material.FIRE_CORAL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + FIREWORK_CLOUD_CIRCLE(new ParticleData(Material.FIREWORK_ROCKET, "PARTICLE_FIREWORK", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + WATER_CLOUD_CIRCLE(new ParticleData(Material.CYAN_DYE, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + ENCHANTING_DOUBLE_CIRCLE(new ParticleData(Material.BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 2.2, 0))) + ), + EVIL_WINGS(new ParticleData(Material.PURPUR_SLAB, "PARTICLE_WINGS_EVIL", ParticleRequirement.SERVER_TEAM, + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java b/src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java deleted file mode 100644 index dc7566e..0000000 --- a/src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.lobby.particle.particles; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Particle; - -import static org.bukkit.Material.ENDER_CHEST; - -@Getter -@AllArgsConstructor -public enum SpecialTeamParticle implements ParticleEnum { - - Eclipse(34, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(ENDER_CHEST, "PARTICLE_EVENT_ENCHANTING"), Particle.PORTAL, 0.0F, 0.0F, 0.0F, 0.01), 0.15, WingParticle.WingDesign.ECLIPSE))), - ; - public static SpecialTeamParticle[] particles = values(); - - private int teamId; - private BaseParticle particle; -} diff --git a/src/de/steamwar/lobby/particle/particles/TeamParticle.java b/src/de/steamwar/lobby/particle/particles/TeamParticle.java index 9efc748..ce20b77 100644 --- a/src/de/steamwar/lobby/particle/particles/TeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/TeamParticle.java @@ -1,52 +1,50 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.NonFloorParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.elements.Circle; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.NonFloor; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum TeamParticle implements ParticleEnum { - SQUID(new SimpleParticle(new ParticleItem(INK_SAC, "PARTICLE_SQUID", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)), - BUBBLE(new SimpleParticle(new ParticleItem(TUBE_CORAL, "PARTICLE_BUBBLE", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)), - HONEY(new SimpleParticle(new ParticleItem(HONEY_BOTTLE, "PARTICLE_HONEY", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)), - NECTAR(new SimpleParticle(new ParticleItem(HONEYCOMB, "PARTICLE_NECTAR", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)), - FIREWORK(new LocationParticleMutator(new NonFloorParticle(new SimpleParticle(new ParticleItem(FIRE_CHARGE, "PARTICLE_FIREWORK", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), location -> location.subtract(0, -0.2, 0))), - DRAGON_BREATH(new SimpleParticle(new ParticleItem(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)), - DAMAGE(new SimpleParticle(new ParticleItem(SPIDER_EYE, "PARTICLE_DAMAGE", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)), - DOLPHIN(new SimpleParticle(new ParticleItem(BLUE_DYE, "PARTICLE_DOLPHIN", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)), - HEART(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_CONCRETE, "PARTICLE_HEART", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.HEART), location -> location.add(0, 2.2, 0)))), + SQUID(new ParticleData(Material.INK_SAC, "PARTICLE_SQUID", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)) + ), + BUBBLE(new ParticleData(Material.TUBE_CORAL, "PARTICLE_BUBBLE", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)) + ), + HONEY(new ParticleData(Material.HONEY_BOTTLE, "PARTICLE_HONEY", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)) + ), + NECTAR(new ParticleData(Material.HONEYCOMB, "PARTICLE_NECTAR", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)) + ), + FIREWORK(new ParticleData(Material.FIRE_CHARGE, "PARTICLE_FIREWORK", ParticleRequirement.HAS_TEAM, + new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) + ), + DRAGON_BREATH(new ParticleData(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)) + ), + DAMAGE(new ParticleData(Material.SPIDER_EYE, "PARTICLE_DAMAGE", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DAMAGE_INDICATOR, 0.2F, 0, 0.2F, 0.01)) + ), + DOLPHIN(new ParticleData(Material.BLUE_DYE, "PARTICLE_DOLPHIN", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DOLPHIN, 0.2F, 0, 0.2F, 0.01)) + ), + HEART(new ParticleData(Material.RED_CONCRETE, "PARTICLE_HEART", ParticleRequirement.HAS_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0))) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java similarity index 60% rename from src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java rename to src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java index 274b7db..456d609 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.particles.custom; +package de.steamwar.lobby.particle.particles.custom; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java similarity index 60% rename from src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java rename to src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java index 29cc9a5..910008e 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.particles.custom; +package de.steamwar.lobby.particle.particles.custom; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java similarity index 63% rename from src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java rename to src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java index a6234bd..37d956c 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java @@ -1,10 +1,10 @@ -package de.steamwar.lobby.otherparticle.particles.custom; +package de.steamwar.lobby.particle.particles.custom; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index adbda25..2619af8 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -19,7 +19,8 @@ package de.steamwar.lobby.util; -import de.steamwar.lobby.particle.particles.*; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleInventory; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserConfig; import org.bukkit.entity.Player; @@ -43,36 +44,7 @@ public class LobbyPlayer { particle = null; String saved = UserConfig.getConfig(userId, "lobby-particle"); if (saved != null) { - try { - String[] strings = saved.split("@"); - switch (strings[0]) { - case "PlayerParticle": - particle = PlayerParticle.valueOf(strings[1]); - break; - case "TeamParticle": - particle = TeamParticle.valueOf(strings[1]); - break; - case "ServerTeamParticle": - particle = ServerTeamParticle.valueOf(strings[1]); - break; - case "EventParticle": - particle = EventParticle.valueOf(strings[1]); - break; - case "EventParticleParticipation": - particle = EventParticleParticipation.valueOf(strings[1]); - break; - case "EventParticlePlacement": - particle = EventParticlePlacement.valueOf(strings[1]); - break; - case "SpecialParticle": - particle = SpecialTeamParticle.valueOf(strings[1]); - break; - default: - break; - } - } catch (Exception e) { - setParticle(null); - } + particle = ParticleInventory.convertFromString(saved); } } @@ -92,7 +64,7 @@ public class LobbyPlayer { if (particle == null) { UserConfig.removePlayerConfig(userId, "lobby-particle"); } else { - String saved = particle.getClass().getSimpleName() + "@" + ((Enum) particle).name(); + String saved = ParticleInventory.convertToString(particle); UserConfig.updatePlayerConfig(userId, "lobby-particle", saved); } this.particle = particle;