From 38e59848f055d54ca474f7565daaaedac59c89be Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 2 Nov 2020 16:19:35 +0100 Subject: [PATCH] Add Seat Change --- .../spectatesystem/listener/PlayerSeatListener.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java index 65f67c8..e6d107e 100644 --- a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java +++ b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java @@ -41,11 +41,13 @@ public class PlayerSeatListener extends BasicListener { if(event.getPlayer().getGameMode() != GameMode.ADVENTURE) return; + if(event.getPlayer().isInsideVehicle()) + event.getPlayer().getVehicle().remove(); + Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(event.getClickedBlock().getLocation().add(0.5, 0, 0.5), EntityType.ARROW); arrow.setGravity(false); - arrow.addScoreboardTag(event.getPlayer().getUniqueId().toString()); arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); - arrow.setPassenger(event.getPlayer()); + arrow.addPassenger(event.getPlayer()); } @EventHandler @@ -56,9 +58,6 @@ public class PlayerSeatListener extends BasicListener { if(event.getEntityType() != EntityType.PLAYER) return; - event.getEntity().getWorld().getEntitiesByClasses(Arrow.class).forEach(entity -> { - if(entity.getScoreboardTags().contains(event.getEntity().getUniqueId().toString())) - entity.remove(); - }); + event.getDismounted().remove(); } }