From b92f54639a241210af1ec74f9a6d6226636f7e83 Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Fri, 17 Jun 2011 19:19:11 -0400 Subject: [PATCH] Added recommended work-around for handling player movement in such a way that it doesn't trigger the movement speed check. Thanks for the help Rigby! Plugins are advised to no longer teleport players in the PlayerMove event and to use setTo instead, as we now trigger a teleport when setTo is used. --- .../net/minecraft/server/NetServerHandler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 052a2b80b1..c5b2b9c46b 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -139,8 +139,18 @@ public class NetServerHandler extends NetHandler implements ICommandListener { server.getPluginManager().callEvent(event); - from = event.getFrom(); - to = event.isCancelled() ? from : event.getTo(); + // If the event is cancelled we move the player back to their old location. + if (event.isCancelled()) { + to = from; + } + + /* If a Plugin has changed the To destination then we teleport the Player + there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. + We only do this if the Event was not cancelled. */ + if (!to.equals(event.getTo()) && !event.isCancelled()) { + ((CraftPlayer) this.player.getBukkitEntity()).teleport(event.getTo()); + return; + } this.player.locX = to.getX(); this.player.locY = to.getY();