diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java index 33d18fe9c..020e5036e 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java @@ -8,7 +8,10 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; @@ -16,6 +19,7 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.vehicle.VehicleMoveEvent; import java.util.Set; @@ -80,6 +84,22 @@ private void onPlayerMove(PlayerMoveEvent event) { } } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + private void onVehicleMove(VehicleMoveEvent event) { + Vehicle vehicle = event.getVehicle(); + if (LocationUtil.isNetherCeiling(vehicle.getLocation())) { + // Teleport any players riding the vehicle + for (Entity entity : vehicle.getPassengers()) { + if (entity.getType() == EntityType.PLAYER) { + this.teleportFromCeiling((Player) entity); + } else { + entity.remove(); // Remove non-player passenger + } + } + vehicle.remove(); // Remove vehicle + } + } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) private void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java index c302b75aa..1aa11e836 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/preventions/NetherRoof.java @@ -9,13 +9,17 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.vehicle.VehicleMoveEvent; import java.util.Arrays; @@ -67,6 +71,22 @@ private void onTeleport(PlayerTeleportEvent event) { } } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + private void onVehicleMove(VehicleMoveEvent event) { + Vehicle vehicle = event.getVehicle(); + if (LocationUtil.isNetherCeiling(vehicle.getLocation())) { + // Teleport any players riding the vehicle + for (Entity entity : vehicle.getPassengers()) { + if (entity.getType() == EntityType.PLAYER) { + this.teleportFromCeiling((Player) entity); + } else { + entity.remove(); // Remove non-player passenger + } + } + vehicle.remove(); // Remove vehicle + } + } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) private void onPlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); @@ -93,12 +113,13 @@ private void onBlockPlace(BlockPlaceEvent event) { } private void teleportFromCeiling(Player player) { - final Location teleportDestination = player.getLocation().clone().subtract(0.5, 7, 0.5); - player.teleport(teleportDestination); if (player.isInsideVehicle()) player.leaveVehicle(); if (player.isGliding()) player.setGliding(false); - if (!safe_teleport_enabled) return; + final Location teleportDestination = player.getLocation().clone().subtract(0.5, 7, 0.5); + player.teleport(teleportDestination); + + if (!safe_teleport_enabled) return; // Check block above for liquid or falling block Block blockAboveHead = teleportDestination.clone().add(0,2,0).getBlock(); if (blockAboveHead.isLiquid() || blockAboveHead.getType().hasGravity())