Java 类org.bukkit.event.player.PlayerTeleportEvent 实例源码

项目:BedwarsXP    文件:NewEventListeners.java   
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) { // ����Ҵ��ͺ���¾�����
    final Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
            .getGameManager().getGameOfPlayer(e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    final Player p = e.getPlayer();
    Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {

        @Override
        public void run() {
            XPManager.updateXPBar(bw.getName(), p);
        }
    }, 5);

}
项目:BedwarsXP    文件:OldEventListeners.java   
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) { // ����Ҵ��ͺ���¾�����
    final Game bw = io.github.yannici.bedwars.Main.getInstance()
            .getGameManager().getGameOfPlayer(e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    final Player p = e.getPlayer();
    Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {

        @Override
        public void run() {
            XPManager.updateXPBar(bw.getName(), p);
        }
    }, 5);

}
项目:Warzone    文件:SpawnPointHandlerModule.java   
public void spawnPlayer(PlayerContext playerContext, MatchTeam matchTeam, boolean teleport) {
    Players.reset(playerContext.getPlayer(), true);

    if (matchTeam.isSpectator()) {
        spectatorModule.applySpectatorKit(playerContext);
        if (teleport) {
            playerContext.getPlayer().teleport(getTeamSpawn(matchTeam).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
        }
    } else {
        matchTeam.getKits().forEach(kit -> kit.apply(playerContext.getPlayer(), matchTeam));
        playerContext.getPlayer().updateInventory();

        if (teleport) {
            playerContext.getPlayer().teleport(getTeamSpawn(matchTeam).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
            playerContext.getPlayer().setGameMode(GameMode.SURVIVAL);
        }
    }
}
项目:WC    文件:TeleportAllCMD.java   
@Override
public void run(WCUser user, String label, String[] args) {
    WCUser target = user;
    if (args.length != 0) {
        target = WCServer.getUser(plugin.getServer().getPlayer(args[0]));
        if (!target.isOnline()) {
            userNotOnline(user);
            return;
        }
    }

    for (Player p : plugin.getServer().getOnlinePlayers()) {
        p.teleport(target.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
    }

    user.sendMessagePrefix("&6Todos los jugadores han sido teletransportados");
}
项目:WC    文件:TeleportPosCMD.java   
@Override
public void run(WCUser user, String label, String[] args) {
    if (args.length != 3) {
        user.sendMessage("&eUsa: /" + label + " <x> <y> <z>");
        return;
    }

    Double x, y, z;
    try {
        x = Double.parseDouble(args[0]);
        y = Double.parseDouble(args[1]);
        z = Double.parseDouble(args[2]);
    } catch (NumberFormatException e) {
        user.sendMessage("&eUsa: /" + label + " <x> <y> <z> (Deben ser números de coordenadas)");
        return;
    }
    Location loc = new Location(user.getPlayer().getWorld(), x, y, z);

    user.getPlayer().teleport(loc, PlayerTeleportEvent.TeleportCause.COMMAND);
    user.sendMessage("&6Teleportando a &e" + x + "&6, &e" + y + "&6, &e" + z);
}
项目:WC    文件:TeleportHereCMD.java   
@Override
public void run(WCUser user, String label, String[] args) {
    if (args.length == 0) {
        user.sendMessage("");
        return;
    }

    WCUser target = WCServer.getUser(plugin.getServer().getPlayer(args[0]));
    if (!target.isOnline()) {
        userNotOnline(user);
        return;
    }

    target.getPlayer().teleport(user.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
    user.sendMessage("");
}
项目:ProjectAres    文件:PlayerMovementListener.java   
/**
 * 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);
}
项目:NavyCraft2-Lite    文件:TeleportFix.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {

    final Player player = event.getPlayer();
    final int visibleDistance = server.getViewDistance() * 16;

    // Fix the visibility issue one tick later
    server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
        @Override
        public void run() {
            // Refresh nearby clients

            String version;

            version = Bukkit.getServer().getClass().getPackage().getName();
            if (version.contains("v1_11")) {
                TeleportFix_1_11.updateEntities(getPlayersWithin(player, visibleDistance));

            } else if (version.contains("v1_12")) {
                TeleportFix_1_12.updateEntities(getPlayersWithin(player, visibleDistance));
            }

            //System.out.println("Applying fix ... " + visibleDistance);
        }
    }, TELEPORT_FIX_DELAY);
}
项目:SkyWarsReloaded    文件:LobbyListener.java   
@EventHandler
public void onTeleportEvent(PlayerTeleportEvent e) {
    final Player player = e.getPlayer();
    if (teleportBetweenWorlds(e.getTo().getWorld(), e.getFrom().getWorld()) && teleportToLobby(e.getTo().getWorld())) {
        SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
            public void run() {
                if (player != null) {
                    givePlayerItems(player);
                }
            }
        }, 8);
    } else if (teleportBetweenWorlds(e.getTo().getWorld(), e.getFrom().getWorld()) && !teleportToLobby(e.getTo().getWorld())) {
        SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
            public void run() {
                if (player != null) {
                    removePlayerItems(player);
                }
            }
        }, 8);
    }
}
项目:RealSurvival    文件:BasicEvent.java   
@EventHandler
public void teleport(PlayerTeleportEvent e){
    if(e.getPlayer().hasMetadata("NPC"))return;
    if(!rs.worldExists(e.getTo().getWorld().getName())){
        if(rs.getPlayerData(e.getPlayer())==null)return;
        rs.deletePlayer(e.getPlayer());
        return;
    }
    if(rs.getPlayerData(e.getPlayer())!=null)return;
    Player p=e.getPlayer();
    File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
    if(!data.exists()){//�������ļ��Ƿ����,������������ʼ��һ���ļ�
        try {data.createNewFile();} catch (IOException e1) {}
        PlayerData pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(), rs.getThirstMax(), 0, 37, 0, rs.getPhysical_strength());
        pd.savaData();
    }
    rs.addPlayerData(p, Utils.getPlayerData(p));
}
项目:HCFCore    文件:PortalListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    if (event.getTo() != null) {
        World toWorld = event.getTo().getWorld();
        if (toWorld != null && toWorld.getEnvironment() == World.Environment.THE_END) {
            event.useTravelAgent(false);
            event.setTo(toWorld.getSpawnLocation());
            return;
        }
    }

    World fromWorld = event.getFrom().getWorld();
    if (fromWorld != null && fromWorld.getEnvironment() == World.Environment.THE_END) {
        event.useTravelAgent(false);
        event.setTo(endExit);
    }
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
        Location to = event.getTo();
        if (blockedPearlTypes.contains(to.getBlock().getType())) {
            Player player = event.getPlayer();
            player.sendMessage(ChatColor.YELLOW + "You have been detected trying to pearl glitch, your pearl has been refunded and cooldown wiped.");
            plugin.getTimerManager().getEnderPearlTimer().refund(player);

            event.setCancelled(true);
            return;
        }

        to.setX(to.getBlockX() + 0.5);
        to.setZ(to.getBlockZ() + 0.5);
        event.setTo(to);
    }
}
项目:HCFCore    文件:VoidGlitchFixListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerDamage(EntityDamageEvent event) {
    if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
        Entity entity = event.getEntity();
        if (entity instanceof Player) {
            // Allow players to die by VOID in the END
            if (entity.getWorld().getEnvironment() == World.Environment.THE_END) {
                return;
            }

            Location destination = BukkitUtils.getHighestLocation(entity.getLocation());
            if (destination == null)
                return;

            if (entity.teleport(destination, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
                event.setCancelled(true);
                ((Player) entity).sendMessage(ChatColor.YELLOW + "You were saved from the void.");
            }
        }
    }
}
项目:HCFCore    文件:TeleportTimer.java   
/**
 * Teleports a {@link Player} to a {@link Location} with a delay.
 *
 * @param player
 *            the {@link Player} to teleport
 * @param location
 *            the {@link Location} to teleport to
 * @param millis
 *            the time in milliseconds until teleport
 * @param warmupMessage
 *            the message to send whilst waiting
 * @param cause
 *            the cause for teleporting
 * @return true if {@link Player} was successfully teleported
 */
public boolean teleport(Player player, Location location, long millis, String warmupMessage, PlayerTeleportEvent.TeleportCause cause) {
    cancelTeleport(player, null); // cancels any previous teleport for the player.

    boolean result;
    if (millis <= 0) { // if there is no delay, just instantly teleport.
        result = player.teleport(location, cause);
        clearCooldown(player.getUniqueId());
    } else {
        UUID uuid = player.getUniqueId();
        player.sendMessage(warmupMessage);
        destinationMap.put(uuid, location.clone());
        setCooldown(player, uuid, millis, true, null);
        result = true;
    }

    return result;
}
项目:HCFCore    文件:PortalListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    if (event.getTo() != null) {
        World toWorld = event.getTo().getWorld();
        if (toWorld != null && toWorld.getEnvironment() == World.Environment.THE_END) {
            event.useTravelAgent(false);
            event.setTo(toWorld.getSpawnLocation());
            return;
        }
    }

    World fromWorld = event.getFrom().getWorld();
    if (fromWorld != null && fromWorld.getEnvironment() == World.Environment.THE_END) {
        event.useTravelAgent(false);
        event.setTo(endExit);
    }
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
        Location to = event.getTo();
        if (blockedPearlTypes.contains(to.getBlock().getType())) {
            Player player = event.getPlayer();
            player.sendMessage(ChatColor.YELLOW + "You have been detected trying to pearl glitch, your pearl has been refunded and cooldown wiped.");
            plugin.getTimerManager().getEnderPearlTimer().refund(player);

            event.setCancelled(true);
            return;
        }

        to.setX(to.getBlockX() + 0.5);
        to.setZ(to.getBlockZ() + 0.5);
        event.setTo(to);
    }
}
项目:HCFCore    文件:TeleportTimer.java   
/**
 * Teleports a {@link Player} to a {@link Location} with a delay.
 *
 * @param player
 *            the {@link Player} to teleport
 * @param location
 *            the {@link Location} to teleport to
 * @param millis
 *            the time in milliseconds until teleport
 * @param warmupMessage
 *            the message to send whilst waiting
 * @param cause
 *            the cause for teleporting
 * @return true if {@link Player} was successfully teleported
 */
public boolean teleport(Player player, Location location, long millis, String warmupMessage, PlayerTeleportEvent.TeleportCause cause) {
    cancelTeleport(player, null); // cancels any previous teleport for the player.

    boolean result;
    if (millis <= 0) { // if there is no delay, just instantly teleport.
        result = player.teleport(location, cause);
        clearCooldown(player.getUniqueId());
    } else {
        UUID uuid = player.getUniqueId();
        player.sendMessage(warmupMessage);
        destinationMap.put(uuid, location.clone());
        setCooldown(player, uuid, millis, true, null);
        result = true;
    }

    return result;
}
项目:PA    文件:TeleportAllCMD.java   
@Override
public void run(PAUser user, String label, String[] args) {
    PAUser target = user;
    if (args.length != 0) {
        target = PAServer.getUser(plugin.getServer().getPlayer(args[0]));
        if (!target.isOnline()) {
            userNotOnline(user);
            return;
        }
    }

    for (Player p : plugin.getServer().getOnlinePlayers()) {
        p.teleport(target.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
    }

    user.sendMessage(PAData.CORE.getPrefix() + "&6Todos los jugadores han sido teletransportados");
}
项目:PA    文件:TeleportPosCMD.java   
@Override
public void run(PAUser user, String label, String[] args) {
    if (args.length != 3) {
        user.sendMessage(Messages.getMessage(Messages.BUFF_ARGS, PAData.CORE));
        return;
    }

    Double x, y, z;
    try {
        x = Double.parseDouble(args[0]);
        y = Double.parseDouble(args[1]);
        z = Double.parseDouble(args[2]);
    } catch (NumberFormatException e) {
        user.sendMessage("&eUsa: /" + label + " <x> <y> <z> (Deben ser números de coordenadas)");
        return;
    }
    Location loc = new Location(user.getPlayer().getWorld(), x, y, z);

    user.getPlayer().teleport(loc, PlayerTeleportEvent.TeleportCause.COMMAND);
    user.sendMessage("&6Teleportando a &e" + x + "&6, &e" + y + "&6, &e" + z);
}
项目:PA    文件:TeleportHereCMD.java   
@Override
public void run(PAUser user, String label, String[] args) {
    if (args.length == 0) {
        user.sendMessage("");
        return;
    }

    PAUser target = PAServer.getUser(plugin.getServer().getPlayer(args[0]));
    if (!target.isOnline()) {
        userNotOnline(user);
        return;
    }

    target.getPlayer().teleport(user.getPlayer().getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
    user.sendMessage("");
}
项目:Chambers    文件:EnderpearlListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
        Location to = event.getTo();
        if (blockedPearlTypes.contains(to.getBlock().getType())) {
            Player player = event.getPlayer();
            player.sendMessage(ChatColor.RED + "You cannot pearl there.");
            removeCooldown(player);
            event.setCancelled(true);

            return;
        }
        to.setX(to.getBlockX() + 0.5D);
        to.setZ(to.getBlockZ() + 0.5D);
        event.setTo(to);

    }
}
项目:Mega-Walls    文件:PlayerTeleportListener.java   
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e)
{
    User user = MWAPI.getUserHandler().findById(e.getPlayer().getUniqueId());

    if (user.getGame() != null && (user.getGame().isPlaying(user) || user.getGame().isSpectating(user)))
    {
        if (handler.getAllowedTeleports().containsKey(user) &&
            handler.getAllowedTeleports().get(user).equals(e.getTo()))
        {
            handler.getAllowedTeleports().remove(user);
            return;
        }

        user.getGame().leave(user);
        user.getPlayer().teleport(e.getTo());
    }
}
项目:RandomCoordinatesV2    文件:PlayerSwitchWorld.java   
@EventHandler
public void onPlayerSwitch(final PlayerTeleportEvent e) {
    if(RandomCoords.getPlugin().config.getStringList("OnJoinWorlds") == null )  { return; }
    if(e.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL || e.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }
    final List<String> list = RandomCoords.getPlugin().config.getStringList("OnJoinWorlds");
    if(list.isEmpty()) { return; }
    if(e.getTo().getWorld() == e.getFrom().getWorld()) { return; }
    if(list.contains(e.getTo().getWorld().getName())) {
        if(e.getTo().getWorld().getPlayers().contains(e.getPlayer())) { return; }
        final Player p = e.getPlayer();
        //coordinates.finalCoordinates(p, 574272099, 574272099, e.getTo().getWorld(), CoordType.JOINWORLD, 0);
        coordinatesManager.randomlyTeleportPlayer(p, e.getTo().getWorld(), coordinatesManager.key, coordinatesManager.key, CoordType.JOINWORLD, 0);

    }


}
项目:Duels    文件:Teleport.java   
public boolean isAuthorizedFor(Player base, Location to) {
    if (to == null || to.getWorld() == null) {
        instance.logToFile(getClass(), base.getUniqueId() + " (" + base.getName() + ") is not authorized to teleport to " + to + "!", Level.WARNING);
        return false;
    }

    Helper.refreshChunk(to);
    Helper.updatePosition(base, to);

    if (config.isPatchesForceAllowTeleportation()) {
        return true;
    }

    PlayerTeleportEvent event = new PlayerTeleportEvent(base, base.getLocation(), to, PlayerTeleportEvent.TeleportCause.PLUGIN);
    Bukkit.getPluginManager().callEvent(event);
    return !event.isCancelled();
}
项目:Duels    文件:Teleport.java   
@EventHandler (priority = EventPriority.MONITOR)
public void on(PlayerTeleportEvent event) {
    if (!config.isPatchesForceAllowTeleportation()) {
        return;
    }

    Storage storage = Storage.get(event.getPlayer());
    Object value = storage.get("teleportedTo");

    if (value == null) {
        return;
    }

    storage.remove("teleportedTo");
    event.setTo((Location) value);
    event.setCancelled(false);
}
项目:GriefPreventionFlags    文件:FlagDef_NoEnderPearl.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.ENDER_PEARL) return;

    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }

    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
项目:GriefPreventionFlags    文件:FlagDef_NoChorusFruit.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.CHORUS_FRUIT) return;

    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }

    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
项目:HoloGUIApi    文件:PlayerTeleportEventListener.java   
@EventHandler
public void playerTeleportEvent(PlayerTeleportEvent event)
{
    Player player = event.getPlayer();

    PlayerGUIPage playerGUIContainer = PlayerData.getPlayerData(player).getPlayerGUIPage();
    if(playerGUIContainer != null)
    {
        if(event.getCause() != PlayerTeleportEvent.TeleportCause.UNKNOWN)
        {
            playerGUIContainer.destroy();
            PlayerData.getPlayerData(player).setPlayerGUIPage(null);
            PlayerData.getPlayerData(player).setPlayerPreviousGUIPage(null);
        }
    }
}
项目:Breakpoint    文件:CTFListener.java   
@Override
public void onPlayerTeleport(PlayerTeleportEvent event, BPPlayer bpPlayer)
{
    TeleportCause cause = event.getCause();

    if(cause == TeleportCause.ENDER_PEARL)
    {
        CTFGame game = getGame();
        FlagManager flm = game.getFlagManager();

        if(flm.isHoldingFlag(bpPlayer))
        {
            Player player = bpPlayer.getPlayer();
            event.setCancelled(true);
            player.sendMessage(MessageType.OTHER_WARNPEARL.getTranslation().getValue());
        }
    }
}
项目:iZenith-PVP    文件:TeleportListener.java   
@EventHandler
public void onTeleport(final PlayerTeleportEvent e) {
    final Player p = e.getPlayer();
    if (e.getCause().equals(TeleportCause.SPECTATE)
            && !(p.hasPermission("essentials.tp"))){ 
        e.setCancelled(true);
        p.sendMessage(ChatColor.RED + "You do not have permission to /tp");
    }

    if (!e.getFrom().getWorld().equals(e.getTo().getWorld())) {
        MultiverseCore mv = (MultiverseCore) Bukkit.getServer()
                .getPluginManager().getPlugin("Multiverse-Core");
        MVWorldManager wm = mv.getMVWorldManager();
        MultiverseWorld toWorld = wm.getMVWorld(e.getTo().getWorld()
                .getName());
        MultiverseWorld fromWorld = wm.getMVWorld(e.getFrom().getWorld()
                .getName());
        if (toWorld != fromWorld
                && !p.getGameMode().equals(toWorld.getGameMode())) {
            p.setGameMode(toWorld.getGameMode());
        }
    }
}
项目:CraftPlugins    文件:Blockode.java   
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)  //这就是我说的那个监听器了,事件发生时会触发下面这个方法
public void onPlayerTeleport(PlayerTeleportEvent e)  {
    if(this.isInList(e.getPlayer())
            &&!e.getTo().getWorld().equals(this.gameworld)
            &&!e.getPlayer().isOp()){//里面的人试图出去(op例外)
        e.getPlayer().sendMessage(ChatColor.RED+"你已经退出了游戏");
        Bukkit.broadcastMessage(ChatColor.GOLD+e.getPlayer().getDisplayName()+"逃离了一场游戏!");
        this.removefromPlayerList(e.getPlayer());
        //e.setCancelled(true);
    }

    if(!this.isInList(e.getPlayer())
            &&e.getTo().getWorld().equals(this.gameworld)
            &&!e.getPlayer().isOp()){//外面的人试图进来(op例外)
        e.getPlayer().sendMessage(ChatColor.GREEN+"成功加入游戏");
        this.addtoPlayerList(e.getPlayer());
        //e.setCancelled(true);
    }

}
项目:Statz    文件:TeleportsListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) {

    final PlayerStat stat = PlayerStat.TELEPORTS;

    // Get player
    final Player player = event.getPlayer();

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
            StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world",
                    event.getFrom().getWorld().getName(), "destWorld", event.getTo().getWorld().getName(), "cause", event.getCause().toString()));

}
项目:Gamemode4Engine    文件:BackCommand.java   
@Override
public boolean onCommand(CommandSender cs, Command command, String alias, String[] args) {
    if (cs instanceof Player) {
        Player sender = (Player) cs;
        if (sender.isOp() || sender.hasPermission("gm4.back")) {
            if (args.length == 0) {
                if (locationHistory.containsKey(sender.getUniqueId())) {
                    Location loc = locationHistory.get(sender.getUniqueId());
                    if (!isUnsafe(sender, loc) || alias.equalsIgnoreCase("backunsafe")) {
                        sender.teleport(loc, PlayerTeleportEvent.TeleportCause.COMMAND);
                        sender.sendMessage(ChatColor.GREEN + "Returning you to your last known location! [" + ChatColor.GOLD + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ChatColor.GREEN + "]");
                    } else {
                        sender.sendMessage(ChatColor.RED + "Unsafe location! Use " + ChatColor.GOLD + "/backunsafe" + ChatColor.RED + " to bypass protection.");
                    }
                } else {
                    sender.sendMessage(ChatColor.RED + "You have no location history!");
                }
                return true;
            }
            TextUtil.sendCommandFormatError(sender, "/" + alias);
        }
    }
    return true;
}
项目:SonarPet    文件:PetOwnerListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
    final Player p = event.getPlayer();
    final IPet pi = EchoPet.getManager().getPet(p);
    Iterator<IPet> i = EchoPet.getManager().getPets().iterator();
    while (i.hasNext()) {
        IPet pet = i.next();
        if (pet.getEntityPet() instanceof IEntityPacketPet && ((IEntityPacketPet) pet.getEntityPet()).hasInititiated()) {
            if (GeometryUtil.getNearbyEntities(event.getTo(), 50).contains(pet)) {
                ((IEntityPacketPet) pet.getEntityPet()).updatePosition();
            }
        }
    }
    if (pi != null) {
        if (!WorldUtil.allowPets(event.getTo())) {
            Lang.sendTo(p, Lang.PETS_DISABLED_HERE.toString().replace("%world%", WordUtils.capitalizeFully(event.getTo().getWorld().getName())));
            EchoPet.getManager().saveFileData("autosave", pi);
            EchoPet.getSqlManager().saveToDatabase(pi, false);
            EchoPet.getManager().removePet(pi, false);
        }
    }
}
项目:Steel    文件:PlayerWorldListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    // make sure they moved through space
    if (event.getFrom().getX() != event.getTo().getX()
            || event.getFrom().getY() != event.getTo().getY()
            || event.getFrom().getZ() != event.getTo().getZ()) {
        // begin the hunt for the challenger
        Optional<Challenger> challenger = CommonCore.getChallenger(event.getPlayer().getUniqueId());
        // check whether the player is in a round for this minigame
        if (challenger.isPresent() && !((CommonChallenger) challenger.get()).isLeaving()) {
            Boundary bound = challenger.get().getRound().getArena().getBoundary();
            // check whether the player is teleporting out of the arena boundary
            if (!bound.contains(LocationHelper.convertLocation(event.getTo()))) {
                if (challenger.get().getRound().getConfigValue(ConfigNode.ALLOW_EXIT_BOUNDARY)) {
                    challenger.get().removeFromRound();
                } else {
                    event.setCancelled(true);
                }
            }
        }
    }
}
项目:SpawnShield    文件:TeleportSafezoningTask.java   
@Override
public void run() {
    for (Player playerEntity : Bukkit.getOnlinePlayers()) {
        SpawnShieldPlayer player = plugin.getPlayer(playerEntity);
        if (isBlocked(playerEntity.getLocation())) {
            if (plugin.getCombatTagPlugin().isTagged(playerEntity)){
                if (player.getLastLocationOutsideSafezone() == null) {
                    plugin.getLogger().warning(player.getName() + "'s last location outside safezone is unknown");
                } else {
                    if (player.getLastCantEnterMessageTime() + 1500 < System.currentTimeMillis()) {
                        playerEntity.sendMessage(plugin.getMessages().getCantEnterSafezone());
                        player.setLastCantEnterMessageTime(System.currentTimeMillis());
                    }
                    playerEntity.teleport(player.getLastLocationOutsideSafezone(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                }
            }
        } else {
            player.setLastLocationOutsideSafezone(playerEntity.getLocation());
        }
    }
}
项目:CanaryBukkit    文件:CanaryPlayerListener.java   
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onTeleportation(final TeleportHook hook) {
    PlayerTeleportEvent event =
            new PlayerTeleportEvent(new CanaryPlayer(hook.getPlayer()), new CanaryLocation(hook.getPlayer()
                    .getLocation(), new CanaryWorld(hook.getDestination().getWorld())), new CanaryLocation(hook
                    .getDestination(), new CanaryWorld(hook.getDestination().getWorld())),
                    TeleportCauseConverter.of(hook.getTeleportReason())) {
                @Override
                public void setFrom(Location from) {
                    super.setFrom(from);
                    // How can you do this in Canary?
                }

                @Override
                public void setTo(Location to) {
                    super.setTo(to);
                    // How can you do this in Canary?
                }
            };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
}
项目:FancyFreeze    文件:DefaultFreezer.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(PlayerTeleportEvent event) {
    if (!isCurrentlyFrozen(event.getPlayer().getUniqueId())) return;

    Player player = event.getPlayer();

    switch (event.getCause()) {
        case PLUGIN:
            // skip if it was to the same location as currently set, stops
            // resetting particles/metadata on border knockback
            if (event.getTo().equals(getFreezeLocation(player).get())) return;
        case COMMAND:
        case UNKNOWN:
            // set new location and reset particles
            setFreezeLocation(player, event.getTo());
            startParticleSpawning(player, event.getTo());
            potionApplier.addPotions(player);
    }
}
项目:PerWorldInventory    文件:PlayerTeleportListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    if (event.isCancelled()) {
        return;
    }

    Location from = event.getFrom();
    Location to = event.getTo();

    if (from.getWorld().equals(to.getWorld())) {
        return;
    }

    ConsoleLogger.debug("[EVENTS] Player '" + event.getPlayer().getName() + "' going from world '" + from + "' to world '" + to + "'");

    Group groupFrom = groupManager.getGroupFromWorld(from.getWorld().getName());
    Group groupTo = groupManager.getGroupFromWorld(to.getWorld().getName());

    if (groupFrom.equals(groupTo)) {
        return;
    }

    playerManager.addPlayer(event.getPlayer(), groupFrom);
    event.getPlayer().closeInventory();
}
项目:PerWorldInventory    文件:PlayerTeleportListenerTest.java   
@Test
public void noInteractionsSameWorld() {
    // given
    Player player = mock(Player.class);

    World worldFrom = mock(World.class);
    Location from = new Location(worldFrom, 1, 2, 3);
    Location to = new Location(worldFrom, 4, 5, 6);

    PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);

    // when
    listener.onPlayerTeleport(event);

    // then
    verifyZeroInteractions(groupManager);
    verifyZeroInteractions(playerManager);
}