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


Java PlayerMoveEvent.isCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent.isCancelled方法的具体用法?Java PlayerMoveEvent.isCancelled怎么用?Java PlayerMoveEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerMoveEvent的用法示例。


在下文中一共展示了PlayerMoveEvent.isCancelled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateLastToLocation

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
/**
 * Update the last known location of a player to account for the
 * given movement event
 */
private void updateLastToLocation(final PlayerMoveEvent event) {
    if(event.isCancelled()) {
        this.lastToLocation.put(event.getPlayer(), event.getEntityFrom());
    } else {
        this.lastToLocation.put(event.getPlayer(), event.getEntityTo());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:PlayerMovementListener.java

示例2: callCoarsePlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
/**
 * Fire a CoarsePlayerMoveEvent that wraps the given event, only if it crosses
 * a block boundary, or the PoseFlags change.
 * @param event         The movement event to potentially wrap
 * @return True if the original event was not cancelled, and a coarse event was fired,
 *         and that coarse event was cancelled. In this case, the wrapped event won't
 *         actually be cancelled, but callers should treat it like it is.
 */
private boolean callCoarsePlayerMove(final PlayerMoveEvent event) {
    // Don't fire coarse events for teleports that are not "in-game"
    // e.g. /jumpto command
    if(event instanceof PlayerTeleportEvent) {
        PlayerTeleportEvent teleportEvent = (PlayerTeleportEvent) event;
        if(teleportEvent.getCause() != TeleportCause.ENDER_PEARL &&
           teleportEvent.getCause() != TeleportCause.UNKNOWN) {
            return false;
        }
    }

    // If the movement does not cross a block boundary, and no PoseFlags changed, we don't care about it
    final EntityLocation from = event.getEntityFrom();
    final EntityLocation to = event.getEntityTo();
    if(from.position().coarseEquals(to.position()) && from.poseFlags().equals(to.poseFlags())) {
        return false;
    }

    // Remember whether the original event was already cancelled
    boolean wasCancelled = event.isCancelled();

    CoarsePlayerMoveEvent generalEvent = new CoarsePlayerMoveEvent(event, event.getPlayer(), from, to);
    this.eventBus.callEvent(generalEvent);

    if(!wasCancelled && generalEvent.isCancelled()) {
        // When a coarse event is cancelled, we have our own logic for resetting the
        // player's position, so we un-cancel the event and instead modify its
        // to location to put the player where we want them.
        resetPosition(event);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:43,代码来源:PlayerMovementListener.java

示例3: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
	if (e != null && e.getPlayer() != null && !e.isCancelled()) {
		Chunk prev = e.getFrom().getChunk();
		Chunk to = e.getTo().getChunk();
		if (prev != to) {
			if (AutoClaimHandler.inList(e.getPlayer())) {
				MainHandler.claimChunk(e.getPlayer(), to);
			}
			ChunkHandler ch = ClaimChunk.getInstance().getChunkHandler();
			boolean lastClaimed = ch.isClaimed(prev.getWorld(), prev.getX(), prev.getZ());
			if (ch.isClaimed(to.getWorld(), to.getX(), to.getZ())) {
				if (lastClaimed) {
					UUID prevOwner = ch.getOwner(prev.getWorld(), prev.getX(), prev.getZ());
					UUID newOwner = ch.getOwner(to.getWorld(), to.getX(), to.getZ());
					if (!prevOwner.equals(newOwner)) {
						showTitle(e.getPlayer(), to);
					}
				} else {
					showTitle(e.getPlayer(), to);
				}
			} else {
				if (lastClaimed) {
					Utils.toPlayer(e.getPlayer(), Config.getColor("infoColor"), Utils.getMsg("chunkLeave"));
				}
			}
		}
	}
}
 
开发者ID:cjburkey01,项目名称:ClaimChunk,代码行数:30,代码来源:PlayerMovementHandler.java

示例4: onMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onMove(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();
    if (from.toVector().equals(to.toVector()))
        return;

    PlayerWalkEvent custom = new PlayerWalkEvent(event);
    Bukkit.getPluginManager().callEvent(custom);
    if (event.isCancelled() != custom.isCancelled()) {
        event.setCancelled(custom.isCancelled());
    }
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:14,代码来源:EventCaller.java


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