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


Java PlayerMoveEvent类代码示例

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


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

示例1: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }
    if (!isWithinBorder(to) && isWithinBorder(from)) {
        final Player player = event.getPlayer();
        player.sendMessage(ChatColor.RED + "You cannot go past the border.");
        event.setTo(from);
        final Entity vehicle = player.getVehicle();
        if (vehicle != null) {
            vehicle.eject();
            vehicle.teleport(from);
            vehicle.setPassenger((Entity)player);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:BorderListener.java

示例2: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if (!event.getFrom().getWorld().getName().equalsIgnoreCase("cave")) {
        return;
    }

    if (event.getTo().getBlock().getLightFromSky() == 0) {
        return;
    }

    if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
        return;
    }

    event.getPlayer().setHealth(0.0D);

    TextComponent message = new TextComponent("DU VOLLIDIOT! SONNE IST GEFÄHRLICH! HOFFE DU LERNST DARAUS");
    message.setColor(ChatColor.DARK_RED);

    event.getPlayer().spigot().sendMessage(message);
}
 
开发者ID:AnguliNetworks,项目名称:NoDaylight,代码行数:22,代码来源:PlayerMoveListener.java

示例3: call

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@Override
public void call(Event event) {
	final Player player = profile.getPlayer();

	if (event instanceof PlayerMoveEvent) {
		if ((player.isSprinting() || player.isBlocking() || player.isConversing()) && player.isSneaking()) {
			callback(true);
			return;
		}
		callback(false);
	} else if (event instanceof AsyncPlayerChatEvent) {
		if ((player.isBlocking() || player.isSprinting() || player.isSneaking())) {
			callback(true);
			return;
		}
		callback(false);
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:19,代码来源:ImpossibleA.java

示例4: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
	final Player player = event.getPlayer();

	final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();

	final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();

	final long current = System.currentTimeMillis();

	if (player.isSprinting()) {
		behaviour.getMotion().setLastSprint(current);
	}
	if (player.isFlying()) {
		behaviour.getMotion().setLastFly(current);
	}

	if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
		behaviour.getMotion().setLastY(player.getLocation().getY());
	}

	if (!behaviour.isOnGround()) {
		behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:26,代码来源:BehaviourListeners.java

示例5: onMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event) {
	Game game = Chambers.getInstance().getGameManager().getGame();
	if (game.getStatus() != GameStatus.INGAME) {
		return;
	}
	Location to = event.getTo();
	Location from = event.getFrom();
	if (to.getBlockX() != from.getBlockX() || to.getBlockZ() != from.getBlockZ()) {
		Player player = event.getPlayer();
		Team toTeam = Chambers.getInstance().getClaimManager().getTeamAt(to);
		Team fromTeam = Chambers.getInstance().getClaimManager().getTeamAt(from);
		if (toTeam != fromTeam) {
			Bukkit.getPluginManager().callEvent(new PlayerEnterClaimEvent(player, toTeam.getClaim()));
			Bukkit.getPluginManager().callEvent(new PlayerLeaveClaimEvent(player, fromTeam.getClaim()));
			if (toTeam.getType() == TeamType.KOTH_CAP || fromTeam.getType() == TeamType.KOTH_CAP) {
				return;
			}
			player.sendMessage(ChatColor.YELLOW + "Now leaving: " + fromTeam.getFormattedName());
			player.sendMessage(ChatColor.YELLOW + "Now entering: " + toTeam.getFormattedName());
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:24,代码来源:ClaimMoveListener.java

示例6: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
        if(event.getTo().getY() <= Integer.valueOf((String) this.getGameMap().fetchSetting("floorLevel"))) {
            this.getAPI().getGameManager().setAlive(event.getPlayer(), false);
        } else {
            final Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
            if(block.getType() != Material.AIR) {
                if(!pendingDeletion.contains(block)) {
                    pendingDeletion.add(block);
                    new BukkitRunnable() {
                        public void run() {
                            if(pendingDeletion.contains(block)) {
                                block.setType(Material.AIR);
                                pendingDeletion.remove(block);
                            }
                        }
                    }.runTaskLater(this.getAPI().getPlugin(), 3L);
                }
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:24,代码来源:DeadEndGame.java

示例7: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
        if(event.getTo().getBlock().getType() == Material.STONE_PLATE) {
            event.getTo().getBlock().setType(Material.AIR);
            event.getTo().getWorld().spigot().playEffect(event.getTo(), Effect.FLAME,
                    0, 0, 1, 1, 1, 0, 5, 15);
            event.getTo().getWorld().spigot().playEffect(event.getTo(), Effect.EXPLOSION,
                0, 0, 1, 1, 1, 0, 6, 15);
            event.getTo().getWorld().playSound(event.getTo(), Sound.ENTITY_GENERIC_EXPLODE, 5f, 1f);
            event.getPlayer().teleport(startPosition);
            return;
        }
        if(this.getSidebar().getSidebar().getScore(event.getPlayer().getName()).getScore() >= -1) {
            this.endGame();
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:19,代码来源:MineFieldGame.java

示例8: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    if(!event.getTo().getWorld().getName().equalsIgnoreCase(event.getFrom().getWorld().getName())) return;
    if(event.getTo().getWorld().getName().equalsIgnoreCase("world")) return;
    ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
    if(!api.getGameManager().isAlive(event.getPlayer())) {
        double yLevel = Utils.parseLocation((String) api.getGameManager().getCurrentGame()
            .getGameMap().fetchSetting("spectatorLocation")).getY();
        double yDif = Math.abs(event.getTo().getY() - yLevel);
        Location newLocation = event.getTo();
        newLocation.setY(yLevel);
        if(yDif >= 0.5) event.setTo(newLocation);
    }
    if(api.getMapRegistry().getMapBounds() != null) {
        if(!api.getMapRegistry().getMapBounds().contains(event.getTo())) {
            if(api.getGameManager().isAlive(event.getPlayer())
                    && api.getGameManager().getCurrentGame().killOnMapExit) {
                api.getGameManager().setAlive(event.getPlayer(), false);
            } else {
                event.setTo(event.getFrom());
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:25,代码来源:SpectatorListener.java

示例9: upElevator

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
    if (p.hasPermission("ironelevators.use") && e.getFrom().getY() < e.getTo().getY()
            && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.UP, minElevation);
        int i = maxElevation;
        while (i > 0 && !(
                b.getType() == elevatorMaterial
                        && b.getRelative(BlockFace.UP).getType().isTransparent()
                        && b.getRelative(BlockFace.UP, 2).getType().isTransparent()
        )
                ) {
            i--;
            b = b.getRelative(BlockFace.UP);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() + maxElevation + 3 - i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:26,代码来源:IronElevators.java

示例10: onPlayerMoveEvent

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
	for (Entity en : e.getPlayer().getWorld().getEntities()) {
		if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getTo()) <= 1) {
			Location l = en.getLocation();
			//e.getPlayer().sendMessage(getPlayerDirection(e.getPlayer()));
			if (getPlayerDirection(e.getPlayer()).equals("north")) {
				l.add(-1.2, 0, 0);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("south")) {
				l.add(1.2, 0, 0);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("east")) {
				l.add(0, 0, -1.2);	
			}
			else if (getPlayerDirection(e.getPlayer()).equals("west")) {
				l.add(0, 0, 1.2);	
			}
			else {
				l = e.getPlayer().getLocation();
			}
			l.setDirection(e.getPlayer().getLocation().getDirection());
			e.setTo(l);
		}
	}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:27,代码来源:GhostBlock.java

示例11: onPlayerMoveEvent

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
	/*if (e.getPlayer().getTargetBlock((HashSet<Byte>) null, 100).getType() != Material.AIR) {
   		e.getPlayer().teleport(e.getPlayer().getLocation().add(0, 1, 0));
   	}*/

	/*for (Entity en : e.getPlayer().getWorld().getEntities()) {
   		for (int i = 0; i < en.getScoreboardTags().toArray().length; i++) {
   			String tag = en.getScoreboardTags().toString().replace('[', ' ').replace(']', ' ').trim().split(",")[i];
   			//System.out.println(tag);
   			if (tag.startsWith("p:")) {
   				//System.out.println(tag.substring(2, tag.length()));
   				if (tag.substring(2, tag.length()).equalsIgnoreCase(e.getPlayer().getName())) {
   					en.teleport(e.getPlayer().getLocation().add(0, -0.2, 0));
   					e.setFrom(en.getLocation());
   				}
   			}
   		}
   	}*/
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:21,代码来源:SuperiorCraft.java

示例12: onMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
    if(!isSpawned()) return;
    MatchPlayer player = match.getPlayer(event.getPlayer());
    if(player != null) {
        CooldownPlayerFacet cooler = player.facet(CooldownPlayerFacet.class);
        if(player.canInteract() &&
           cooler.isNotCooling(this) &&
           Capsule.fromEndpointsAndRadius(event.getFrom().position(),
                                          event.getTo().position(),
                                          0.5)
                  .intersects(Sphere.fromCircumscribedCuboid(entity.get().getBoundingBox())) &&
           data.pickup().query(player).isAllowed()) {

            cooler.coolFor(this, data.cooldown());
            despawn(true);
            player.facet(KitPlayerFacet.class).applyKit(data.kit(), false);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:Pickup.java

示例13: move

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void move(final PlayerMoveEvent event) {
    Player player = event.getPlayer();
    Location to = event.getTo();
    Location from = event.getFrom();
    Block toBlock = to.getBlock();
    Block fromBlock = from.getBlock();

    handleLook(player, to);

    if(PORTAL_MATERIALS.contains(toBlock.getType()) && !PORTAL_MATERIALS.contains(fromBlock.getType())) {
        nearestSign(event.getTo()).ifPresent(
            sign -> sign.connector().teleport(player)
        );
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:SignUpdater.java

示例14: 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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:30,代码来源:PlayerMovementListener.java

示例15: onMove

import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent e) {
	KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
	double xfrom = e.getFrom().getX();
	double yfrom = e.getFrom().getY();
	double zfrom = e.getFrom().getZ();
	double xto = e.getTo().getX();
	double yto = e.getTo().getY();
	double zto = e.getTo().getZ();
	if (!(xfrom == xto && yfrom == yto && zfrom == zto)) {
		if (p.hasAction()) {
			if (p.getAction() instanceof TeleportationAction) {
				((TeleportationAction) p.getAction()).notifyPlayerOnMovement();
			} else if(p.getAction() instanceof LogoutAction) {
				p.getAction().cancel();
				p.sendMessage(Messages.getInstance().getPrefix() + "Je bewoog! Je uitlog actie is geannuleerd!");
			}
		}
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:21,代码来源:HomeTeleportMoveEvent.java


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