本文整理汇总了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());
}
}
示例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;
}
}
示例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"));
}
}
}
}
}
示例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());
}
}