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


Java PlayerPortalEvent.getTo方法代码示例

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


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

示例1: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(PlayerPortalEvent event) {
    if (!this.worldConfig.getBoolean("special-travel-agent", true)) {
        return;
    }

    Location destination = event.getTo();

    if (destination == null) {
        return;
    }

    World targetWorld = destination.getWorld();

    if (targetWorld.getName() != this.nmsWorld.worldData.getName()) {
        return;
    }

    if (this.worldConfig.getBoolean("enabled", false)) {
        event.setPortalTravelAgent(this.portalTravelAgent);
    }
}
 
开发者ID:OtakuMegane,项目名称:TallNether,代码行数:23,代码来源:LoadHell.java

示例2: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的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

示例3: onPlayerEnterPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerEnterPortal(PlayerPortalEvent e){
	Player p = e.getPlayer();
	
	Region rto = null;
	Region from = null;
	if (e.getTo() != null){
		rto = RedProtect.get().rm.getTopRegion(e.getTo());
	}
	if (e.getFrom() != null){
		from = RedProtect.get().rm.getTopRegion(e.getFrom());
	}
	
	
	if (rto != null && !rto.canExitPortal(p)){
		RPLang.sendMessage(p, "playerlistener.region.cantteleport");
		e.setCancelled(true);
	}    
	
	if (from != null && !from.canEnterPortal(p)){
		RPLang.sendMessage(p, "playerlistener.region.cantenterteleport");
		e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPPlayerListener.java

示例4: onPortalEvent

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPortalEvent(PlayerPortalEvent event) {
    Player player = event.getPlayer();
    if (usePortals || event.getTo() == null || event.getFrom() == null ||
            (!plugin.isSkyWorld(event.getTo().getWorld()) && !plugin.isSkyWorld(event.getFrom().getWorld())))
    {
        return; // We only care about portals going into or out of skyworld
    }
    if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) {
        return;
    }
    if (event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL ||
        event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(player);
        if (islandInfo == null || (!islandInfo.contains(event.getTo()) && !islandInfo.contains(event.getFrom()))) {
            event.setCancelled(true);
            player.sendMessage(tr("\u00a7eYou can not use another islands portals!"));
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:21,代码来源:ExploitEvents.java

示例5: onPlayerPortal

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPortal(PlayerPortalEvent event) {
    EntityPortalEvent e = new EntityPortalEvent(event.getPlayer(), event.getFrom(), event.getTo(), event.getPortalTravelAgent());
    this.onEntityPortal(e);
    event.setFrom(e.getFrom());
    event.setTo(e.getTo());
    event.setPortalTravelAgent(e.getPortalTravelAgent());
    event.useTravelAgent(e.useTravelAgent());
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:10,代码来源:PortalListener.java

示例6: onPortalEnter

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPortalEnter(PlayerPortalEvent event) {
    if (event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL) {
        return;
    }

    Location to = event.getTo();
    World toWorld = to.getWorld();
    if (toWorld == null)
        return; // safe-guard if the End or Nether is disabled

    if (toWorld.getEnvironment() == World.Environment.THE_END) {
        Player player = event.getPlayer();

        // Prevent entering the end if it's closed.
        if (false /* TODO:plugin.getEndManager().isOpened() */) {
            message(player, ChatColor.RED + "The End is currently closed.");
            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is Spawn Tagged.
        PlayerTimer timer = plugin.getTimerManager().getCombatTimer();
        long remaining;
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        // Prevent entering the end if the player is PVP Protected.
        timer = plugin.getTimerManager().getInvincibilityTimer();
        if ((remaining = timer.getRemaining(player)) > 0L) {
            message(player, ChatColor.RED + "You cannot enter the End whilst your " + timer.getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]");

            event.setCancelled(true);
            return;
        }

        event.useTravelAgent(false);
        event.setTo(toWorld.getSpawnLocation().add(0.5, 0, 0.5));
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:47,代码来源:PortalListener.java

示例7: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:55,代码来源:PlayerList.java

示例8: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().t() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.t().adjustExit(entityplayer, exit, velocity); // Should be getTravelAgent
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:55,代码来源:PlayerList.java

示例9: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    org.bukkit.event.player.PlayerTeleportEvent tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(entityplayer.getBukkitEntity(), enter, exit, cause);
    Bukkit.getServer().getPluginManager().callEvent(tpEvent);
    if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
        return;
    }

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);

   
    entityplayer.ck = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:59,代码来源:PlayerList.java

示例10: changeDimension

import org.bukkit.event.player.PlayerPortalEvent; //导入方法依赖的package包/类
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
    WorldServer exitWorld = null;
    if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
        // only target existing worlds (compensate for allow-nether/allow-end as false)
        for (WorldServer world : this.server.worlds) {
            if (world.dimension == i) {
                exitWorld = world;
            }
        }
    }

    Location enter = entityplayer.getBukkitEntity().getLocation();
    Location exit = null;
    boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
    if (exitWorld != null) {
        if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
            // THE_END -> NORMAL; use bed if available, otherwise default spawn
            exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
            if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
                exit = exitWorld.getWorld().getSpawnLocation();
            }
        } else {
            // NORMAL <-> NETHER or NORMAL -> THE_END
            exit = this.calculateTarget(enter, exitWorld);
            useTravelAgent = true;
        }
    }

    TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
    PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
    event.useTravelAgent(useTravelAgent);
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled() || event.getTo() == null) {
        return;
    }

    exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
    if (exit == null) {
        return;
    }
    exitWorld = ((CraftWorld) exit.getWorld()).getHandle();

    Vector velocity = entityplayer.getBukkitEntity().getVelocity();
    boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
    exitWorld.chunkProviderServer.forceChunkLoad = true;
    exitWorld.s().adjustExit(entityplayer, exit, velocity);
    exitWorld.chunkProviderServer.forceChunkLoad = before;

    this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
    if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
        entityplayer.getBukkitEntity().setVelocity(velocity);
    }
    // CraftBukkit end
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:55,代码来源:PlayerList.java


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