本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent.setFrom方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent.setFrom方法的具体用法?Java PlayerMoveEvent.setFrom怎么用?Java PlayerMoveEvent.setFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerMoveEvent
的用法示例。
在下文中一共展示了PlayerMoveEvent.setFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMovementHigh
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
private final void handleMovementHigh(final PlayerMoveEvent event) {
Player player = event.getPlayer();
EntityLocation originalFrom = event.getEntityFrom();
EntityLocation originalTo = event.getEntityTo();
EntityLocation oldTo = this.lastToLocation.get(player);
if(oldTo != null && !oldTo.equals(originalFrom)) {
// If this movement does not start where the last known movement ended,
// we have to make up the missing movement. We do that by (potentially) firing
// two coarse events for this one event, a "fake" one for the missing movement
// and a "real" one for the current movement.
// First, modify this event to look like the missing event, and fire
// a coarse event that wraps it.
event.setFrom(oldTo);
event.setTo(originalFrom);
this.updateLastToLocation(event);
if(this.callCoarsePlayerMove(event)) {
// If the fake coarse event was cancelled, we don't need to fire
// the real one, so just return. Note that the wrapped event won't
// actually be cancelled, rather its to location will be modified
// to return the player to the oldTo location. Also note that if
// the original event was already cancelled before the coarse event
// fired, then we will never get here, and both the fake and real
// events will go through.
this.updateLastToLocation(event);
return;
}
// Restore the event to its real state
event.setFrom(originalFrom);
event.setTo(originalTo);
}
this.updateLastToLocation(event);
if(this.callCoarsePlayerMove(event)) {
this.updateLastToLocation(event);
}
}