From e6852d92f28f32cd048529042032a0d7e0b44445 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 29 Apr 2017 13:24:27 -0300 Subject: [PATCH] Fixed item, spawn particles even if player is moving --- .../gadgets/particle/king/CastleManager.java | 20 +++++++++++-------- .../gadgets/particle/king/ParticleKing.java | 11 +++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java index b50a5e864..c93477763 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java @@ -7,7 +7,6 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -19,10 +18,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import org.spigotmc.event.entity.EntityDismountEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -129,6 +128,9 @@ public class CastleManager extends MiniPlugin if (event.getEntity() instanceof Player) return; + if (event.getEntity() instanceof Item) + return; + if (UtilAlg.inBoundingBox(event.getLocation(), _castleLocationA, _castleLocationB)) { event.setCancelled(true); @@ -264,13 +266,15 @@ public class CastleManager extends MiniPlugin if (!isThrone) return; - Location loc = _throneLocations[0].clone().add(0.5, 0, 0.5); + Location loc = _throneLocations[0].clone().add(0.5, 0.75, 0.5); loc.setYaw(90); loc.setPitch(0); - Item item = loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.WOOL, 1, (byte) 14)); + Item item = loc.getWorld().dropItem(loc, new ItemStack(Material.WOOL, 1, (byte) 14)); item.setPickupDelay(Integer.MAX_VALUE); - item.setVelocity(new Vector().zero()); + item.teleport(loc); + item.setVelocity(new Vector(0, 0, 0)); item.setPassenger(player); + _item = item; } /** @@ -278,15 +282,15 @@ public class CastleManager extends MiniPlugin * @param event */ @EventHandler - public void onLeaveThrone(VehicleExitEvent event) + public void onLeaveThrone(EntityDismountEvent event) { - if (!(event.getVehicle() instanceof ArmorStand)) + if (!(event.getEntity() instanceof Item)) return; if (_item == null) return; - if (!event.getVehicle().equals(_item)) + if (!event.getEntity().equals(_item)) return; _item.remove(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/ParticleKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/ParticleKing.java index b2de2e217..7da074849 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/ParticleKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/ParticleKing.java @@ -46,7 +46,6 @@ public class ParticleKing extends ParticleGadget @Override public void playParticle(Player player, UpdateEvent event) { - Location loc = player.getLocation().add(0, 0.8, 0).add(player.getLocation().getDirection().multiply(-0.3)); if (Manager.isMoving(player)) { @@ -55,14 +54,15 @@ public class ParticleKing extends ParticleGadget _capeRed.displayColoredParticle(loc, Color.RED); _capeWhite.displayColoredParticle(loc, Color.WHITE); } - return; } - - if (event.getType() == UpdateType.FAST) + else if (event.getType() == UpdateType.FAST) { _capeRed.displayColored(loc, Color.RED); _capeWhite.displayColored(loc, Color.WHITE); - for (int i = 0; i < 360; i += 360/CROWN_POINTS) + } + if (event.getType() == UpdateType.FAST) + { + for (int i = 0; i < 360; i += 360 / CROWN_POINTS) { double angle = (i * Math.PI / 180); double x = 0.5 * Math.cos(angle); @@ -71,7 +71,6 @@ public class ParticleKing extends ParticleGadget UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.FLAME, crown, null, 0, 1, UtilParticle.ViewDist.NORMAL); } } - } @Override