From d5ad2b7e732bd11fe11bc4c718874a20d7e00222 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 16 Aug 2020 08:36:28 +0200 Subject: [PATCH 1/2] Fix Particle Exception --- src/de/steamwar/lobby/inventories/ParticleInventory.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index fd6ab8e..1e2e7f0 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -39,16 +39,18 @@ 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); - add(swInventory, Material.APPLE, "§8Item", lore, Particle.ITEM_CRACK, 22, player, lobbyPlayer); + add(swInventory, Material.IRON_SWORD, "§8Angriff", lore, Particle.SWEEP_ATTACK, 22, player, lobbyPlayer); add(swInventory, Material.INK_SAC, "§8Tintenfisch", lore, Particle.SQUID_INK, 23, player, lobbyPlayer); add(swInventory, Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME, 24, player, lobbyPlayer); + // CAMPFIRE_COSY_SMOKE, SQUID_INK, TOTEM, FLAME + if (userGroup == UserGroup.Member) { add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer); } else { 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.TUBE_CORAL_FAN, "§bLuftblasen", lore, Particle.BUBBLE_COLUMN_UP, 31, player, lobbyPlayer); + add(swInventory, Material.EMERALD_BLOCK, "§2Freude", lore, Particle.VILLAGER_HAPPY, 31, player, lobbyPlayer); add(swInventory, Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 32, player, lobbyPlayer); add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyPlayer); -- 2.39.5 From 577b330fbd65d01023bc4eb7c2cde8fe9785a538 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 16 Aug 2020 08:46:51 +0200 Subject: [PATCH 2/2] Fix Non Working Particle --- .../lobby/inventories/ParticleInventory.java | 18 ++++++++++++------ .../lobby/listener/ParticleListener.java | 10 ++++++++-- src/de/steamwar/lobby/utils/LobbyPlayer.java | 11 +++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 1e2e7f0..6b39f0f 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -38,21 +38,19 @@ public class ParticleInventory { add(swInventory, Material.NOTE_BLOCK, "§eNoten", lore, Particle.NOTE, 15, player, lobbyPlayer); 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); + add(swInventory, Material.CAMPFIRE, "§7Rauch", lore, Particle.CAMPFIRE_COSY_SMOKE, 21, player, lobbyPlayer, true); add(swInventory, Material.IRON_SWORD, "§8Angriff", lore, Particle.SWEEP_ATTACK, 22, player, lobbyPlayer); - add(swInventory, Material.INK_SAC, "§8Tintenfisch", lore, Particle.SQUID_INK, 23, player, lobbyPlayer); + add(swInventory, Material.INK_SAC, "§8Tintenfisch", lore, Particle.SQUID_INK, 23, player, lobbyPlayer, true); add(swInventory, Material.SLIME_BALL, "§aSchleim", lore, Particle.SLIME, 24, player, lobbyPlayer); - // CAMPFIRE_COSY_SMOKE, SQUID_INK, TOTEM, FLAME - if (userGroup == UserGroup.Member) { add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer); } else { 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); - add(swInventory, Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 32, player, lobbyPlayer); - add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyPlayer); + add(swInventory, Material.FLINT_AND_STEEL, "§7Flammen", lore, Particle.FLAME, 32, player, lobbyPlayer, true); + add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyPlayer, true); add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 40, player, lobbyPlayer); } @@ -60,6 +58,14 @@ public class ParticleInventory { return swInventory; } + private static void add(SWInventory swInventory, Material material, String name, List lore, Particle particle, int slot, Player player, LobbyPlayer lobbyPlayer, boolean removeVelocity) { + SWItem swItem = new SWItem(material, name, lore, false, clickType -> { + lobbyPlayer.setParticle(particle, removeVelocity); + 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); diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 8f9aaac..b1b8fc5 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.Particle; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -25,9 +26,14 @@ public class ParticleListener implements Listener { public void handlePlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - if(lobbyPlayer.getParticle() == null) return; + Particle particle = lobbyPlayer.getParticle(); + if (particle == null) return; - player.getWorld().spawnParticle(lobbyPlayer.getParticle(), player.getLocation().add(0.0D, 0.2D, 0.0D), 5); + if (lobbyPlayer.isRemoveVelocity()) { + player.getWorld().spawnParticle(lobbyPlayer.getParticle(), player.getLocation().add(0.0D, 0.2D, 0.0D), 5, 0F, 0F, 0F); + } else { + player.getWorld().spawnParticle(lobbyPlayer.getParticle(), player.getLocation().add(0.0D, 0.2D, 0.0D), 5); + } } diff --git a/src/de/steamwar/lobby/utils/LobbyPlayer.java b/src/de/steamwar/lobby/utils/LobbyPlayer.java index fe678a4..31cf593 100644 --- a/src/de/steamwar/lobby/utils/LobbyPlayer.java +++ b/src/de/steamwar/lobby/utils/LobbyPlayer.java @@ -10,6 +10,7 @@ public class LobbyPlayer { private PlayerHiderState hiderState; private Particle particle; + private boolean removeVelocity = false; private boolean enderPearlUsed; private LobbyPlayer(UUID uuid) { @@ -29,8 +30,18 @@ public class LobbyPlayer { return particle; } + public boolean isRemoveVelocity() { + return removeVelocity; + } + public void setParticle(Particle particle) { this.particle = particle; + this.removeVelocity = false; + } + + public void setParticle(Particle particle, boolean removeVelocity) { + this.particle = particle; + this.removeVelocity = removeVelocity; } public boolean isEnderPearlUsed() { -- 2.39.5