From 4324d4fe74d7ca527a42c34fb231698d385e5383 Mon Sep 17 00:00:00 2001 From: asofold Date: Sat, 26 Jan 2013 07:42:56 +0100 Subject: [PATCH] [Bleeding] Lessen trouble with boats. --- .../checks/moving/MovingListener.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index 88589b09..16a04d97 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -36,6 +36,8 @@ import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.event.vehicle.VehicleDestroyEvent; +import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.util.Vector; @@ -1042,6 +1044,39 @@ public class MovingListener extends CheckListener implements TickListener, IRemo noFall.onLeave(player); } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onVehicleExit(final VehicleExitEvent event){ + final Entity entity = event.getExited(); + if (!(entity instanceof Player)) return; + onPlayerVehicleLeave((Player) entity); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onVehicleDestroy(final VehicleDestroyEvent event){ + final Entity entity = event.getVehicle().getPassenger(); + if (!(entity instanceof Player)) return; + onPlayerVehicleLeave((Player) entity); + } + + private final void onPlayerVehicleLeave(final Player player){ + final MovingData data = MovingData.getData(player); +// if (data.morePacketsVehicleTaskId != -1){ +// // Await set-back. +// // TODO: might still set ordinary set-backs ? +// return; +// } + // Reset survivalfly set-back to prevent the worst damage. + final Location loc = player.getLocation(); + if (BlockProperties.isLiquid(loc.getBlock().getTypeId())){ + loc.setY(Location.locToBlock(loc.getY()) + 1.25); + } + data.resetPositions(loc); + data.setSetBack(loc); + // Experiment: add some horizontal velocity (fake). + data.horizontalVelocityCounter = 4; + data.horizontalFreedom = 0.6; + } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerKick(final PlayerKickEvent event){