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.
This commit is contained in:
EvilSeph 2011-06-17 19:19:11 -04:00
parent f3d25e647f
commit b92f54639a

View File

@ -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();