From fecaa21f08fac9817c5ccf17ae36d8962e6e94e3 Mon Sep 17 00:00:00 2001 From: jojo Date: Wed, 30 Dec 2020 10:22:42 +0100 Subject: [PATCH 01/11] Add FunctionalParticle Add ParticleFunction Add SimpleParticle Add SpecialParticle --- .../lobby/inventories/ParticleInventory.java | 97 +++++++++---------- .../lobby/listener/ParticleListener.java | 37 ++++--- .../lobby/particle/FunctionalParticle.java | 44 +++++++++ .../lobby/particle/ParticleFunction.java | 30 ++++++ .../lobby/particle/SimpleParticle.java | 68 +++++++++++++ .../lobby/particle/SpecialParticle.java | 77 +++++++++++++++ src/de/steamwar/lobby/utils/LobbyPlayer.java | 53 ++-------- 7 files changed, 291 insertions(+), 115 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/FunctionalParticle.java create mode 100644 src/de/steamwar/lobby/particle/ParticleFunction.java create mode 100644 src/de/steamwar/lobby/particle/SimpleParticle.java create mode 100644 src/de/steamwar/lobby/particle/SpecialParticle.java diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 15ca3ca..9f95d1e 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -20,7 +20,9 @@ package de.steamwar.lobby.inventories; import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.particle.FunctionalParticle; +import de.steamwar.lobby.particle.SimpleParticle; +import de.steamwar.lobby.particle.SpecialParticle; import de.steamwar.lobby.utils.LobbyPlayer; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; @@ -33,70 +35,67 @@ import java.util.List; public class ParticleInventory { - private ParticleInventory() {} + private ParticleInventory() { + } - private static List lore = Arrays.asList("§aKlicken zum Auswählen"); + private static final List lore = Arrays.asList("§aKlicken zum Auswählen"); + + private static final SpecialParticle SNEEZE = new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01); + private static final SpecialParticle SMOKE = new SimpleParticle(Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01); + private static final SpecialParticle FLAME = new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA); + private static final SpecialParticle WATER = new SimpleParticle(Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER); + private static final SpecialParticle HEART = new FunctionalParticle(Material.RED_DYE, "§cHerzen", lore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5)); + private static final SpecialParticle NOTES = new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", lore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5)); + private static final SpecialParticle NAUTILIS = new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01); + + private static final SpecialParticle SNOWBALL = new SimpleParticle(Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01); + private static final SpecialParticle EFFECT = new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01); + private static final SpecialParticle CAMPFIRE = new SimpleParticle(Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01); + private static final SpecialParticle MAGIC = new SimpleParticle(Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01); + private static final SpecialParticle RAGE = new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01); + private static final SpecialParticle SLIME = new SimpleParticle(Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME); + private static final SpecialParticle MOB = new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB); + + private static final SpecialParticle DAMAGE = new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01); + private static final SpecialParticle WITCH = new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH); + private static final SpecialParticle ENCHANTING = new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE); + private static final SpecialParticle FRIEND = new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01); + private static final SpecialParticle FIRE = new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01); + private static final SpecialParticle TOTEM = new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01); + private static final SpecialParticle END = new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01); + + private static final SpecialParticle[] row_1 = new SpecialParticle[]{SNEEZE, SMOKE, FLAME, WATER, HEART, NOTES, NAUTILIS}; + private static final SpecialParticle[] row_2 = new SpecialParticle[]{SNOWBALL, EFFECT, CAMPFIRE, MAGIC, RAGE, SLIME, MOB}; + private static final SpecialParticle[] row_3 = new SpecialParticle[]{DAMAGE, WITCH, ENCHANTING, FRIEND, FIRE, TOTEM, END}; private static SWInventory createInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - SWInventory swInventory; - if (userGroup == UserGroup.Member) { - swInventory = new SWInventory(player, 9*5, "§6Partikel"); - } else { - swInventory = new SWInventory(player, 9*6, "§6Partikel"); - } + SWInventory swInventory = new SWInventory(player, 9 * (userGroup == UserGroup.Member ? 5 : 6), "§6Partikel"); - add(swInventory, Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 10, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01); - add(swInventory, Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 11, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01); - add(swInventory, Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA, 12, player, lobbyPlayer); - add(swInventory, Material.RED_DYE, "§cHerzen", lore, Particle.HEART, 13, player, lobbyPlayer); - add(swInventory, Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER, 14, player, lobbyPlayer); - add(swInventory, Material.NOTE_BLOCK, "§eNoten", lore, Particle.NOTE, 15, player, lobbyPlayer); - add(swInventory, Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 16, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01); - - add(swInventory, Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 19, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01); - add(swInventory, Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 20, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01); - add(swInventory, Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 21, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.01); - add(swInventory, Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 22, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01); - add(swInventory, Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 23, player, lobbyPlayer, true, 0.2F, 0.02F, 0.2F, 0.01); - add(swInventory, Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME, 24, player, lobbyPlayer); - add(swInventory, Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB, 25, player, lobbyPlayer); + add(swInventory, row_1, 10, lobbyPlayer); + add(swInventory, row_2, 19, lobbyPlayer); if (userGroup == UserGroup.Member) { - add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer); + swInventory.setItem(31, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { + lobbyPlayer.setParticle(null); + }); } else { - add(swInventory, Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 28, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01); - add(swInventory, Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH, 29, player, lobbyPlayer); - add(swInventory, Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE, 30, player, lobbyPlayer); - add(swInventory, Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 31, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01); - add(swInventory, Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 32, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.01); - add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.2); - add(swInventory, Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 34, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01); - - add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 40, player, lobbyPlayer); + add(swInventory, row_3, 28, lobbyPlayer); + swInventory.setItem(40, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { + lobbyPlayer.setParticle(null); + }); } return swInventory; } - private static void add(SWInventory swInventory, Material material, String name, List lore, Particle particle, int slot, Player player, LobbyPlayer lobbyPlayer, boolean customVelocity, float vx, float vy, float vz, double time) { - SWItem swItem = new SWItem(material, name, lore, false, clickType -> { - lobbyPlayer.setParticle(particle, customVelocity); - lobbyPlayer.setParticle(vx, vy, vz, time); - player.closeInventory(); - }); - swInventory.setItem(slot, swItem); - } - - private static void add(SWInventory swInventory, Material material, String name, List lore, Particle particle, int slot, Player player, LobbyPlayer lobbyPlayer) { - SWItem swItem = new SWItem(material, name, lore, false, clickType -> { - lobbyPlayer.setParticle(particle); - player.closeInventory(); - }); - swInventory.setItem(slot, swItem); + private static void add(SWInventory swInventory, SpecialParticle[] specialParticles, int index, LobbyPlayer lobbyPlayer) { + for (int i = 0; i < specialParticles.length; i++) { + specialParticles[i].add(swInventory, i + index, lobbyPlayer); + } } public static void openParticleInventory(Player player) { diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 87c3509..deee72e 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -19,11 +19,12 @@ package de.steamwar.lobby.listener; +import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.inventories.ParticleInventory; +import de.steamwar.lobby.particle.SpecialParticle; import de.steamwar.lobby.utils.LobbyPlayer; -import org.bukkit.Color; -import org.bukkit.Particle; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -31,17 +32,23 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; -import java.util.Random; - public class ParticleListener implements Listener { - private static Random random = new Random(); + private static int deg = 0; + + public ParticleListener() { + Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { + deg++; + if (deg > 360) { + deg = 0; + } + }, 0, 1); + } @EventHandler(priority = EventPriority.NORMAL) public void handlePlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - if(event.getMaterial() != LobbyInventory.PARTICLE) - return; + if (event.getMaterial() != LobbyInventory.PARTICLE) return; ParticleInventory.openParticleInventory(player); } @@ -50,20 +57,10 @@ public class ParticleListener implements Listener { public void handlePlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - Particle particle = lobbyPlayer.getParticle(); + SpecialParticle particle = lobbyPlayer.getParticle(); + if (particle == null) return; - - if (particle == Particle.REDSTONE) { - Particle.DustOptions dust = new Particle.DustOptions(Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)), random.nextFloat() / 2 + 1); - player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5, dust); - return; - } - - if (lobbyPlayer.isCustomVelocity()) { - player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5, lobbyPlayer.getParticle_vx(), lobbyPlayer.getParticle_vy(), lobbyPlayer.getParticle_vz(), lobbyPlayer.getParticle_time()); - } else { - player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5); - } + particle.particle(player.getWorld(), player, deg); } diff --git a/src/de/steamwar/lobby/particle/FunctionalParticle.java b/src/de/steamwar/lobby/particle/FunctionalParticle.java new file mode 100644 index 0000000..c8bc297 --- /dev/null +++ b/src/de/steamwar/lobby/particle/FunctionalParticle.java @@ -0,0 +1,44 @@ +/* + * + * 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, int deg) { + particleFunction.accept(world, player, deg); + } + +} diff --git a/src/de/steamwar/lobby/particle/ParticleFunction.java b/src/de/steamwar/lobby/particle/ParticleFunction.java new file mode 100644 index 0000000..13f475a --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleFunction.java @@ -0,0 +1,30 @@ +/* + * + * 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, Integer time); +} diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java new file mode 100644 index 0000000..14930cb --- /dev/null +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -0,0 +1,68 @@ +/* + * + * 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.*; +import org.bukkit.entity.Player; + +import java.util.List; + +public class SimpleParticle extends SpecialParticle { + + private Particle particle; + private boolean customVelocity = false; + private float vx; + private float vy; + private float vz; + private double time; + + public SimpleParticle(Material material, String name, List lore, Particle particle) { + super(material, name, lore); + 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); + this.particle = particle; + customVelocity = true; + this.vx = vx; + this.vy = vy; + this.vz = vz; + this.time = time; + } + + @Override + public void particle(World world, Player player, int deg) { + Location location = player.getLocation().add(0.0, 0.2, 0.0); + if (particle == Particle.REDSTONE) { + world.spawnParticle(particle, location, 5, getParticleDust()); + return; + } + + if (customVelocity) { + world.spawnParticle(particle, location, 5, vx, vy, vz, time); + } else { + world.spawnParticle(particle, location, 5); + } + } + +} diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java new file mode 100644 index 0000000..f8ffa2d --- /dev/null +++ b/src/de/steamwar/lobby/particle/SpecialParticle.java @@ -0,0 +1,77 @@ +/* + 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.SWInventory; +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.utils.LobbyPlayer; +import org.bukkit.Color; +import org.bukkit.Material; +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 abstract class SpecialParticle { + + private static final List emptyLore = new ArrayList<>(); + private static Random random = new Random(); + + protected static Color randomColor() { + return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)); + } + + protected static float randomSize() { + return random.nextFloat() / 2 + 1; + } + + protected static Particle.DustOptions getParticleDust() { + return new Particle.DustOptions(randomColor(), randomSize()); + } + + private Material material; + private String name; + private List lore; + + public SpecialParticle(Material material, String name, List lore) { + if (lore == null) { + lore = emptyLore; + } + this.material = material; + this.name = name; + this.lore = lore; + } + + public final SWItem getItem(LobbyPlayer lobbyPlayer) { + return new SWItem(material, name, lore, false, clickType -> { + lobbyPlayer.setParticle(this); + }); + } + + public final void add(SWInventory swInventory, int pos, LobbyPlayer lobbyPlayer) { + swInventory.setItem(pos, getItem(lobbyPlayer)); + } + + public abstract void particle(World world, Player player, int deg); + +} diff --git a/src/de/steamwar/lobby/utils/LobbyPlayer.java b/src/de/steamwar/lobby/utils/LobbyPlayer.java index 96a0292..380daf5 100644 --- a/src/de/steamwar/lobby/utils/LobbyPlayer.java +++ b/src/de/steamwar/lobby/utils/LobbyPlayer.java @@ -19,7 +19,7 @@ package de.steamwar.lobby.utils; -import org.bukkit.Particle; +import de.steamwar.lobby.particle.SpecialParticle; import java.util.HashMap; import java.util.Map; @@ -29,60 +29,21 @@ public class LobbyPlayer { private static Map cache = new HashMap<>(); - private Particle particle; - private boolean customVelocity = false; - private float particle_vx = 0; - private float particle_vy = 0; - private float particle_vz = 0; - private double particle_time = 0.001; + private SpecialParticle specialParticle; private boolean enderPearlUsed; private LobbyPlayer(UUID uuid) { cache.put(uuid, this); + specialParticle = null; } - public Particle getParticle() { - return particle; + public SpecialParticle getParticle() { + return specialParticle; } - public boolean isCustomVelocity() { - return customVelocity; - } - - public float getParticle_vx() { - return particle_vx; - } - - public float getParticle_vy() { - return particle_vy; - } - - public float getParticle_vz() { - return particle_vz; - } - - public double getParticle_time() { - return particle_time; - } - - public void setParticle(Particle particle) { - this.particle = particle; - this.customVelocity = false; - setParticle(0, 0, 0, 0.001); - } - - public void setParticle(Particle particle, boolean customVelocity) { - this.particle = particle; - this.customVelocity = customVelocity; - setParticle(0, 0, 0, 0.001); - } - - public void setParticle(float vx, float vy, float vz, double time) { - this.particle_vx = vx; - this.particle_vy = vy; - this.particle_vz = vz; - this.particle_time = time; + public void setParticle(SpecialParticle specialParticle) { + this.specialParticle = specialParticle; } public boolean isEnderPearlUsed() { -- 2.39.5 From 6f04d2b811cf53b87802e68385c3dbc0bb7edb53 Mon Sep 17 00:00:00 2001 From: jojo Date: Wed, 30 Dec 2020 10:29:52 +0100 Subject: [PATCH 02/11] Add CircleParticle Add FireRing particle --- .../lobby/inventories/ParticleInventory.java | 5 ++ .../lobby/particle/CircleParticle.java | 53 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/de/steamwar/lobby/particle/CircleParticle.java diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 9f95d1e..d137fe7 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -20,6 +20,7 @@ package de.steamwar.lobby.inventories; import de.steamwar.inventory.SWInventory; +import de.steamwar.lobby.particle.CircleParticle; import de.steamwar.lobby.particle.FunctionalParticle; import de.steamwar.lobby.particle.SimpleParticle; import de.steamwar.lobby.particle.SpecialParticle; @@ -28,6 +29,7 @@ import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import org.bukkit.Material; import org.bukkit.Particle; +import org.bukkit.block.data.type.Fire; import org.bukkit.entity.Player; import java.util.Arrays; @@ -64,9 +66,12 @@ public class ParticleInventory { private static final SpecialParticle TOTEM = new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01); private static final SpecialParticle END = new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01); + private static final SpecialParticle FIRE_RING = new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0)); + private static final SpecialParticle[] row_1 = new SpecialParticle[]{SNEEZE, SMOKE, FLAME, WATER, HEART, NOTES, NAUTILIS}; private static final SpecialParticle[] row_2 = new SpecialParticle[]{SNOWBALL, EFFECT, CAMPFIRE, MAGIC, RAGE, SLIME, MOB}; private static final SpecialParticle[] row_3 = new SpecialParticle[]{DAMAGE, WITCH, ENCHANTING, FRIEND, FIRE, TOTEM, END}; + private static final SpecialParticle[] row_4 = new SpecialParticle[]{FIRE_RING}; private static SWInventory createInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java new file mode 100644 index 0000000..a57d702 --- /dev/null +++ b/src/de/steamwar/lobby/particle/CircleParticle.java @@ -0,0 +1,53 @@ +/* + * + * 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.Supplier; + +public class CircleParticle extends SpecialParticle { + + private Particle particle; + private Function locationShift; + + public CircleParticle(Material material, String name, List lore, Particle particle, Function locationShift) { + super(material, name, lore); + this.particle = particle; + this.locationShift = locationShift; + } + + @Override + public void particle(World world, Player player, int deg) { + Vector vector = new Vector(1, 0, 0); + vector.rotateAroundY(deg); + world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 5); + } + +} -- 2.39.5 From 3d6c9b267fbd8f26acf1ba1e5b74f01ab475b660 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 3 Jan 2021 15:36:23 +0100 Subject: [PATCH 03/11] Implement new ParticleInventory --- .../lobby/inventories/ParticleInventory.java | 88 +++++++++---------- .../lobby/listener/ParticleListener.java | 8 +- .../lobby/particle/CircleParticle.java | 25 +++++- .../lobby/particle/FunctionalParticle.java | 2 +- .../lobby/particle/ParticleFunction.java | 2 +- .../lobby/particle/SimpleParticle.java | 4 +- .../lobby/particle/SpecialParticle.java | 14 +-- 7 files changed, 74 insertions(+), 69 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index d137fe7..bfa6db1 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -20,6 +20,7 @@ package de.steamwar.lobby.inventories; import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWListInv; import de.steamwar.lobby.particle.CircleParticle; import de.steamwar.lobby.particle.FunctionalParticle; import de.steamwar.lobby.particle.SimpleParticle; @@ -29,9 +30,9 @@ import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import org.bukkit.Material; import org.bukkit.Particle; -import org.bukkit.block.data.type.Fire; import org.bukkit.entity.Player; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -42,65 +43,60 @@ public class ParticleInventory { private static final List lore = Arrays.asList("§aKlicken zum Auswählen"); - private static final SpecialParticle SNEEZE = new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01); - private static final SpecialParticle SMOKE = new SimpleParticle(Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01); - private static final SpecialParticle FLAME = new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA); - private static final SpecialParticle WATER = new SimpleParticle(Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER); - private static final SpecialParticle HEART = new FunctionalParticle(Material.RED_DYE, "§cHerzen", lore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5)); - private static final SpecialParticle NOTES = new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", lore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5)); - private static final SpecialParticle NAUTILIS = new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01); + private static final List playerParticles = new ArrayList<>(); + private static final List teamParticles = new ArrayList<>(); - private static final SpecialParticle SNOWBALL = new SimpleParticle(Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01); - private static final SpecialParticle EFFECT = new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01); - private static final SpecialParticle CAMPFIRE = new SimpleParticle(Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01); - private static final SpecialParticle MAGIC = new SimpleParticle(Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01); - private static final SpecialParticle RAGE = new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01); - private static final SpecialParticle SLIME = new SimpleParticle(Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME); - private static final SpecialParticle MOB = new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB); + private static final List> playerParticlesEntries = new ArrayList<>(); + private static final List> teamParticlesEntries = new ArrayList<>(); - private static final SpecialParticle DAMAGE = new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01); - private static final SpecialParticle WITCH = new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH); - private static final SpecialParticle ENCHANTING = new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE); - private static final SpecialParticle FRIEND = new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01); - private static final SpecialParticle FIRE = new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01); - private static final SpecialParticle TOTEM = new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01); - private static final SpecialParticle END = new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01); + static { + playerParticles.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA)); + playerParticles.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER)); + playerParticles.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", lore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5))); + playerParticles.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", lore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5))); + playerParticles.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)); + playerParticles.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01)); + playerParticles.add(new SimpleParticle(Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME)); + playerParticles.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB)); - private static final SpecialParticle FIRE_RING = new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0)); + teamParticles.addAll(playerParticles); + teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH)); + teamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE)); + teamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); + teamParticles.add(new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01)); + teamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); + teamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); + teamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); + teamParticles.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten Ring", lore, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); - private static final SpecialParticle[] row_1 = new SpecialParticle[]{SNEEZE, SMOKE, FLAME, WATER, HEART, NOTES, NAUTILIS}; - private static final SpecialParticle[] row_2 = new SpecialParticle[]{SNOWBALL, EFFECT, CAMPFIRE, MAGIC, RAGE, SLIME, MOB}; - private static final SpecialParticle[] row_3 = new SpecialParticle[]{DAMAGE, WITCH, ENCHANTING, FRIEND, FIRE, TOTEM, END}; - private static final SpecialParticle[] row_4 = new SpecialParticle[]{FIRE_RING}; + playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); + teamParticles.forEach(specialParticle -> teamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); + } private static SWInventory createInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - SWInventory swInventory = new SWInventory(player, 9 * (userGroup == UserGroup.Member ? 5 : 6), "§6Partikel"); - - add(swInventory, row_1, 10, lobbyPlayer); - add(swInventory, row_2, 19, lobbyPlayer); - + SWListInv particleSWListInv; if (userGroup == UserGroup.Member) { - swInventory.setItem(31, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { - lobbyPlayer.setParticle(null); - }); + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, playerParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } else { - add(swInventory, row_3, 28, lobbyPlayer); - swInventory.setItem(40, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { - lobbyPlayer.setParticle(null); - }); + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, teamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } + particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { + lobbyPlayer.setParticle(null); + }); - return swInventory; - } - - private static void add(SWInventory swInventory, SpecialParticle[] specialParticles, int index, LobbyPlayer lobbyPlayer) { - for (int i = 0; i < specialParticles.length; i++) { - specialParticles[i].add(swInventory, i + index, lobbyPlayer); - } + return particleSWListInv; } public static void openParticleInventory(Player player) { diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index deee72e..6b55a6b 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -34,14 +34,12 @@ import org.bukkit.event.player.PlayerMoveEvent; public class ParticleListener implements Listener { - private static int deg = 0; + private static double deg = 0; public ParticleListener() { Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { - deg++; - if (deg > 360) { - deg = 0; - } + deg += 0.1; + if (deg > 360) deg = 0; }, 0, 1); } diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java index a57d702..bca7529 100644 --- a/src/de/steamwar/lobby/particle/CircleParticle.java +++ b/src/de/steamwar/lobby/particle/CircleParticle.java @@ -30,12 +30,16 @@ import org.bukkit.util.Vector; import java.util.List; import java.util.function.Function; -import java.util.function.Supplier; public class CircleParticle extends SpecialParticle { private Particle particle; 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, Function locationShift) { super(material, name, lore); @@ -43,11 +47,26 @@ public class CircleParticle extends SpecialParticle { this.locationShift = locationShift; } + public CircleParticle(Material material, String name, List lore, Particle particle, Function locationShift, float vx, float vy, float vz, double time) { + super(material, name, lore); + this.particle = particle; + 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, int deg) { + public void particle(World world, Player player, double deg) { Vector vector = new Vector(1, 0, 0); vector.rotateAroundY(deg); - world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 5); + 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); + } } } diff --git a/src/de/steamwar/lobby/particle/FunctionalParticle.java b/src/de/steamwar/lobby/particle/FunctionalParticle.java index c8bc297..f2bc6dc 100644 --- a/src/de/steamwar/lobby/particle/FunctionalParticle.java +++ b/src/de/steamwar/lobby/particle/FunctionalParticle.java @@ -37,7 +37,7 @@ public class FunctionalParticle extends SpecialParticle { } @Override - public void particle(World world, Player player, int deg) { + public void particle(World world, Player player, double deg) { particleFunction.accept(world, player, deg); } diff --git a/src/de/steamwar/lobby/particle/ParticleFunction.java b/src/de/steamwar/lobby/particle/ParticleFunction.java index 13f475a..1e62c03 100644 --- a/src/de/steamwar/lobby/particle/ParticleFunction.java +++ b/src/de/steamwar/lobby/particle/ParticleFunction.java @@ -26,5 +26,5 @@ import org.bukkit.entity.Player; @FunctionalInterface public interface ParticleFunction { - void accept(World world, Player player, Integer time); + void accept(World world, Player player, double time); } diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index 14930cb..4695220 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -33,7 +33,7 @@ public class SimpleParticle extends SpecialParticle { private float vx; private float vy; private float vz; - private double time; + private double time = 1; public SimpleParticle(Material material, String name, List lore, Particle particle) { super(material, name, lore); @@ -51,7 +51,7 @@ public class SimpleParticle extends SpecialParticle { } @Override - public void particle(World world, Player player, int deg) { + public void particle(World world, Player player, double deg) { Location location = player.getLocation().add(0.0, 0.2, 0.0); if (particle == Particle.REDSTONE) { world.spawnParticle(particle, location, 5, getParticleDust()); diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java index f8ffa2d..8e2f808 100644 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ b/src/de/steamwar/lobby/particle/SpecialParticle.java @@ -19,9 +19,7 @@ package de.steamwar.lobby.particle; -import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; -import de.steamwar.lobby.utils.LobbyPlayer; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.Particle; @@ -62,16 +60,10 @@ public abstract class SpecialParticle { this.lore = lore; } - public final SWItem getItem(LobbyPlayer lobbyPlayer) { - return new SWItem(material, name, lore, false, clickType -> { - lobbyPlayer.setParticle(this); - }); + public final SWItem getItem() { + return new SWItem(material, name, lore, false, clickType -> {}); } - public final void add(SWInventory swInventory, int pos, LobbyPlayer lobbyPlayer) { - swInventory.setItem(pos, getItem(lobbyPlayer)); - } - - public abstract void particle(World world, Player player, int deg); + public abstract void particle(World world, Player player, double deg); } -- 2.39.5 From d44bb520d42c158b3811459a287fd8ebeae45673 Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 8 Jan 2021 13:03:39 +0100 Subject: [PATCH 04/11] Add CloudParticle Add ParticleInventory.teamParticles Add ParticleInventory.serverteamParticles --- .../lobby/inventories/ParticleInventory.java | 48 ++++++++++++------- .../lobby/particle/CloudParticle.java | 44 +++++++++++++++++ 2 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/CloudParticle.java diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index bfa6db1..68d735d 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -21,16 +21,15 @@ package de.steamwar.lobby.inventories; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWListInv; -import de.steamwar.lobby.particle.CircleParticle; -import de.steamwar.lobby.particle.FunctionalParticle; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.SpecialParticle; +import de.steamwar.lobby.particle.*; import de.steamwar.lobby.utils.LobbyPlayer; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; import java.util.Arrays; @@ -45,9 +44,11 @@ public class ParticleInventory { private static final List playerParticles = new ArrayList<>(); private static final List teamParticles = new ArrayList<>(); + private static final List serverteamParticles = new ArrayList<>(); private static final List> playerParticlesEntries = new ArrayList<>(); private static final List> teamParticlesEntries = new ArrayList<>(); + private static final List> serverteamParticlesEntries = new ArrayList<>(); static { playerParticles.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); @@ -66,19 +67,30 @@ public class ParticleInventory { playerParticles.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB)); teamParticles.addAll(playerParticles); - teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH)); - teamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE)); - teamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); - teamParticles.add(new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01)); - teamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); - teamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); - teamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); - teamParticles.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten Ring", lore, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); + teamParticles.add(new SimpleParticle(Material.INK_SAC, "§8Squid", lore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", lore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", lore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); + teamParticles.add(new SimpleParticle(Material.FIRE_CHARGE, "§7Firework", lore, Particle.FIREWORKS_SPARK, 0.2F, 0.2F, 0.2F, 0.5)); + teamParticles.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", lore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); + teamParticles.add(new CircleParticle(Material.RED_WOOL, "§cHerzen Ring", lore, Particle.HEART, location -> location.add(0, 2.2, 0))); + + serverteamParticles.addAll(teamParticles); + serverteamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); + serverteamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH)); + serverteamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE)); + serverteamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); + serverteamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); + serverteamParticles.add(new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01)); + serverteamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); + serverteamParticles.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", lore, Particle.CLOUD)); + serverteamParticles.add(new CloudParticle(Material.ENCHANTED_GOLDEN_APPLE, "§eZauber Cloud", lore, Particle.ENCHANTMENT_TABLE)); + serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); + serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, 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 Ring", lore, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); teamParticles.forEach(specialParticle -> teamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); + serverteamParticles.forEach(specialParticle -> serverteamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); } private static SWInventory createInventory(Player player) { @@ -88,9 +100,13 @@ public class ParticleInventory { SWListInv particleSWListInv; if (userGroup == UserGroup.Member) { - particleSWListInv = new SWListInv<>(player, "§6Partikel", false, playerParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + if (steamwarUser.getTeam() != 0) { + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, teamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + } else { + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, playerParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + } } else { - particleSWListInv = new SWListInv<>(player, "§6Partikel", false, teamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, serverteamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { lobbyPlayer.setParticle(null); diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java new file mode 100644 index 0000000..d5f3a82 --- /dev/null +++ b/src/de/steamwar/lobby/particle/CloudParticle.java @@ -0,0 +1,44 @@ +/* + * + * 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.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.List; + +public class CloudParticle extends FunctionalParticle { + + 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, 1, false, false, false)); + world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 10, 1F, 0.02F, 1F, 0.01); + } else { + player.removePotionEffect(PotionEffectType.SLOW_FALLING); + } + }); + } + +} -- 2.39.5 From a0498ce7940fb1e1ade0347e7ba60c5b5abb6c6d Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 8 Jan 2021 15:58:43 +0100 Subject: [PATCH 05/11] Add CloudCircleParticle --- .../lobby/inventories/ParticleInventory.java | 13 +++-- .../lobby/particle/CircleParticle.java | 5 +- .../lobby/particle/CloudCircleParticle.java | 51 +++++++++++++++++++ .../lobby/particle/CloudParticle.java | 2 +- 4 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/CloudCircleParticle.java diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 68d735d..58a6d88 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -72,10 +72,11 @@ public class ParticleInventory { teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", lore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); teamParticles.add(new SimpleParticle(Material.FIRE_CHARGE, "§7Firework", lore, Particle.FIREWORKS_SPARK, 0.2F, 0.2F, 0.2F, 0.5)); teamParticles.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", lore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); - teamParticles.add(new CircleParticle(Material.RED_WOOL, "§cHerzen Ring", lore, Particle.HEART, location -> location.add(0, 2.2, 0))); + teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", lore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)); + teamParticles.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen Ring", lore, Particle.HEART, location -> location.add(0, 2.2, 0))); serverteamParticles.addAll(teamParticles); - serverteamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); serverteamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH)); serverteamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE)); serverteamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); @@ -83,10 +84,14 @@ public class ParticleInventory { serverteamParticles.add(new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01)); serverteamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); serverteamParticles.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", lore, Particle.CLOUD)); - serverteamParticles.add(new CloudParticle(Material.ENCHANTED_GOLDEN_APPLE, "§eZauber Cloud", lore, Particle.ENCHANTMENT_TABLE)); - serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§7Flammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); + serverteamParticles.add(new CloudParticle(Material.WHITE_DYE, "§eZauber Wolke", lore, Particle.ENCHANTMENT_TABLE)); + serverteamParticles.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen Wolke", lore, Particle.FLAME)); + serverteamParticles.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze Wolke", lore, Particle.SNEEZE)); + serverteamParticles.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim Wolke", lore, Particle.SLIME)); + serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, 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 Ring", lore, Particle.NOTE, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); + serverteamParticles.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic Ring Wolke", lore, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0))); playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); teamParticles.forEach(specialParticle -> teamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java index bca7529..0031103 100644 --- a/src/de/steamwar/lobby/particle/CircleParticle.java +++ b/src/de/steamwar/lobby/particle/CircleParticle.java @@ -30,6 +30,7 @@ import org.bukkit.util.Vector; import java.util.List; import java.util.function.Function; +import java.util.function.UnaryOperator; public class CircleParticle extends SpecialParticle { @@ -41,13 +42,13 @@ public class CircleParticle extends SpecialParticle { private float vz; private double time = 1; - public CircleParticle(Material material, String name, List lore, Particle particle, Function locationShift) { + public CircleParticle(Material material, String name, List lore, Particle particle, UnaryOperator locationShift) { super(material, name, lore); this.particle = particle; this.locationShift = locationShift; } - public CircleParticle(Material material, String name, List lore, Particle particle, Function locationShift, float vx, float vy, float vz, double time) { + public CircleParticle(Material material, String name, List lore, Particle particle, UnaryOperator locationShift, float vx, float vy, float vz, double time) { super(material, name, lore); this.particle = particle; this.locationShift = locationShift; diff --git a/src/de/steamwar/lobby/particle/CloudCircleParticle.java b/src/de/steamwar/lobby/particle/CloudCircleParticle.java new file mode 100644 index 0000000..5e1a668 --- /dev/null +++ b/src/de/steamwar/lobby/particle/CloudCircleParticle.java @@ -0,0 +1,51 @@ +/* + * + * 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.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +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, locationShift, 0.0F, 0.0F, 0.0F, 0.01); + } + + @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); + } + } + +} diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java index d5f3a82..7ebb689 100644 --- a/src/de/steamwar/lobby/particle/CloudParticle.java +++ b/src/de/steamwar/lobby/particle/CloudParticle.java @@ -33,7 +33,7 @@ public class CloudParticle extends FunctionalParticle { 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, 1, false, false, false)); + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 10, 1F, 0.02F, 1F, 0.01); } else { player.removePotionEffect(PotionEffectType.SLOW_FALLING); -- 2.39.5 From 19cf849bf7311394ab7f912c4010d1f1934f7fce Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 8 Jan 2021 21:28:02 +0100 Subject: [PATCH 06/11] Add DoubleCircleParticle Add CloudParticle Add more particles --- .../lobby/inventories/ParticleInventory.java | 18 ++++- .../lobby/particle/CloudParticle.java | 2 +- .../lobby/particle/DoubleCircleParticle.java | 76 +++++++++++++++++++ 3 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/DoubleCircleParticle.java diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 58a6d88..9a93be4 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -28,8 +28,6 @@ import de.steamwar.sql.UserGroup; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; import java.util.Arrays; @@ -70,7 +68,12 @@ public class ParticleInventory { teamParticles.add(new SimpleParticle(Material.INK_SAC, "§8Squid", lore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); teamParticles.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", lore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", lore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); - teamParticles.add(new SimpleParticle(Material.FIRE_CHARGE, "§7Firework", lore, Particle.FIREWORKS_SPARK, 0.2F, 0.2F, 0.2F, 0.5)); + teamParticles.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", lore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); + teamParticles.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", lore, (world, player, time) -> { + if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { + world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2); + } + })); teamParticles.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", lore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); teamParticles.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", lore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)); @@ -81,17 +84,24 @@ public class ParticleInventory { serverteamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE)); serverteamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); serverteamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); - serverteamParticles.add(new SimpleParticle(Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 0F, 0.2F, 0F, 0.01)); serverteamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); serverteamParticles.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", lore, Particle.CLOUD)); + serverteamParticles.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem Wolke", lore, Particle.TOTEM)); serverteamParticles.add(new CloudParticle(Material.WHITE_DYE, "§eZauber Wolke", lore, Particle.ENCHANTMENT_TABLE)); serverteamParticles.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen Wolke", lore, Particle.FLAME)); serverteamParticles.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze Wolke", lore, Particle.SNEEZE)); serverteamParticles.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim Wolke", lore, Particle.SLIME)); + serverteamParticles.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke Wolke", lore, Particle.CAMPFIRE_COSY_SMOKE)); + serverteamParticles.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town Wolke", lore, Particle.TOWN_AURA)); serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, 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 Ring", lore, 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 Double Ring", lore, 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 Double Ring", lore, 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 Ring Wolke", lore, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0))); + serverteamParticles.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen Ring Wolke", lore, Particle.FLAME, location -> location.add(0, 1.1, 0))); + serverteamParticles.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework Ring Wolke", lore, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0))); + serverteamParticles.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater Ring Wolke", lore, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0))); playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); teamParticles.forEach(specialParticle -> teamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java index 7ebb689..db2fd5d 100644 --- a/src/de/steamwar/lobby/particle/CloudParticle.java +++ b/src/de/steamwar/lobby/particle/CloudParticle.java @@ -34,7 +34,7 @@ public class CloudParticle extends FunctionalParticle { 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), 10, 1F, 0.02F, 1F, 0.01); + 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); } diff --git a/src/de/steamwar/lobby/particle/DoubleCircleParticle.java b/src/de/steamwar/lobby/particle/DoubleCircleParticle.java new file mode 100644 index 0000000..e88819a --- /dev/null +++ b/src/de/steamwar/lobby/particle/DoubleCircleParticle.java @@ -0,0 +1,76 @@ +/* + * + * 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); + } + } + +} -- 2.39.5 From 256e59be69e59636c20d96387eb021e91d38996b Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 9 Jan 2021 12:33:15 +0100 Subject: [PATCH 07/11] Add ParticleInventory.loreBuilder --- .../lobby/inventories/ParticleInventory.java | 121 +++++++++++------- 1 file changed, 72 insertions(+), 49 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 9a93be4..eba500b 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -30,7 +30,6 @@ import org.bukkit.Particle; import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class ParticleInventory { @@ -38,8 +37,6 @@ public class ParticleInventory { private ParticleInventory() { } - private static final List lore = Arrays.asList("§aKlicken zum Auswählen"); - private static final List playerParticles = new ArrayList<>(); private static final List teamParticles = new ArrayList<>(); private static final List serverteamParticles = new ArrayList<>(); @@ -49,59 +46,67 @@ public class ParticleInventory { private static final List> serverteamParticlesEntries = new ArrayList<>(); static { - playerParticles.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", lore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.COBWEB, "§7Smoke", lore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", lore, Particle.DRIP_LAVA)); - playerParticles.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", lore, Particle.DRIP_WATER)); - playerParticles.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", lore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5))); - playerParticles.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", lore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5))); - playerParticles.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", lore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", lore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)); - playerParticles.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01)); - playerParticles.add(new SimpleParticle(Material.CAULDRON, "§5Magie", lore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", lore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME)); - playerParticles.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB)); + List defaultLore = loreBuilder(null, null); + List teamLore = loreBuilder(null, "Team beitritt"); + List serverTeamLore = loreBuilder(null, "Serverteam"); + List serverTeamLore_C = loreBuilder(new String[]{"Wolke"}, "Serverteam"); + List serverTeamLore_R = loreBuilder(new String[]{"Ring"}, "Serverteam"); + List serverTeamLore_2R = loreBuilder(new String[]{"doppel Ring"}, "Serverteam"); + List serverTeamLore_CR = loreBuilder(new String[]{"Wolke", "Ring"}, "Serverteam"); + + playerParticles.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", defaultLore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.COBWEB, "§7Smoke", defaultLore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", defaultLore, Particle.DRIP_LAVA)); + playerParticles.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", defaultLore, Particle.DRIP_WATER)); + playerParticles.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5))); + playerParticles.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5))); + playerParticles.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", defaultLore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", defaultLore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", defaultLore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)); + playerParticles.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", defaultLore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01)); + playerParticles.add(new SimpleParticle(Material.CAULDRON, "§5Magie", defaultLore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", defaultLore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01)); + playerParticles.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", defaultLore, Particle.SLIME)); + playerParticles.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", defaultLore, Particle.SPELL_MOB)); teamParticles.addAll(playerParticles); - teamParticles.add(new SimpleParticle(Material.INK_SAC, "§8Squid", lore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", lore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", lore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); - teamParticles.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", lore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); - teamParticles.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", lore, (world, player, time) -> { + teamParticles.add(new SimpleParticle(Material.INK_SAC, "§8Squid", teamLore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", teamLore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); + teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); + teamParticles.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); + teamParticles.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> { if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2); } })); - teamParticles.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", lore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); - teamParticles.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", lore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)); - teamParticles.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen Ring", lore, Particle.HEART, location -> location.add(0, 2.2, 0))); + 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))); serverteamParticles.addAll(teamParticles); - serverteamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH)); - serverteamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", lore, Particle.ENCHANTMENT_TABLE)); - serverteamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); - serverteamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); - serverteamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); - serverteamParticles.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", lore, Particle.CLOUD)); - serverteamParticles.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem Wolke", lore, Particle.TOTEM)); - serverteamParticles.add(new CloudParticle(Material.WHITE_DYE, "§eZauber Wolke", lore, Particle.ENCHANTMENT_TABLE)); - serverteamParticles.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen Wolke", lore, Particle.FLAME)); - serverteamParticles.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze Wolke", lore, Particle.SNEEZE)); - serverteamParticles.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim Wolke", lore, Particle.SLIME)); - serverteamParticles.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke Wolke", lore, Particle.CAMPFIRE_COSY_SMOKE)); - serverteamParticles.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town Wolke", lore, Particle.TOWN_AURA)); - serverteamParticles.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen Ring", lore, Particle.FLAME, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); - serverteamParticles.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted Ring", lore, 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 Ring", lore, 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 Double Ring", lore, 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 Double Ring", lore, 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 Ring Wolke", lore, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0))); - serverteamParticles.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen Ring Wolke", lore, Particle.FLAME, location -> location.add(0, 1.1, 0))); - serverteamParticles.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework Ring Wolke", lore, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0))); - serverteamParticles.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater Ring Wolke", lore, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0))); + serverteamParticles.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH)); + serverteamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", serverTeamLore, Particle.ENCHANTMENT_TABLE)); + serverteamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", serverTeamLore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); + serverteamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", serverTeamLore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); + serverteamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", serverTeamLore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); + serverteamParticles.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", serverTeamLore_C, Particle.CLOUD)); + serverteamParticles.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem", serverTeamLore_C, Particle.TOTEM)); + serverteamParticles.add(new CloudParticle(Material.WHITE_DYE, "§eZauber", serverTeamLore_C, Particle.ENCHANTMENT_TABLE)); + serverteamParticles.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen", serverTeamLore_C, Particle.FLAME)); + serverteamParticles.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze", serverTeamLore_C, Particle.SNEEZE)); + 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 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))); + serverteamParticles.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater", serverTeamLore_CR, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0))); playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); teamParticles.forEach(specialParticle -> teamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); @@ -123,7 +128,7 @@ public class ParticleInventory { } else { particleSWListInv = new SWListInv<>(player, "§6Partikel", false, serverteamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } - particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", lore, false, clickType -> { + particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> { lobbyPlayer.setParticle(null); }); @@ -134,5 +139,23 @@ public class ParticleInventory { createInventory(player).open(); } + private static List loreBuilder(String[] attribute, String unlocked) { + List lore = new ArrayList<>(); + lore.add(""); + if (attribute != null && attribute.length > 0) { + lore.add("§eAttribute§7:"); + for (String s : attribute) { + lore.add("§7- §f" + s); + } + lore.add(""); + } + if (unlocked != null) { + lore.add("§eFreigeschaltet durch"); + lore.add("§f" + unlocked); + lore.add(""); + } + lore.add("§eKlicken zum auswählen"); + return lore; + } } -- 2.39.5 From 687f4985437afa4994a4221723fb632502f04e8e Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 23 Feb 2021 11:37:54 +0100 Subject: [PATCH 08/11] Simplify ParticleInventory --- .../lobby/inventories/ParticleInventory.java | 12 +-- .../lobby/listener/ParticleListener.java | 2 +- .../lobby/particle/CircleParticle.java | 19 ++++- .../lobby/particle/CloudCircleParticle.java | 12 +-- .../lobby/particle/CloudParticle.java | 23 +++--- .../lobby/particle/DoubleCircleParticle.java | 76 ------------------- .../lobby/particle/SpecialParticle.java | 17 ++++- 7 files changed, 55 insertions(+), 106 deletions(-) delete mode 100644 src/de/steamwar/lobby/particle/DoubleCircleParticle.java 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); } -- 2.39.5 From 4d5abbf8e189e022acd60b85fc3c0be5110079b4 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 23 Feb 2021 11:40:20 +0100 Subject: [PATCH 09/11] Fix Copyright notice --- src/de/steamwar/lobby/particle/CircleParticle.java | 1 - src/de/steamwar/lobby/particle/CloudCircleParticle.java | 1 - src/de/steamwar/lobby/particle/CloudParticle.java | 1 - src/de/steamwar/lobby/particle/FunctionalParticle.java | 1 - src/de/steamwar/lobby/particle/ParticleFunction.java | 1 - src/de/steamwar/lobby/particle/SimpleParticle.java | 1 - 6 files changed, 6 deletions(-) diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java index 5b7ff24..1c76092 100644 --- a/src/de/steamwar/lobby/particle/CircleParticle.java +++ b/src/de/steamwar/lobby/particle/CircleParticle.java @@ -16,7 +16,6 @@ * * 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; diff --git a/src/de/steamwar/lobby/particle/CloudCircleParticle.java b/src/de/steamwar/lobby/particle/CloudCircleParticle.java index 4d92f36..80f9ed7 100644 --- a/src/de/steamwar/lobby/particle/CloudCircleParticle.java +++ b/src/de/steamwar/lobby/particle/CloudCircleParticle.java @@ -16,7 +16,6 @@ * * 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; diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java index 58895ef..706c071 100644 --- a/src/de/steamwar/lobby/particle/CloudParticle.java +++ b/src/de/steamwar/lobby/particle/CloudParticle.java @@ -16,7 +16,6 @@ * * 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; diff --git a/src/de/steamwar/lobby/particle/FunctionalParticle.java b/src/de/steamwar/lobby/particle/FunctionalParticle.java index f2bc6dc..2e11da0 100644 --- a/src/de/steamwar/lobby/particle/FunctionalParticle.java +++ b/src/de/steamwar/lobby/particle/FunctionalParticle.java @@ -16,7 +16,6 @@ * * 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; diff --git a/src/de/steamwar/lobby/particle/ParticleFunction.java b/src/de/steamwar/lobby/particle/ParticleFunction.java index 1e62c03..ab210ec 100644 --- a/src/de/steamwar/lobby/particle/ParticleFunction.java +++ b/src/de/steamwar/lobby/particle/ParticleFunction.java @@ -16,7 +16,6 @@ * * 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; diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index 4695220..a138b58 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -16,7 +16,6 @@ * * 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; -- 2.39.5 From f64b60bb58eb873c97b7afd112ff01ece5c75741 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 23 Feb 2021 11:51:18 +0100 Subject: [PATCH 10/11] Fix Copyright notice --- src/de/steamwar/lobby/inventories/ParticleInventory.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 7719e91..cd3f7a8 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -75,7 +75,7 @@ public class ParticleInventory { teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); teamParticles.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); teamParticles.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> { - if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { + if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2); } })); @@ -123,6 +123,9 @@ public class ParticleInventory { if (steamwarUser.getTeam() != 0) { particleSWListInv = new SWListInv<>(player, "§6Partikel", false, teamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } else { + if (teamParticles.contains(lobbyPlayer.getParticle())) { + lobbyPlayer.setParticle(null); + } particleSWListInv = new SWListInv<>(player, "§6Partikel", false, playerParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } } else { -- 2.39.5 From b187221910fcb48feda89539cf17f82984973e0c Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 23 Feb 2021 17:40:08 +0100 Subject: [PATCH 11/11] Simplify ParticleInventory --- .../lobby/inventories/ParticleInventory.java | 122 +++++++++--------- .../lobby/particle/SimpleParticle.java | 5 - .../lobby/particle/SpecialParticle.java | 10 +- 3 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index cd3f7a8..569bad6 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -37,13 +37,13 @@ public class ParticleInventory { private ParticleInventory() { } - private static final List playerParticles = new ArrayList<>(); - private static final List teamParticles = new ArrayList<>(); - private static final List serverteamParticles = new ArrayList<>(); + private static final List PLAYER_PARTICLES = new ArrayList<>(); + private static final List TEAM_PARTICLES = new ArrayList<>(); + private static final List SERVERTEAM_PARTICLES = new ArrayList<>(); - private static final List> playerParticlesEntries = new ArrayList<>(); - private static final List> teamParticlesEntries = new ArrayList<>(); - private static final List> serverteamParticlesEntries = new ArrayList<>(); + private static final List> PLAYER_PARTICLES_ENTRIES = new ArrayList<>(); + private static final List> TEAM_PARTICLES_ENTRIES = new ArrayList<>(); + private static final List> SERVERTEAM_PARTICLES_ENTRIES = new ArrayList<>(); static { List defaultLore = loreBuilder(null, null); @@ -54,63 +54,65 @@ public class ParticleInventory { List serverTeamLore_2R = loreBuilder(new String[]{"doppel Ring"}, "Serverteam"); List serverTeamLore_CR = loreBuilder(new String[]{"Wolke", "Ring"}, "Serverteam"); - playerParticles.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", defaultLore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.COBWEB, "§7Smoke", defaultLore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", defaultLore, Particle.DRIP_LAVA)); - playerParticles.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", defaultLore, Particle.DRIP_WATER)); - playerParticles.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5))); - playerParticles.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5))); - playerParticles.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", defaultLore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", defaultLore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.GLASS_BOTTLE, "§5Effekt", defaultLore, Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)); - playerParticles.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", defaultLore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01)); - playerParticles.add(new SimpleParticle(Material.CAULDRON, "§5Magie", defaultLore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", defaultLore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01)); - playerParticles.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", defaultLore, Particle.SLIME)); - playerParticles.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", defaultLore, Particle.SPELL_MOB)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", defaultLore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.COBWEB, "§7Smoke", defaultLore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", defaultLore, Particle.DRIP_LAVA)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", defaultLore, Particle.DRIP_WATER)); + PLAYER_PARTICLES.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5))); + PLAYER_PARTICLES.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5))); + PLAYER_PARTICLES.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", defaultLore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", defaultLore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01)); + PLAYER_PARTICLES.add(new FunctionalParticle(Material.GLASS_BOTTLE, "§5Effekt", defaultLore, (world, player, time) -> { + world.spawnParticle(Particle.REDSTONE, player.getLocation().add(0.0, 0.2, 0.0), 5, 0F, 0.2F, 0F, 0.01, SpecialParticle.getParticleDust()); + })); + PLAYER_PARTICLES.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", defaultLore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.CAULDRON, "§5Magie", defaultLore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", defaultLore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", defaultLore, Particle.SLIME)); + PLAYER_PARTICLES.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", defaultLore, Particle.SPELL_MOB)); - teamParticles.addAll(playerParticles); - teamParticles.add(new SimpleParticle(Material.INK_SAC, "§8Squid", teamLore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", teamLore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); - teamParticles.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); - teamParticles.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); - teamParticles.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> { + TEAM_PARTICLES.addAll(PLAYER_PARTICLES); + TEAM_PARTICLES.add(new SimpleParticle(Material.INK_SAC, "§8Squid", teamLore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); + TEAM_PARTICLES.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", teamLore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); + TEAM_PARTICLES.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); + TEAM_PARTICLES.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); + TEAM_PARTICLES.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> { if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2); } })); - 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, null, location -> location.add(0, 2.2, 0))); + TEAM_PARTICLES.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", teamLore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); + TEAM_PARTICLES.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", teamLore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); + TEAM_PARTICLES.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", teamLore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)); + TEAM_PARTICLES.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)); - serverteamParticles.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", serverTeamLore, Particle.ENCHANTMENT_TABLE)); - serverteamParticles.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", serverTeamLore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); - serverteamParticles.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", serverTeamLore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); - serverteamParticles.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", serverTeamLore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); - serverteamParticles.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", serverTeamLore_C, Particle.CLOUD)); - serverteamParticles.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem", serverTeamLore_C, Particle.TOTEM)); - serverteamParticles.add(new CloudParticle(Material.WHITE_DYE, "§eZauber", serverTeamLore_C, Particle.ENCHANTMENT_TABLE)); - serverteamParticles.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen", serverTeamLore_C, Particle.FLAME)); - serverteamParticles.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze", serverTeamLore_C, Particle.SNEEZE)); - 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, 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))); - serverteamParticles.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater", serverTeamLore_CR, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0))); + SERVERTEAM_PARTICLES.addAll(TEAM_PARTICLES); + SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH)); + SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", serverTeamLore, Particle.ENCHANTMENT_TABLE)); + SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", serverTeamLore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); + SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", serverTeamLore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); + SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", serverTeamLore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", serverTeamLore_C, Particle.CLOUD)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem", serverTeamLore_C, Particle.TOTEM)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_DYE, "§eZauber", serverTeamLore_C, Particle.ENCHANTMENT_TABLE)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen", serverTeamLore_C, Particle.FLAME)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze", serverTeamLore_C, Particle.SNEEZE)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim", serverTeamLore_C, Particle.SLIME)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke", serverTeamLore_C, Particle.CAMPFIRE_COSY_SMOKE)); + SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town", serverTeamLore_C, Particle.TOWN_AURA)); + SERVERTEAM_PARTICLES.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)); + SERVERTEAM_PARTICLES.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)); + SERVERTEAM_PARTICLES.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)); + SERVERTEAM_PARTICLES.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)); + SERVERTEAM_PARTICLES.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)); + SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic", serverTeamLore_CR, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0))); + SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen", serverTeamLore_CR, Particle.FLAME, location -> location.add(0, 1.1, 0))); + SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework", serverTeamLore_CR, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0))); + SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater", serverTeamLore_CR, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0))); - playerParticles.forEach(specialParticle -> playerParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); - teamParticles.forEach(specialParticle -> teamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); - serverteamParticles.forEach(specialParticle -> serverteamParticlesEntries.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); + PLAYER_PARTICLES.forEach(specialParticle -> PLAYER_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); + TEAM_PARTICLES.forEach(specialParticle -> TEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); + SERVERTEAM_PARTICLES.forEach(specialParticle -> SERVERTEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); } private static SWInventory createInventory(Player player) { @@ -121,15 +123,15 @@ public class ParticleInventory { SWListInv particleSWListInv; if (userGroup == UserGroup.Member) { if (steamwarUser.getTeam() != 0) { - particleSWListInv = new SWListInv<>(player, "§6Partikel", false, teamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, TEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } else { - if (teamParticles.contains(lobbyPlayer.getParticle())) { + if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) { lobbyPlayer.setParticle(null); } - particleSWListInv = new SWListInv<>(player, "§6Partikel", false, playerParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, PLAYER_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } } else { - particleSWListInv = new SWListInv<>(player, "§6Partikel", false, serverteamParticlesEntries, (clickType, particle) -> lobbyPlayer.setParticle(particle)); + particleSWListInv = new SWListInv<>(player, "§6Partikel", false, SERVERTEAM_PARTICLES_ENTRIES, (clickType, particle) -> lobbyPlayer.setParticle(particle)); } particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> { lobbyPlayer.setParticle(null); diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index a138b58..52c0b1d 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -52,11 +52,6 @@ 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 (particle == Particle.REDSTONE) { - world.spawnParticle(particle, location, 5, getParticleDust()); - return; - } - if (customVelocity) { world.spawnParticle(particle, location, 5, vx, vy, vz, time); } else { diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java index 0d99b84..6ba8e21 100644 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ b/src/de/steamwar/lobby/particle/SpecialParticle.java @@ -34,18 +34,18 @@ import java.util.Random; public abstract class SpecialParticle { - private static final List emptyLore = new ArrayList<>(); + private static final List EMPTY_LORE = new ArrayList<>(); private static Random random = new Random(); - protected static Color randomColor() { + public static Color randomColor() { return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)); } - protected static float randomSize() { + public static float randomSize() { return random.nextFloat() / 2 + 1; } - protected static Particle.DustOptions getParticleDust() { + public static Particle.DustOptions getParticleDust() { return new Particle.DustOptions(randomColor(), randomSize()); } @@ -56,7 +56,7 @@ public abstract class SpecialParticle { protected SpecialParticle(Material material, String name, List lore) { if (lore == null) { - lore = emptyLore; + lore = EMPTY_LORE; } this.material = material; this.name = name; -- 2.39.5