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


Java PlayerTeleportEvent.setTo方法代碼示例

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


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

示例1: 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

示例2: 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.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);

	}
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:19,代碼來源:EnderpearlListener.java

示例3: on

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

示例4: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
	final IUser user = ess.getUserMap().getUser(event.getPlayer());
	if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
	{
		return;
	}

	try
	{
		event.setTo(getJail(user.getData().getJail()));
	}
	catch (Exception ex)
	{
		if (ess.getSettings().isDebug())
		{
			LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()), ex);
		}
		else
		{
			LOGGER.log(Level.INFO, _("§4Error occurred when trying to return player§c {0} §4to jail: {1}!", user.getName(), ex.getLocalizedMessage()));
		}
	}
	user.sendMessage(_("§4You do the crime, you do the time."));
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:27,代碼來源:Jails.java

示例5: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.NORMAL)
public void onTeleport(PlayerTeleportEvent event) {
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
        Location to = event.getTo();

        if (this.blockedTypes.contains(to.getBlock().getType())) {
            event.setCancelled(true);
            return;
        }

        to.setX(to.getBlockX() + 0.5D);
        to.setZ(to.getBlockZ() + 0.5D);
        event.setTo(to);
    }
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:16,代碼來源:PearlFix.java

示例6: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onTeleport(PlayerTeleportEvent event) {
    final Player player = event.getPlayer();
    HeightMapMCAGenerator gen = getGenerator(player);
    if (gen != null) {
        Location from = event.getFrom();
        Location to = event.getTo();
        if (to.getWorld().equals(from.getWorld()) && to.distanceSquared(from) < 8) {
            event.setTo(player.getLocation());
            event.setCancelled(true);
            player.setVelocity(player.getVelocity());
        }
    }
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:15,代碼來源:CFIPacketListener.java

示例7: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onTeleport(final PlayerTeleportEvent e) {
    //
    // plugin.getLogger().info("DEBUG: Teleport called");
    Player player = e.getPlayer();
    if (SafeBoat.ignoreList.contains(player.getUniqueId())) {
        return;
    }
    // If the player is not teleporting due to boat exit, return
    if (!exitedBoat.containsKey(player.getUniqueId())) {
        return;
    }
    // Entity boat = exitedBoat.get(player.getUniqueId());
    // Reset the flag
    exitedBoat.remove(player.getUniqueId());
    // Okay, so a player is getting out of a boat in the the right world.
    // Now...
    //plugin.getLogger().info("DEBUG: Player just exited a boat");
    // Find a safe place for the player to land
    int radius = 0;
    while (radius++ < 2) {
        for (int x = player.getLocation().getBlockX() - radius; x < player.getLocation().getBlockX() + radius; x++) {
            for (int z = player.getLocation().getBlockZ() - radius; z < player.getLocation().getBlockZ() + radius; z++) {
                for (int y = player.getLocation().getBlockY(); y < player.getLocation().getBlockY() + 2; y++) {
                    // The safe location to tp to is actually +0.5 to x and
                    // z.
                    final Location loc = new Location(player.getWorld(), (double) (x + 0.5), (double) y, (double) (z + 0.5));
                    // plugin.getLogger().info("XYZ is " + x + " " + y + " "
                    // + z);
                    // Make sure the location is safe
                    if (GridManager.isSafeLocation(loc)) {
                        // plugin.getLogger().info("Safe!");
                        e.setTo(loc);
                        return;
                    }
                }
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:41,代碼來源:SafeBoat.java

示例8: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
    if (testObserver(event.getPlayer())) {
        if (event.getTo().getY() <= -64) {
            TeamModule teamModule = Teams.getTeamById("observers").get();
            ModuleCollection<SpawnModule> modules = new ModuleCollection<>();
            for (SpawnModule spawnModule : match.getModules().getModules(SpawnModule.class)) {
                if (spawnModule.getTeam() == teamModule) modules.add(spawnModule);
            }
            event.setTo(modules.getRandom().getLocation());
        }
    }
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:14,代碼來源:ObserverModule.java


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