From f9966c3377983cb21158f067bb637f66ca11ad97 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 14 Nov 2020 20:32:47 +0100 Subject: [PATCH 1/3] Fix Seat problem --- .../spectatesystem/listener/PlayerSeatListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java index 8b9183d..212e1a4 100644 --- a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java +++ b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java @@ -20,6 +20,8 @@ package de.steamwar.spectatesystem.listener; import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.data.Bisected; import org.bukkit.block.data.type.Stairs; import org.bukkit.entity.AbstractArrow; @@ -49,7 +51,11 @@ public class PlayerSeatListener extends BasicListener { 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); + Location location = event.getClickedBlock().getLocation(); + if (location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ()).getType() == Material.AIR) + return; + + Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARROW); arrow.setGravity(false); arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); arrow.addPassenger(event.getPlayer()); From be105ac77055efaf4917e93ac34077961203c820 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 15 Nov 2020 08:40:01 +0100 Subject: [PATCH 2/3] Fix Air Problem --- src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java index 212e1a4..35389fb 100644 --- a/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java +++ b/src/de/steamwar/spectatesystem/listener/PlayerSeatListener.java @@ -52,7 +52,7 @@ public class PlayerSeatListener extends BasicListener { event.getPlayer().getVehicle().remove(); Location location = event.getClickedBlock().getLocation(); - if (location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ()).getType() == Material.AIR) + if (location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ()).getType() != Material.AIR) return; Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARROW); From a3d7376d546555673548beed5cbf49b9372f01a4 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 15 Nov 2020 08:41:29 +0100 Subject: [PATCH 3/3] 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());