From 87e3056e252c51a2e8330ea3deddf8e578ae7f50 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 16 Aug 2020 09:28:23 +0200 Subject: [PATCH] Fix Non Working Particle --- .../lobby/inventories/ParticleInventory.java | 2 +- .../steamwar/lobby/listener/ParticleListener.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 61fdb91..040ae9b 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -40,7 +40,7 @@ public class ParticleInventory { add(swInventory, Material.GLASS_BOTTLE, "§5Effekt", lore, Particle.SPELL, 20, player, lobbyPlayer); 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.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); if (userGroup == UserGroup.Member) { diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 3a7c18e..65cecbd 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -3,6 +3,7 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.inventories.ParticleInventory; import de.steamwar.lobby.utils.LobbyPlayer; +import org.bukkit.Color; import org.bukkit.Particle; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -11,8 +12,12 @@ 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(); + @EventHandler(priority = EventPriority.NORMAL) public void handlePlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); @@ -29,10 +34,16 @@ public class ParticleListener implements Listener { Particle particle = lobbyPlayer.getParticle(); if (particle == null) return; + if (particle == Particle.SPELL) { + 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(lobbyPlayer.getParticle(), player.getLocation().add(0.0D, 0.2D, 0.0D), 5, lobbyPlayer.getParticle_vx(), lobbyPlayer.getParticle_vy(), lobbyPlayer.getParticle_vz(), lobbyPlayer.getParticle_time()); + 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(lobbyPlayer.getParticle(), player.getLocation().add(0.0D, 0.2D, 0.0D), 5); + player.getWorld().spawnParticle(particle, player.getLocation().add(0.0D, 0.2D, 0.0D), 5); } }