当前位置: 首页>>代码示例>>Java>>正文


Java PlayerMoveEvent.setFrom方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:40,代码来源:PlayerMovementListener.java


注:本文中的org.bukkit.event.player.PlayerMoveEvent.setFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。