From 5faa4765549f6f2c5b70e91f10da75bf793aed77 Mon Sep 17 00:00:00 2001 From: VictorD Date: Wed, 29 Dec 2010 01:19:19 +0100 Subject: [PATCH] Updated PLAYER_MOVE hook to deal correctly with a cancelled event. --- src/net/minecraft/server/EntityPlayerMP.java | 23 ++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/net/minecraft/server/EntityPlayerMP.java b/src/net/minecraft/server/EntityPlayerMP.java index af81a0c53f..86dd1eafd1 100644 --- a/src/net/minecraft/server/EntityPlayerMP.java +++ b/src/net/minecraft/server/EntityPlayerMP.java @@ -62,23 +62,24 @@ public class EntityPlayerMP extends EntityPlayer } /** - * Craftbukkit: Overloaded version of b(double,double,double,float) + * Craftbukkit: Overloaded version of b(double,double,double,float, float) * * Enables monitoring of PLAYER_MOVE events. */ public void b(double x, double y, double z, float rotation, float pitch) { - super.b(x,y,z,pitch,rotation); - - // Only send an event if player position has changed. - if (x == oldLocation.getX() && y == oldLocation.getY() && z == oldLocation.getZ()) - return; - Location newLocation = new Location(server.getWorld(b.e),x,y,z); - PlayerMoveEvent pm = new PlayerMoveEvent(Event.Type.PLAYER_MOVE, server.getPlayer(this), - oldLocation, newLocation); - - server.getPluginManager().callEvent(pm); + + // Only send an event if player position has changed. + if (x != oldLocation.getX() || y != oldLocation.getY() || z != oldLocation.getZ()) { + PlayerMoveEvent pm = new PlayerMoveEvent(Event.Type.PLAYER_MOVE, server.getPlayer(this), + oldLocation, newLocation); + + server.getPluginManager().callEvent(pm); + if (pm.isCancelled()) + newLocation = pm.getFrom(); + } oldLocation = newLocation; + super.b(newLocation.getX(),newLocation.getY(),newLocation.getZ(),rotation, pitch); } public void k() {