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


Java PlayerTeleportEvent.getFrom方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerTeleportEvent.getFrom方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerTeleportEvent.getFrom方法的具体用法?Java PlayerTeleportEvent.getFrom怎么用?Java PlayerTeleportEvent.getFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerTeleportEvent的用法示例。


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

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

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

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

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

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

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

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

示例8: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    TeleportCause cause = event.getCause();
    
    if(cause == null || cause != TeleportCause.NETHER_PORTAL) return;
    
    Location from = event.getFrom();
    if(from.getBlock().getType() != Material.PORTAL)
    {
        event.setCancelled(true);
        return;
    }
    
    Player player = event.getPlayer();
    
    Flag flag = this.GetFlagInstanceAtLocation(from, player);
    if(flag == null) return;
    
    event.setCancelled(true);
    String [] commandLines = flag.parameters.replace("%name%", player.getName()).replace("%uuid%", player.getUniqueId().toString()).split(";");
    for(String commandLine : commandLines)
    {
        GPFlags.AddLogEntry("Nether portal command: " + commandLine);
        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandLine);
    }
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:28,代码来源:FlagDef_NetherPortalConsoleCommand.java

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

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

示例11: a

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
public void a(double d0, double d1, double d2, float f, float f1) {
    // CraftBukkit start - Delegate to teleport(Location)
    Player player = this.getPlayer();
    Location from = player.getLocation();
    Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1);
    PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
    this.server.getPluginManager().callEvent(event);

    from = event.getFrom();
    to = event.isCancelled() ? from : event.getTo();

    this.teleport(to);
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:14,代码来源:PlayerConnection.java

示例12: onTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) {
    if (event.getTo() == null || event.getFrom() == null) {
        return;
    }
    final Location f = BukkitUtil.getLocation(event.getFrom());
    final Location t = BukkitUtil.getLocation(event.getTo());
    final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
    final Player player = event.getPlayer();
    if (PlotSquared.isPlotWorld(q.getWorld())) {
        final Plot plot = MainUtil.getPlot(q);
        if (plot != null) {
            final PlotPlayer pp = BukkitUtil.getPlayer(player);
            if (plot.isDenied(pp.getUUID())) {
                if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
                    return;
                }
                MainUtil.sendMessage(pp, C.YOU_BE_DENIED);
                event.setCancelled(true);
                return;
            } else {
                if (MainUtil.enteredPlot(f, t)) {
                    plotEntry(pp, plot);
                }
            }
        } else {
            if (MainUtil.leftPlot(f, t)) {
                final Plot plot2 = MainUtil.getPlot(f);
                APlotListener.manager.plotExit(BukkitUtil.getPlayer(player), plot2);
            }
        }
        if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
            event.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:38,代码来源:PlayerEvents.java

示例13: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent e) {
    Location from = e.getFrom();
    Location to = e.getTo();
    final Player p = e.getPlayer();

    // Wait till the chunk should have loaded on the client
    // Update IF worlds are different OR chunks are different (as many teleports are in same chunk)
    if (!from.getWorld().getName().equals(to.getWorld().getName())
            || from.getChunk().getX() != to.getChunk().getX()
            || from.getChunk().getZ() != to.getChunk().getZ()) {
        // Wait for 15 ticks before we actually put it in the queue
        new BukkitRunnable() {
            @Override
            public void run() {
                plugin.getUpdater().beforeNext(new Runnable() {
                    @Override
                    public void run() {
                        if (p.isOnline()) {
                            for (Shop shop : plugin.getShopUtils().getShops()) {
                                if (shop.hasItem()) {
                                    shop.getItem().hidePlayer(p);
                                }
                                if (shop.hasHologram()) {
                                    shop.getHologram().hidePlayer(p);
                                }
                            }
                            // so next update will update correctly
                            plugin.getShopUtils().resetPlayerLocation(p);
                        }
                    }
                });
            }
        }.runTaskLater(plugin, 15L);
    }
}
 
开发者ID:EpicEricEE,项目名称:ShopChest,代码行数:37,代码来源:ShopUpdateListener.java

示例14: setPlayerLocation

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_)
{
    // CraftBukkit start - Delegate to teleport(Location)
    Player player = this.getPlayerB();
    Location from = player.getLocation();
    Location to = new Location(this.getPlayerB().getWorld(), p_147364_1_, p_147364_3_, p_147364_5_, p_147364_7_, p_147364_8_);
    PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
    this.server.getPluginManager().callEvent(event);
    from = event.getFrom();
    to = event.isCancelled() ? from : event.getTo();
    this.teleport(to);
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:13,代码来源:NetHandlerPlayServer.java

示例15: TeleporZone

import org.bukkit.event.player.PlayerTeleportEvent; //导入方法依赖的package包/类
@EventHandler
public void TeleporZone(PlayerTeleportEvent event)
{
    BytecraftPlayer player = plugin.getPlayer(event.getPlayer());
    
    Location to = event.getTo();
    Location from = event.getFrom();
    
    ZoneWorld toWorld = plugin.getWorld(to.getWorld());
    
    Zone newZone = toWorld.findZone(to);
    String newName;
    
    ZoneWorld fromWorld = plugin.getWorld(from.getWorld());
    
    Zone fromZone = fromWorld.findZone(from);
    String fromName;
    if (fromZone == null && newZone == null) {
        return;
    }
    
    if (fromZone == null) {
        fromName = "null";
    } else {
        fromName = fromZone.getName();
    }
    
    if (newZone == null) {
        newName = "null";
    } else {
        newName = newZone.getName();
    }
    
    if (fromName.equalsIgnoreCase(newName)) {
        return;
    }
    
    PlayerChangeZoneEvent customEvent = new PlayerChangeZoneEvent(to, from, player, fromZone, newZone);
    Bukkit.getServer().getPluginManager().callEvent(customEvent);
}
 
开发者ID:sabersamus,项目名称:Bytecraft,代码行数:41,代码来源:CallEventListener.java


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