From 9922f0b59584c86f8318efe9ccbe1032278bb639 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 11:17:56 +0100 Subject: [PATCH] Fix PlayerSeatListener --- src/de/steamwar/lobby/listener/PlayerSeatListener.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/lobby/listener/PlayerSeatListener.java b/src/de/steamwar/lobby/listener/PlayerSeatListener.java index 4dda9fa..10d8528 100644 --- a/src/de/steamwar/lobby/listener/PlayerSeatListener.java +++ b/src/de/steamwar/lobby/listener/PlayerSeatListener.java @@ -25,6 +25,7 @@ import org.bukkit.block.data.Bisected; import org.bukkit.block.data.type.Stairs; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; @@ -70,7 +71,7 @@ public class PlayerSeatListener extends BasicListener{ if (((Stairs) event.getClickedBlock().getBlockData()).getShape() != Stairs.Shape.STRAIGHT) return; - if (event.getPlayer().isInsideVehicle()) + if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle())) event.getPlayer().getVehicle().remove(); if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR) @@ -93,7 +94,7 @@ public class PlayerSeatListener extends BasicListener{ public void onEntityDismount(EntityDismountEvent event) { seats.remove(getSeatLocation(event.getDismounted().getLocation())); - if (event.getEntityType() != EntityType.PLAYER && event.getDismounted().getType() != EntityType.ARROW) + if (event.getEntityType() != EntityType.PLAYER && !isArrow(event.getDismounted())) return; event.getDismounted().remove(); @@ -101,7 +102,7 @@ public class PlayerSeatListener extends BasicListener{ @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - if (event.getPlayer().isInsideVehicle() && event.getPlayer().getVehicle().getType() == EntityType.ARROW) + if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle())) event.getPlayer().getVehicle().remove(); } @@ -109,4 +110,7 @@ public class PlayerSeatListener extends BasicListener{ return new Location(world,location.getBlockX(), location.getBlockY(), location.getBlockZ()); } + private boolean isArrow(Entity entity) { + return entity.getType() == EntityType.ARROW; + } }