diff options
author | EvilSeph <evilseph@unaligned.org> | 2011-06-17 19:19:11 -0400 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-06-17 19:22:57 -0400 |
commit | b92f54639a241210af1ec74f9a6d6226636f7e83 (patch) | |
tree | adb9774c8fb85666c1cbce0a834e08797bed3b1f /src/main/java | |
parent | f3d25e647f8ffc256fc26cdd0fa2b2843702555a (diff) | |
download | craftbukkit-b92f54639a241210af1ec74f9a6d6226636f7e83.tar craftbukkit-b92f54639a241210af1ec74f9a6d6226636f7e83.tar.gz craftbukkit-b92f54639a241210af1ec74f9a6d6226636f7e83.tar.lz craftbukkit-b92f54639a241210af1ec74f9a6d6226636f7e83.tar.xz craftbukkit-b92f54639a241210af1ec74f9a6d6226636f7e83.zip |
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.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 14 |
1 files 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 052a2b80..c5b2b9c4 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(); |