return;
}
// call move event if movement actually occurred and there are handlers registered
if (!oldLocation.equals(newLocation) && PlayerMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
final PlayerMoveEvent event = EventFactory.callEvent(new PlayerMoveEvent(session.getPlayer(), oldLocation, newLocation));
if (event.isCancelled()) {
// tell client they're back where they started
session.send(new PositionRotationMessage(oldLocation));
return;
}
if (!event.getTo().equals(newLocation)) {
// teleport to the set destination: fires PlayerTeleportEvent and
// handles if the destination is in another world
session.getPlayer().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN);
return;
}
}
// move event was not fired or did nothing, simply update location