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


Java PlayerTeleportEvent.getTo方法代碼示例

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


在下文中一共展示了PlayerTeleportEvent.getTo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onPlayerTeleport

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

示例4: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
   public void onPlayerTeleport(PlayerTeleportEvent e){
   	if (e.isCancelled()) {
           return;
       }
   	
   	final Player p = e.getPlayer();
   	Location lfrom = e.getFrom();
   	Location lto = e.getTo();    	
   	
   	if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)){
   		final Region rfrom = RedProtect.get().rm.getTopRegion(lfrom);
       	final Region rto = RedProtect.get().rm.getTopRegion(lto);
       	
   		if (rfrom != null && !rfrom.canTeleport(p)){
       		RPLang.sendMessage(p, "playerlistener.region.cantuse");
               e.setCancelled(true);    		
       	}
       	if (rto != null && !rto.canTeleport(p)){
       		RPLang.sendMessage(p, "playerlistener.region.cantuse");
               e.setCancelled(true);    		
       	}
   	}
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:25,代碼來源:RPMine19.java

示例5: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) {
    if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld().equals(event.getTo().getWorld())) {
        BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
        BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
        org.bukkit.Location to = event.getTo();
        if (to != null) {
            Player player = event.getPlayer();
            PlotPlayer pp = PlotPlayer.wrap(player);
            Location loc = BukkitUtil.getLocation(to);
            PlotArea area = PS.get().getPlotAreaAbs(loc);
            if (area == null) {
                return;
            }
            Plot plot = area.getPlot(loc);
            if (plot != null) {
                plotEntry(pp, plot);
            }
        }
        return;
    }
    playerMove(event);
}
 
開發者ID:IntellectualSites,項目名稱:PlotSquared,代碼行數:24,代碼來源:PlayerEvents.java

示例6: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event)
{
    Location from = event.getFrom();
    Location to = event.getTo();
    PlayerTeleport action = this.newAction(PlayerTeleport.class, from.getWorld());
    if (action != null)
    {
        action.setLocation(from);
        action.setOtherLocation(to, true);
        action.setPlayer(event.getPlayer());
        this.logAction(action);
    }
    PlayerTeleport action2 = this.newAction(PlayerTeleport.class, to.getWorld());
    if (action2 != null)
    {
        action2.setLocation(to);
        action2.setOtherLocation(from, false);
        action2.setPlayer(event.getPlayer());
        this.logAction(action2);
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:23,代碼來源:PlayerActionListener.java

示例7: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    // Strangely, sometimes these worlds can be null
    if (event.getFrom() == null || event.getTo() == null) {
        return;
    }
    // Check if they changed worlds
	UUID uuid = event.getPlayer().getUniqueId();
	if (plugin.getPlayerGHouse(uuid) == null || plugin.getPlayerGHouse(uuid).isEmpty()) {
		return;
	}
	
    World fromWorld = event.getFrom().getWorld();
    World toWorld = event.getTo().getWorld();
    // Check we are in the right world
    if (!Settings.worldName.contains(fromWorld.getName()) && !Settings.worldName.contains(toWorld.getName())) {
        return;
    }
    // Did we move a block?
    checkMove(event.getPlayer(), event.getFrom(), event.getTo(), uuid);
}
 
開發者ID:tastybento,項目名稱:greenhouses,代碼行數:22,代碼來源:GreenhouseEvents.java

示例8: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onPlayerTeleport(PlayerTeleportEvent event) {

    if (event.getTo() == null) {
        NucMsg.warning("Teleport using a null destination location detected.");
        return;
    }

    if (event.getTo().getWorld() == null) {
        NucMsg.warning("Teleport using a null world in destination location detected.");
        return;
    }

    if (event.getFrom() != null && event.getTo().getWorld().equals(event.getFrom().getWorld()))
        return;

    synchronized (_sync) {
        _lastWorldChange.put(event.getPlayer(), new Date());
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:21,代碼來源:InternalPlayerTracker.java

示例9: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
private void onPlayerTeleport(PlayerTeleportEvent event) {

    if (event.getFrom() == null || event.getTo() == null)
        return;

    // player teleporting to a different world
    if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) {

        PlayList.clearQueue(event.getPlayer());
    }

    if (event.getCause() != TeleportCause.UNKNOWN) {
        _regionManager.getPlayerWatcher()
                .updatePlayerLocation(event.getPlayer(), event.getTo(), RegionEventReason.TELEPORT);
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:18,代碼來源:JCGEventListener.java

示例10: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    if(event.isCancelled()) return;

    if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && event.getTo() != tos.get(event.getPlayer().getName())) {
        Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
        to.setPitch(event.getTo().getPitch());
        to.setYaw(event.getTo().getYaw());

        tos.put(event.getPlayer().getName(), to);
        event.getPlayer().teleport(to);

        if(System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
            event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
            pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
        }
    }
}
 
開發者ID:graywolf336,項目名稱:Jail,代碼行數:19,代碼來源:HandCuffListener.java

示例11: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public final void onPlayerTeleport(final PlayerTeleportEvent event) {
    final Location to = event.getTo();
    final double origX = to.getX();
    final double origZ = to.getZ();
    this.adjustToPos(to, wbHandler.getBorder(to.getWorld()));
    if (Double.compare(origX, to.getX()) != 0
            || Double.compare(origZ, to.getZ()) != 0) {
        event.getPlayer().sendMessage(DENY_TELEPORT);
    }
}
 
開發者ID:Mystiflow,項目名稱:WorldBorder,代碼行數:12,代碼來源:WorldBorderListener.java

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

示例13: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
    if(event.getTo() != null && event.getPlayer() != null)
    {
        handleTeleport(event.getPlayer(), event.getTo().clone());
    }
}
 
開發者ID:MrLittleKitty,項目名稱:AnnihilationPro,代碼行數:9,代碼來源:Bar.java

示例14: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    Player player = event.getPlayer();
    Location from = event.getFrom();
    Location to = event.getTo();

    if (from != null && to != null && !this.canTeleport(player, from.getWorld(), to.getWorld())) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You cannot leave the world until the bloodmoon has ended.");
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:12,代碼來源:LockInWorldListener.java

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


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