diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index eba500b..7719e91 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -82,7 +82,7 @@ public class ParticleInventory { teamParticles.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", teamLore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", teamLore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); teamParticles.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", teamLore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)); - teamParticles.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, location -> location.add(0, 2.2, 0))); + teamParticles.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, null, location -> location.add(0, 2.2, 0))); serverteamParticles.addAll(teamParticles); serverteamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH)); @@ -98,11 +98,11 @@ public class ParticleInventory { serverteamParticles.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim", serverTeamLore_C, Particle.SLIME)); serverteamParticles.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke", serverTeamLore_C, Particle.CAMPFIRE_COSY_SMOKE)); serverteamParticles.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town", serverTeamLore_C, Particle.TOWN_AURA)); - serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen", serverTeamLore_R, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); - serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted", serverTeamLore_R, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); - serverteamParticles.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten", serverTeamLore_R, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); - serverteamParticles.add(new DoubleCircleParticle(Material.GUARDIAN_SPAWN_EGG, "§bWater§7/§cFire", serverTeamLore_2R, Particle.DRIP_WATER, Particle.DRIP_LAVA, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); - serverteamParticles.add(new DoubleCircleParticle(Material.DIAMOND_SWORD, "§5Magic§7/§eZauber", serverTeamLore_2R, Particle.CRIT_MAGIC, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); + serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen", serverTeamLore_R, Particle.FLAME, null, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); + serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted", serverTeamLore_R, Particle.ENCHANTMENT_TABLE, null, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); + serverteamParticles.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten", serverTeamLore_R, Particle.NOTE, null, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); + serverteamParticles.add(new CircleParticle(Material.GUARDIAN_SPAWN_EGG, "§bWater§7/§cFire", serverTeamLore_2R, Particle.DRIP_WATER, Particle.DRIP_LAVA, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); + serverteamParticles.add(new CircleParticle(Material.DIAMOND_SWORD, "§5Magic§7/§eZauber", serverTeamLore_2R, Particle.CRIT_MAGIC, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); serverteamParticles.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic", serverTeamLore_CR, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0))); serverteamParticles.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen", serverTeamLore_CR, Particle.FLAME, location -> location.add(0, 1.1, 0))); serverteamParticles.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework", serverTeamLore_CR, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0))); diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 6b55a6b..dd69150 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -58,7 +58,7 @@ public class ParticleListener implements Listener { SpecialParticle particle = lobbyPlayer.getParticle(); if (particle == null) return; - particle.particle(player.getWorld(), player, deg); + particle.execute(player.getWorld(), player, deg); } diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java index 0031103..5b7ff24 100644 --- a/src/de/steamwar/lobby/particle/CircleParticle.java +++ b/src/de/steamwar/lobby/particle/CircleParticle.java @@ -35,6 +35,7 @@ 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; @@ -42,15 +43,17 @@ public class CircleParticle extends SpecialParticle { private float vz; private double time = 1; - public CircleParticle(Material material, String name, List lore, Particle particle, UnaryOperator locationShift) { + 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, UnaryOperator locationShift, float vx, float vy, float vz, double time) { + 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; @@ -68,6 +71,18 @@ public class CircleParticle extends SpecialParticle { } 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 index 5e1a668..4d92f36 100644 --- a/src/de/steamwar/lobby/particle/CloudCircleParticle.java +++ b/src/de/steamwar/lobby/particle/CloudCircleParticle.java @@ -26,8 +26,6 @@ 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.List; import java.util.function.UnaryOperator; @@ -35,17 +33,13 @@ 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, locationShift, 0.0F, 0.0F, 0.0F, 0.01); + 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) { - if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); - super.particle(world, player, deg); - } else { - player.removePotionEffect(PotionEffectType.SLOW_FALLING); - } + super.particle(world, player, deg); } } diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java index db2fd5d..58895ef 100644 --- a/src/de/steamwar/lobby/particle/CloudParticle.java +++ b/src/de/steamwar/lobby/particle/CloudParticle.java @@ -23,22 +23,23 @@ package de.steamwar.lobby.particle; import org.bukkit.Material; import org.bukkit.Particle; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; +import org.bukkit.World; +import org.bukkit.entity.Player; import java.util.List; -public class CloudParticle extends FunctionalParticle { +public class CloudParticle extends SpecialParticle { + + private Particle particle; public CloudParticle(Material material, String name, List lore, Particle particle) { - super(material, name, lore, (world, player, time) -> { - if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); - world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 5, 0.5F, 0.02F, 0.5F, 0.01); - } else { - player.removePotionEffect(PotionEffectType.SLOW_FALLING); - } - }); + 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/DoubleCircleParticle.java b/src/de/steamwar/lobby/particle/DoubleCircleParticle.java deleted file mode 100644 index e88819a..0000000 --- a/src/de/steamwar/lobby/particle/DoubleCircleParticle.java +++ /dev/null @@ -1,76 +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 DoubleCircleParticle extends SpecialParticle { - - private Particle particle1; - private Particle particle2; - private Function locationShift; - private boolean customVelocity = false; - private float vx; - private float vy; - private float vz; - private double time = 1; - - public DoubleCircleParticle(Material material, String name, List lore, Particle particle1, Particle particle2, UnaryOperator locationShift, float vx, float vy, float vz, double time) { - super(material, name, lore); - this.particle1 = particle1; - 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(particle1, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time); - } else { - world.spawnParticle(particle1, locationShift.apply(player.getLocation().add(vector)), 1); - } - 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/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java index 8e2f808..0d99b84 100644 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ b/src/de/steamwar/lobby/particle/SpecialParticle.java @@ -25,6 +25,8 @@ 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; @@ -50,8 +52,9 @@ public abstract class SpecialParticle { private Material material; private String name; private List lore; + protected boolean asCloud = false; - public SpecialParticle(Material material, String name, List lore) { + protected SpecialParticle(Material material, String name, List lore) { if (lore == null) { lore = emptyLore; } @@ -64,6 +67,18 @@ public abstract class SpecialParticle { 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); }