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


Java TeleportCause.END_PORTAL屬性代碼示例

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


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

示例1: onPlayerTeleport

@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    if (OrebfuscatorConfig.UseProximityHider) {
        if(event.getCause() != TeleportCause.END_PORTAL
                && event.getCause() != TeleportCause.NETHER_PORTAL
                )
        {
            ProximityHider.addPlayerToCheck(event.getPlayer(), null);
        }
    }
}
 
開發者ID:SamaGames,項目名稱:AntiCheat,代碼行數:11,代碼來源:OrebfuscatorPlayerListener.java

示例2: onPlayerPortal

@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onPlayerPortal(PlayerPortalEvent event)
{
  if (event.getCause() == TeleportCause.END_PORTAL) {
    if (event.getTo().getWorld().getEnvironment() == Environment.THE_END) {
      event.setTo(event.getTo().getWorld().getSpawnLocation().clone().add(0.5D, 0.0D, 0.5D));
    } else if (event.getFrom().getWorld().getEnvironment() == Environment.THE_END) {
      event.setTo(this.endExitLocation);
    }
  }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:11,代碼來源:EndListener.java

示例3: onPlayerPortal

@EventHandler
public void onPlayerPortal(PlayerPortalEvent event) {
	ExilePearl pearl = pearlApi.getPearl(event.getPlayer().getUniqueId());
	if(pearl != null && pearl.getPearlType() == PearlType.PRISON && event.getCause() == TeleportCause.END_PORTAL) {
		event.setTo(pearlApi.getPearlConfig().getPrisonWorld().getSpawnLocation());
	}
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:7,代碼來源:PlayerListener.java

示例4: b

public void b(int i) {
    if (this.dimension == 1 && i == 1) {
        this.a((Statistic) AchievementList.D);
        this.world.kill(this);
        this.viewingCredits = true;
        this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 0.0F));
    } else {
        if (this.dimension == 0 && i == 1) {
            this.a((Statistic) AchievementList.C);
            // CraftBukkit start - Rely on custom portal management
            /*
            ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn();

            if (chunkcoordinates != null) {
                this.playerConnection.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F);
            }

            i = 1;
            */
            // CraftBukkit end
        } else {
            this.a((Statistic) AchievementList.y);
        }

        // CraftBukkit start
        TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
        this.server.getPlayerList().changeDimension(this, i, cause);
        // CraftBukkit end
        this.lastSentExp = -1;
        this.bQ = -1.0F;
        this.bR = -1;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:33,代碼來源:EntityPlayer.java

示例5: b

public void b(int i) {
    if (this.dimension == 1 && i == 1) {
        this.a((Statistic) AchievementList.C);
        this.world.kill(this);
        this.viewingCredits = true;
        this.playerConnection.sendPacket(new Packet70Bed(4, 0));
    } else {
        if (this.dimension == 0 && i == 1) {
            this.a((Statistic) AchievementList.B);
            // CraftBukkit start - Rely on custom portal management
            /*
            ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn();

            if (chunkcoordinates != null) {
                this.playerConnection.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F);
            }

            i = 1;
            */
            // CraftBukkit end
        } else {
            this.a((Statistic) AchievementList.x);
        }

        // CraftBukkit start
        TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
        this.server.getPlayerList().changeDimension(this, i, cause);
        // CraftBukkit end
        this.lastSentExp = -1;
        this.bP = -1.0F;
        this.bQ = -1;
    }
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:33,代碼來源:EntityPlayer.java

示例6: onPlayerTeleport

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
	Player p = event.getPlayer();
	
	if(um.isPlaying(p.getName())) {
		if(event.getCause() == TeleportCause.END_PORTAL || event.getCause() == TeleportCause.COMMAND || event.getCause() == TeleportCause.NETHER_PORTAL) {
			event.setCancelled(true);
		}
	}
}
 
開發者ID:maker56,項目名稱:UltimateSurvivalGames,代碼行數:10,代碼來源:PlayerListener.java

示例7: travelToDimension

public void travelToDimension(int p_71027_1_)
{
    if (this.dimension == 1 && p_71027_1_ == 1)
    {
        this.triggerAchievement(AchievementList.theEnd2);
        this.worldObj.removeEntity(this);
        this.playerConqueredTheEnd = true;
        this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(4, 0.0F));
    }
    else
    {
        if (this.dimension == 0 && p_71027_1_ == 1)
        {
            this.triggerAchievement(AchievementList.theEnd);
            ChunkCoordinates chunkcoordinates = this.mcServer.worldServerForDimension(p_71027_1_).getEntrancePortalLocation();

            if (chunkcoordinates != null)
            {
                this.playerNetServerHandler.setPlayerLocation((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ, 0.0F, 0.0F);
            }

            p_71027_1_ = 1;
        }
        else
        {
            this.triggerAchievement(AchievementList.portal);
        }

        // CraftBukkit start
        TeleportCause cause = (this.dimension == 1 || p_71027_1_ == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
        this.mcServer.getConfigurationManager().transferPlayerToDimension(this, p_71027_1_, cause); // Cauldron
        // CraftBukkit end
        this.lastExperience = -1;
        this.lastHealth = -1.0F;
        this.lastFoodLevel = -1;
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:37,代碼來源:EntityPlayerMP.java

示例8: c

@Nullable
public Entity c(int i) {
    //this.ck = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
    if (this.dimension == 1 && i == 1) {
        this.ck = true; // CraftBukkit - Moved down from above
        this.world.kill(this);
        if (!this.viewingCredits) {
            this.viewingCredits = true;
            if (this.a(AchievementList.D)) {
                this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 0.0F));
            } else {
                this.b((Statistic) AchievementList.D);
                this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 1.0F));
            }
        }

        return this;
    } else {
        if (this.dimension == 0 && i == 1) {
            this.b((Statistic) AchievementList.C);
            i = 1;
        } else {
            this.b((Statistic) AchievementList.y);
        }

        // CraftBukkit start
        TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
        this.server.getPlayerList().changeDimension(this, i, cause); // PAIL: check all this
        // CraftBukkit end
        this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
        this.lastSentExp = -1;
        this.lastHealthSent = -1.0F;
        this.cc = -1;
        return this;
    }
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:36,代碼來源:EntityPlayer.java

示例9: onPlayerUsePortal

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onPlayerUsePortal(final PlayerPortalEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerUsePortal", "player=" + event.getPlayer().getName() + ";from=" + NLocation.toString(event.getFrom()) + ";to=" + NLocation.toString(event.getTo()));

    final GeneralWorld world = this.plugin.getWorlds().get(event.getFrom().getWorld().getName());
    if (GeneralWorld.WorldType.isStock(world)) {
        return;
    }

    if (world.getType() == WorldType.ADDITIONAL) {
        final AdditionalWorld additionalWorld = (AdditionalWorld)world;
        if (event.getCause() == TeleportCause.NETHER_PORTAL && !additionalWorld.hasNether()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onPlayerUsePortal", "doesn't have required subworld (nether)");
            return;
        } else if (event.getCause() == TeleportCause.END_PORTAL && !additionalWorld.hasEnd()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onPlayerUsePortal", "doesn't have required subworld (end)");
            return;
        }
    }

    final PortalEventResult result = this.handlePortalEvent(event.getFrom(), event.getCause(), event.getPortalTravelAgent());
    if (result == null) {
        return;
    }
    if (result.destination != null) {
        event.setTo(result.destination);
    }
    if (result.useTravelAgent) {
        event.useTravelAgent(true);
    }
    if (result.cancelEvent) {
        event.setCancelled(true);
    }

    this.plugin.exiting(this.getClass(), "onPlayerUsePortal");
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:38,代碼來源:NListener.java

示例10: c

public void c(int i) {
    if (this.dimension == 1 && i == 1) {
        this.a((Statistic) AchievementList.C);
        this.world.kill(this);
        this.viewingCredits = true;
        this.playerConnection.sendPacket(new Packet70Bed(4, 0));
    } else {
        if (this.dimension == 1 && i == 0) {
            this.a((Statistic) AchievementList.B);
            // CraftBukkit start - Rely on custom portal management
            /*
            ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn();

            if (chunkcoordinates != null) {
                this.playerConnection.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F);
            }

            i = 1;
            */
            // CraftBukkit end
        } else {
            this.a((Statistic) AchievementList.x);
        }

        // CraftBukkit start
        TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
        this.server.getPlayerList().changeDimension(this, i, cause);
        // CraftBukkit end
        this.lastSentExp = -1;
        this.cm = -1;
        this.cn = -1;
    }
}
 
開發者ID:didoupimpon,項目名稱:Craft-city,代碼行數:33,代碼來源:EntityPlayer.java

示例11: changeDimension

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,代碼行數:54,代碼來源:PlayerList.java

示例12: changeDimension

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,代碼行數:54,代碼來源:PlayerList.java

示例13: changeDimension

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,代碼行數:58,代碼來源:PlayerList.java

示例14: onEntityUsePortal

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onEntityUsePortal(final EntityPortalEvent event) {
    this.plugin.entering(this.getClass(), "onEntityUsePortal", "entity=" + event.getEntityType() + ";from=" + NLocation.toString(event.getFrom()) + ";to=" + NLocation.toString(event.getTo()));

    if (event.getEntityType() == EntityType.ENDER_DRAGON) {
        this.plugin.exiting(this.getClass(), "onEntityUsePortal", "EnderDragon should really stay in the End!");
        event.setCancelled(true);
        return;
    }

    final GeneralWorld world = this.plugin.getWorlds().get(event.getFrom().getWorld().getName());
    if (GeneralWorld.WorldType.isStock(world)) {
        this.plugin.exiting(this.getClass(), "onEntityUsePortal", "Stock world!");
        return;
    }

    // Build a fake TeleportCause based on From and To locations
    PlayerTeleportEvent.TeleportCause cause = null;
    final Block block = event.getFrom().getBlock();
    switch (block.getType()) {
        case PORTAL:
            cause = PlayerTeleportEvent.TeleportCause.NETHER_PORTAL;
            break;
        case ENDER_PORTAL:
            cause = PlayerTeleportEvent.TeleportCause.END_PORTAL;
            break;
        default:
            this.plugin.debug("Strange block found: " + block.getType() + ", trying to find a portal block near the Location");
            for (final BlockFace face : blockFaces) {
                if (block.getRelative(face).getType() == Material.PORTAL) {
                    cause = PlayerTeleportEvent.TeleportCause.NETHER_PORTAL;
                    this.plugin.debug("Found a Nether Portal block at " + NLocation.toString(block.getRelative(face).getLocation()));
                    break;
                } else if (block.getRelative(face).getType() == Material.ENDER_PORTAL) {
                    cause = PlayerTeleportEvent.TeleportCause.END_PORTAL;
                    this.plugin.debug("Found an End Portal block at " + NLocation.toString(block.getRelative(face).getLocation()));
                    break;
                }
            }
            if (cause == null) {
                cause = PlayerTeleportEvent.TeleportCause.PLUGIN;
            }
            break;
    }

    if (world.getType() == WorldType.ADDITIONAL) {
        final AdditionalWorld additionalWorld = (AdditionalWorld)world;
        if (cause == TeleportCause.NETHER_PORTAL && !additionalWorld.hasNether()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onEntityUsePortal", "doesn't have required subworld (nether)");
            return;
        } else if (cause == TeleportCause.END_PORTAL && !additionalWorld.hasEnd()) {
            event.setCancelled(true);
            this.plugin.exiting(this.getClass(), "onEntityUsePortal", "doesn't have required subworld (end)");
            return;
        }
    }

    final PortalEventResult result = this.handlePortalEvent(event.getFrom(), cause, event.getPortalTravelAgent());
    if (result == null) {
        this.plugin.exiting(this.getClass(), "onEntityUsePortal", "result is null");
        return;
    }
    if (result.destination != null) {
        event.setTo(result.destination);
    }
    if (result.useTravelAgent) {
        event.useTravelAgent(true);
    }
    if (result.cancelEvent) {
        event.setCancelled(true);
    }

    this.plugin.exiting(this.getClass(), "onEntityUsePortal");
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:75,代碼來源:NListener.java

示例15: changeDimension

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,代碼行數:54,代碼來源:PlayerList.java


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