From a3d7376d546555673548beed5cbf49b9372f01a4 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 15 Nov 2020 08:41:29 +0100 Subject: [PATCH] Simplify PlayerSeatListener --- .../spectatesystem/listener/PlayerSeatListener.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java index 35389fb..0e84497 100644 --- a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java +++ b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java @@ -50,12 +50,11 @@ public class PlayerSeatListener extends BasicListener { if(event.getPlayer().isInsideVehicle()) event.getPlayer().getVehicle().remove(); - - Location location = event.getClickedBlock().getLocation(); - if (location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ()).getType() != Material.AIR) + + if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR) return; - Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARROW); + Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(event.getClickedBlock().getLocation().add(0.5, 0, 0.5), EntityType.ARROW); arrow.setGravity(false); arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); arrow.addPassenger(event.getPlayer());