From 52d61ccd7994452251bf5bd36a997b3310b53ce7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 15:09:05 +0100 Subject: [PATCH] Update some stuff --- src/de/steamwar/lobby/LobbySystem.properties | 14 ++- .../steamwar/lobby/particle/BaseParticle.java | 12 +-- .../lobby/particle/CircleParticle.java | 87 ------------------- .../lobby/particle/CloudCircleParticle.java | 44 ---------- .../lobby/particle/CloudParticle.java | 44 ---------- .../lobby/particle/FunctionalParticle.java | 43 --------- .../steamwar/lobby/particle/ParticleData.java | 53 +++++++++++ .../lobby/particle/ParticleFunction.java | 29 ------- .../steamwar/lobby/particle/ParticleItem.java | 66 ++++++++++++++ .../lobby/particle/SimpleParticle.java | 67 +++++++------- .../lobby/particle/SpecialParticle.java | 83 ------------------ .../particle/decorator/CircleParticle.java | 75 ++++++++++++++++ .../particle/decorator/CloudParticle.java | 58 +++++++++++++ .../particle/decorator/NonFloorParticle.java | 46 ++++++++++ .../particle/decorator/TickParticle.java | 49 +++++++++++ .../lobby/particle/group/ParticleGroup.java | 47 ++++++++++ .../mutator/LocationParticleMutator.java | 54 ++++++++++++ 17 files changed, 500 insertions(+), 371 deletions(-) delete mode 100644 src/de/steamwar/lobby/particle/CircleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/CloudCircleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/CloudParticle.java delete mode 100644 src/de/steamwar/lobby/particle/FunctionalParticle.java create mode 100644 src/de/steamwar/lobby/particle/ParticleData.java delete mode 100644 src/de/steamwar/lobby/particle/ParticleFunction.java create mode 100644 src/de/steamwar/lobby/particle/ParticleItem.java delete mode 100644 src/de/steamwar/lobby/particle/SpecialParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/CircleParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/CloudParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/TickParticle.java create mode 100644 src/de/steamwar/lobby/particle/group/ParticleGroup.java create mode 100644 src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index a157b1b..a08edb6 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -9,4 +9,16 @@ PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7P PORTAL_COMMAND_REMOVE_HELP = §8/§7portal §eremove §8[§7PortalName§8] §8- §7Entfernt ein Portal PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos2§8(§7{3}§8) -PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection \ No newline at end of file +PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection + +# Particle +PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring +PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel Ring +PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke +PARTICLE_ATTRIBUTE_TICK = §8-§f Immer aktiv +PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft +PARTICLE_ATTRIBUTE = §eAttribute§7: + +PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch + +PARTICLE_SELECT = §eKlicken zum auswählen diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java index 8bf9162..9545282 100644 --- a/src/de/steamwar/lobby/particle/BaseParticle.java +++ b/src/de/steamwar/lobby/particle/BaseParticle.java @@ -1,17 +1,11 @@ package de.steamwar.lobby.particle; -import de.steamwar.inventory.SWItem; import org.bukkit.Color; import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.List; import java.util.Random; public interface BaseParticle { - List EMPTY_LORE = new ArrayList<>(); Random RANDOM = new Random(); default Color randomColor() { @@ -26,11 +20,11 @@ public interface BaseParticle { return new Particle.DustOptions(randomColor(), randomSize()); } - SWItem getItem(); + ParticleItem getItem(); - default boolean tickable() { + default boolean needsTick() { return false; } - void particle(World world, Player player, double deg); + void particle(ParticleData particleData); } diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java deleted file mode 100644 index 1c76092..0000000 --- a/src/de/steamwar/lobby/particle/CircleParticle.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.List; -import java.util.function.Function; -import java.util.function.UnaryOperator; - -public class CircleParticle extends SpecialParticle { - - private Particle particle; - private Particle particle2; - private Function locationShift; - private boolean customVelocity = false; - private float vx; - private float vy; - private float vz; - private double time = 1; - - public CircleParticle(Material material, String name, List lore, Particle particle, Particle particle2, UnaryOperator locationShift) { - super(material, name, lore); - this.particle = particle; - this.particle2 = particle2; - this.locationShift = locationShift; - } - - public CircleParticle(Material material, String name, List lore, Particle particle, Particle particle2, UnaryOperator locationShift, float vx, float vy, float vz, double time) { - super(material, name, lore); - this.particle = particle; - this.particle2 = particle2; - this.locationShift = locationShift; - customVelocity = true; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - } - - @Override - public void particle(World world, Player player, double deg) { - Vector vector = new Vector(1, 0, 0); - vector.rotateAroundY(deg); - if (customVelocity) { - world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time); - } else { - world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1); - } - - if (particle2 == null) { - return; - } - - vector.setX(-vector.getX()); - vector.setZ(-vector.getZ()); - if (customVelocity) { - world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time); - } else { - world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1); - } - } - -} diff --git a/src/de/steamwar/lobby/particle/CloudCircleParticle.java b/src/de/steamwar/lobby/particle/CloudCircleParticle.java deleted file mode 100644 index 80f9ed7..0000000 --- a/src/de/steamwar/lobby/particle/CloudCircleParticle.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.function.UnaryOperator; - -public class CloudCircleParticle extends CircleParticle { - - public CloudCircleParticle(Material material, String name, List lore, Particle particle, UnaryOperator locationShift) { - super(material, name, lore, particle, null, locationShift, 0.0F, 0.0F, 0.0F, 0.01); - asCloud = true; - } - - @Override - public void particle(World world, Player player, double deg) { - super.particle(world, player, deg); - } - -} diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java deleted file mode 100644 index 706c071..0000000 --- a/src/de/steamwar/lobby/particle/CloudParticle.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; - -public class CloudParticle extends SpecialParticle { - - private Particle particle; - - public CloudParticle(Material material, String name, List lore, Particle particle) { - super(material, name, lore); - asCloud = true; - this.particle = particle; - } - - @Override - public void particle(World world, Player player, double deg) { - world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 5, 0.5F, 0.02F, 0.5F, 0.01); - } -} diff --git a/src/de/steamwar/lobby/particle/FunctionalParticle.java b/src/de/steamwar/lobby/particle/FunctionalParticle.java deleted file mode 100644 index 2e11da0..0000000 --- a/src/de/steamwar/lobby/particle/FunctionalParticle.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; - -public class FunctionalParticle extends SpecialParticle { - - private ParticleFunction particleFunction; - - public FunctionalParticle(Material material, String name, List lore, ParticleFunction particleFunction) { - super(material, name, lore); - this.particleFunction = particleFunction; - } - - @Override - public void particle(World world, Player player, double deg) { - particleFunction.accept(world, player, deg); - } - -} diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java new file mode 100644 index 0000000..df9afcb --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -0,0 +1,53 @@ +/* + * 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 lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; + +@RequiredArgsConstructor +@AllArgsConstructor +@Getter +public class ParticleData { + private final World world; + private final Player player; + private Location location; + private final double deg; + + public ParticleData withLocation(Location location) { + this.location = location; + return this; + } + + public Location getLocation() { + if (location == null) { + return player.getLocation(); + } + return location; + } + + public ParticleData clone() { + return new ParticleData(world, player, location, deg); + } +} diff --git a/src/de/steamwar/lobby/particle/ParticleFunction.java b/src/de/steamwar/lobby/particle/ParticleFunction.java deleted file mode 100644 index ab210ec..0000000 --- a/src/de/steamwar/lobby/particle/ParticleFunction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.World; -import org.bukkit.entity.Player; - -@FunctionalInterface -public interface ParticleFunction { - void accept(World world, Player player, double time); -} diff --git a/src/de/steamwar/lobby/particle/ParticleItem.java b/src/de/steamwar/lobby/particle/ParticleItem.java new file mode 100644 index 0000000..3634d17 --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleItem.java @@ -0,0 +1,66 @@ +/* + * 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 lombok.Setter; +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 { + + private final Material material; + private final String name; + private final Set attributes = new LinkedHashSet<>(); + + @Setter + private String 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/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index 52c0b1d..416ea79 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -1,48 +1,49 @@ /* + * This file is a part of the SteamWar software. * - * This file is a part of the SteamWar software. + * Copyright (C) 2022 SteamWar.de-Serverteam * - * Copyright (C) 2020 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 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. * - * 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 . + * 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.*; -import org.bukkit.entity.Player; +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.Particle; -import java.util.List; +public class SimpleParticle implements BaseParticle { -public class SimpleParticle extends SpecialParticle { - - private Particle particle; + 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; - public SimpleParticle(Material material, String name, List lore, Particle particle) { - super(material, name, lore); + public SimpleParticle(ParticleItem particleItem, Particle particle) { + this.particleItem = particleItem; this.particle = particle; } - public SimpleParticle(Material material, String name, List lore, Particle particle, float vx, float vy, float vz, double time) { - super(material, name, lore); + public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) { + this.particleItem = particleItem; this.particle = particle; - customVelocity = true; + this.customVelocity = true; this.vx = vx; this.vy = vy; this.vz = vz; @@ -50,13 +51,17 @@ public class SimpleParticle extends SpecialParticle { } @Override - public void particle(World world, Player player, double deg) { - Location location = player.getLocation().add(0.0, 0.2, 0.0); - if (customVelocity) { - world.spawnParticle(particle, location, 5, vx, vy, vz, time); - } else { - world.spawnParticle(particle, location, 5); - } + public ParticleItem getItem() { + return particleItem; } + @Override + public void particle(ParticleData particleData) { + Location location = particleData.getLocation().add(0.0, 0.2, 0.0); + if (customVelocity) { + particleData.getWorld().spawnParticle(particle, location, 5, vx, vy, vz, time); + } else { + particleData.getWorld().spawnParticle(particle, location, 5); + } + } } diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java deleted file mode 100644 index 3a81325..0000000 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 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 org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public abstract class SpecialParticle { - - private static final List EMPTY_LORE = new ArrayList<>(); - private static Random random = new Random(); - - public static Color randomColor() { - return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)); - } - - public static float randomSize() { - return random.nextFloat() / 2 + 1; - } - - public static Particle.DustOptions getParticleDust() { - return new Particle.DustOptions(randomColor(), randomSize()); - } - - private Material material; - private String name; - private List lore; - protected boolean asCloud = false; - - protected SpecialParticle(Material material, String name, List lore) { - if (lore == null) { - lore = EMPTY_LORE; - } - this.material = material; - this.name = name; - this.lore = lore; - } - - public final SWItem getItem() { - return new SWItem(material, name, lore, false, clickType -> {}); - } - - public final void execute(World world, Player player, double deg) { - if (asCloud) { - if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); - } else { - player.removePotionEffect(PotionEffectType.SLOW_FALLING); - return; - } - } - particle(world, player, deg); - } - - public abstract void particle(World world, Player player, double deg); -} diff --git a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java new file mode 100644 index 0000000..bc3fb1b --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java @@ -0,0 +1,75 @@ +/* + * 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.withLocation(location.clone().add(vector)); + particle.particle(particleData); + + if (particle2 == null) { + return; + } + vector.setX(-vector.getX()); + vector.setZ(-vector.getZ()); + + particleData.withLocation(location.clone().add(vector)); + particle2.particle(particleData); + } +} diff --git a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java new file mode 100644 index 0000000..c3d6747 --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java @@ -0,0 +1,58 @@ +/* + * 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; + } + particle.particle(particleData); + } +} diff --git a/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java b/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java new file mode 100644 index 0000000..f0a090a --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java @@ -0,0 +1,46 @@ +/* + * 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 new file mode 100644 index 0000000..1eee74e --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/TickParticle.java @@ -0,0 +1,49 @@ +/* + * 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/group/ParticleGroup.java b/src/de/steamwar/lobby/particle/group/ParticleGroup.java new file mode 100644 index 0000000..f2c4272 --- /dev/null +++ b/src/de/steamwar/lobby/particle/group/ParticleGroup.java @@ -0,0 +1,47 @@ +/* + * 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.clone()); + } + } +} diff --git a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java new file mode 100644 index 0000000..d91f850 --- /dev/null +++ b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java @@ -0,0 +1,54 @@ +/* + * 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.withLocation(mutator.apply(particleData.getLocation())); + particle.particle(particleData); + } +}