當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerTeleportEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerTeleportEvent的典型用法代碼示例。如果您正苦於以下問題:Java PlayerTeleportEvent類的具體用法?Java PlayerTeleportEvent怎麽用?Java PlayerTeleportEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PlayerTeleportEvent類屬於org.bukkit.event.player包,在下文中一共展示了PlayerTeleportEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);

}
 
開發者ID:Ldcr993519867,項目名稱:BedwarsXP,代碼行數:21,代碼來源:NewEventListeners.java

示例2: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);

}
 
開發者ID:Ldcr993519867,項目名稱:BedwarsXP,代碼行數:21,代碼來源:OldEventListeners.java

示例3: spawnPlayer

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
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);
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:19,代碼來源:SpawnPointHandlerModule.java

示例4: run

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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");
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:18,代碼來源:TeleportAllCMD.java

示例5: run

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:22,代碼來源:TeleportPosCMD.java

示例6: run

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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("");
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:17,代碼來源:TeleportHereCMD.java

示例7: resetPosition

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的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

示例8: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:27,代碼來源:TeleportFix.java

示例9: onTeleportEvent

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:22,代碼來源:LobbyListener.java

示例10: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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));
}
 
開發者ID:SchoolUniform,項目名稱:RealSurvival,代碼行數:19,代碼來源:BasicEvent.java

示例11: onPlayerPortal

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:PortalListener.java

示例12: onPearlClip

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:19,代碼來源:PearlGlitchListener.java

示例13: onPlayerDamage

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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.");
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:VoidGlitchFixListener.java

示例14: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:33,代碼來源:TeleportTimer.java

示例15: run

import org.bukkit.event.player.PlayerTeleportEvent; //導入依賴的package包/類
@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");
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:18,代碼來源:TeleportAllCMD.java


注:本文中的org.bukkit.event.player.PlayerTeleportEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。