本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent.setCancelled方法的具体用法?Java PlayerMoveEvent.setCancelled怎么用?Java PlayerMoveEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerMoveEvent
的用法示例。
在下文中一共展示了PlayerMoveEvent.setCancelled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event) {
for (Region region : regions) {
if (region.contains(event.getTo())) {
for (MatchTeam matchTeam : teams) {
if (matchTeam.containsPlayer(event.getPlayer())) {
FilterResult filterResult = evaluator.evaluate(event.getPlayer());
if (filterResult == FilterResult.DENY) {
event.setCancelled(true);
event.getPlayer().sendMessage(message);
} else if (filterResult == FilterResult.ALLOW) {
event.setCancelled(false);
}
}
}
}
}
}
示例2: resetPosition
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
/**
* Modify the to location of the given event to prevent the movement and
* move the player so they are standing on the center of the block at the
* from location.
*/
private static void resetPosition(final PlayerMoveEvent event) {
Location newLoc;
double yValue = event.getFrom().getY();
if(yValue <= 0 || event instanceof PlayerTeleportEvent) {
newLoc = event.getFrom();
} else {
newLoc = BlockUtils.center(event.getFrom()).subtract(new Vector(0, 0.5, 0));
if(newLoc.getBlock() != null) {
switch(newLoc.getBlock().getType()) {
case STEP:
case WOOD_STEP:
newLoc.add(new Vector(0, 0.5, 0));
break;
default: break;
}
}
}
newLoc.setPitch(event.getTo().getPitch());
newLoc.setYaw(event.getTo().getYaw());
event.setCancelled(false);
event.setTo(newLoc);
}
示例3: onPlayerMoveWhenNotLoaded
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerMoveWhenNotLoaded(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.isAllowedWorld(player.getWorld()) || InventoryManager.playerIsLoaded(player)) {
return;
}
if (PlayerLoader.isPreparedPlayer(player)) {
PlayerLoader.removePlayer(player);
player.kickPlayer(RPGInventory.getLanguage().getMessage("error.rp.denied"));
event.setCancelled(true);
} else {
Location toLocation = event.getTo();
Location newLocation = event.getFrom().clone();
//noinspection deprecation
if (!player.isOnGround()) {
newLocation.setY(toLocation.getY());
}
newLocation.setPitch(toLocation.getPitch());
newLocation.setYaw(toLocation.getYaw());
event.setTo(newLocation);
}
}
示例4: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event) {
/*if (event.getPlayer().isInsideVehicle() || event.getPlayer().isDead() || (event.getFrom().getX() == event.getTo().getX() && event.getFrom().getY() == event.getTo().getY() && event.getFrom().getZ() == event.getTo().getZ())) return;
double vd = event.getTo().getY() - event.getFrom().getY();
//double yd = Math.abs(event.getFrom().getY() - event.getTo().getY());
boolean up = (vd > -0.9);
if (!event.getPlayer().isOnGround() && vd < -0.1 && vd < 0.1)
event.getPlayer().sendMessage(String.valueOf(vd));*/
/*if (event.getFrom().distance(event.getTo()) > 0.75 && !event.getPlayer().hasPotionEffect(PotionEffectType.SPEED) && !event.getPlayer().isFlying() && !event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
ActionFactory.log(Cheats.SPEED_HACKING, event.getPlayer());
}*/
if (McLinkCommand.FREEZED.contains(event.getPlayer())) {
event.setCancelled(true);
}
}
示例5: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (p.isInsideVehicle() && p.getVehicle() instanceof ArmorStand){
e.setCancelled(true);
}
}
示例6: 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());
}
}