Java 类org.bukkit.World.Environment 实例源码

项目:bskyblock    文件:ChunkGeneratorWorld.java   
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, ChunkGenerator.BiomeGrid biomeGrid) {
    if (world.getEnvironment().equals(World.Environment.NETHER)) {
        return generateNetherChunks(world, random, chunkX, chunkZ, biomeGrid);
    }
    ChunkData result = createChunkData(world);
    if (Settings.seaHeight != 0) {
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                for (int y = 0; y < Settings.seaHeight; y++) {
                    result.setBlock(x, y, z, Material.STATIONARY_WATER);
                }
            }
        }

    }
    return result;
}
项目:ProtocolSupportPocketStuff    文件:DimensionPacket.java   
private static int toPocketDimension(Environment dimId) {
    switch (dimId) {
        case NETHER: {
            return 1;
        }
        case THE_END: {
            return 2;
        }
        case NORMAL: {
            return 0;
        }
        default: {
            throw new IllegalArgumentException(String.format("Unknown dim id %s", dimId));
        }
    }
}
项目:DragonEggDrop    文件:RespawnListeners.java   
@EventHandler
public void onPlayerSwitchWorlds(PlayerChangedWorldEvent event) {
    World world = event.getPlayer().getWorld();
    if (world.getEnvironment() != Environment.THE_END) return;

    EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);

    // Start the respawn countdown if joining an empty world
    if (plugin.getConfig().getBoolean("respawn-on-join", false)) {
        if (world.getPlayers().size() > 1 || worldWrapper.isRespawnInProgress()
                || world.getEntitiesByClass(EnderDragon.class).size() == 0) 
            return;

        manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
    }

    // Reset end crystal states just in case something went awry
    if (!worldWrapper.isRespawnInProgress()) {
        world.getEntitiesByClass(EnderCrystal.class).forEach(e -> {
            e.setInvulnerable(false);
            e.setBeamTarget(null);
        });
    }
}
项目:DragonEggDrop    文件:PortalClickListener.java   
@EventHandler
public void onClickEndPortalFrame(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    World world = player.getWorld();
    Block clickedBlock = event.getClickedBlock();
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || world.getEnvironment() != Environment.THE_END 
            || clickedBlock.getType() != Material.BEDROCK || event.getHand() != EquipmentSlot.HAND
            || (player.getInventory().getItemInMainHand() != null || player.getInventory().getItemInOffHand() != null)) return;

    NMSAbstract nmsAbstract = plugin.getNMSAbstract();
    DragonBattle dragonBattle = nmsAbstract.getEnderDragonBattleFromWorld(world);
    Location portalLocation = dragonBattle.getEndPortalLocation();

    if (event.getClickedBlock().getLocation().distanceSquared(portalLocation) > 36) return; // 5 blocks

    EndWorldWrapper endWorld = plugin.getDEDManager().getWorldWrapper(world);
    int secondsRemaining = endWorld.getTimeUntilRespawn();
    if (secondsRemaining <= 0) return;

    plugin.sendMessage(player, "Dragon will respawn in " + ChatColor.YELLOW + secondsRemaining);
}
项目:BloodMoon    文件:NetherSkyListener.java   
private void sendWorldEnvironment(Player player, Environment environment) {
    CraftPlayer craftPlayer = (CraftPlayer) player;
    CraftWorld world = (CraftWorld) player.getWorld();
    Location location = player.getLocation();

    PacketPlayOutRespawn packet = new PacketPlayOutRespawn(environment.getId(), EnumDifficulty.getById(world.getDifficulty().getValue()), WorldType.NORMAL, WorldSettings.EnumGamemode.getById(player.getGameMode().getValue()));

    craftPlayer.getHandle().playerConnection.sendPacket(packet);

    int viewDistance = plugin.getServer().getViewDistance();

    int xMin = location.getChunk().getX() - viewDistance;
    int xMax = location.getChunk().getX() + viewDistance;
    int zMin = location.getChunk().getZ() - viewDistance;
    int zMax = location.getChunk().getZ() + viewDistance;

    for (int x = xMin; x < xMax; ++x) {
        for (int z = zMin; z < zMax; ++z) {
            world.refreshChunk(x, z);
        }
    }

    //player.updateInventory(); Possibly no longer needed
}
项目:Thermos    文件:ThermiteTeleportationHandler.java   
public static void transferEntityToDimension(Entity ent, int dim, ServerConfigurationManager manager, Environment environ) {

        if (ent instanceof EntityPlayerMP) {
            transferPlayerToDimension((EntityPlayerMP) ent, dim, manager, environ);
            return;
        }
        WorldServer worldserver = manager.getServerInstance().worldServerForDimension(ent.dimension);
        ent.dimension = dim;
        WorldServer worldserver1 = manager.getServerInstance().worldServerForDimension(ent.dimension);
        worldserver.removePlayerEntityDangerously(ent);
        if (ent.riddenByEntity != null) {
            ent.riddenByEntity.mountEntity(null);
        }
        if (ent.ridingEntity != null) {
            ent.mountEntity(null);
        }
        ent.isDead = false;
        transferEntityToWorld(ent, worldserver, worldserver1);
    }
项目:GriefPreventionPlus    文件:RestoreNatureProcessingTask.java   
private void removeDumpedFluids()
{
    //remove any surface water or lava above sea level, presumed to be placed by players
    //sometimes, this is naturally generated.  but replacing it is very easy with a bucket, so overall this is a good plan
    if(this.environment == Environment.NETHER) return;
    for(int x = 1; x < snapshots.length - 1; x++)
    {
        for(int z = 1; z < snapshots[0][0].length - 1; z++)
        {
            for(int y = this.seaLevel - 1; y < snapshots[0].length - 1; y++)
            {
                BlockSnapshot block = snapshots[x][y][z];
                if(block.typeId == Material.STATIONARY_WATER.getId() || block.typeId == Material.STATIONARY_LAVA.getId() ||
                   block.typeId == Material.WATER.getId() || block.typeId == Material.LAVA.getId())
                {
                    block.typeId = Material.AIR.getId();
                }
            }
        }
    }
}
项目:MyiuLib    文件:MGUtil.java   
/**
 * Determines the environment of the given world based on its folder
 * structure.
 *
 * @param world the name of the world to determine the environment of
 * @return the environment of the given world
 * @since 0.3.0
 */
public static Environment getEnvironment(String world) {
    File worldFolder = new File(Bukkit.getWorldContainer(), world);
    if (worldFolder.exists()) {
        for (File f : worldFolder.listFiles()) {
            if (f.getName().equals("region")) {
                return Environment.NORMAL;
            }
            else if (f.getName().equals("DIM1")) {
                return Environment.THE_END;
            }
            else if (f.getName().equals("DIM-1")) {
                return Environment.NETHER;
            }
        }
    }
    return null;
}
项目:Peacecraft    文件:WorldManager.java   
public void createWorld(String name, long seed, String generator, Environment env, WorldType type, boolean genStructures, boolean providedSeed) {
    name = name.toLowerCase();
    World w = this.createBukkitWorld(name, seed, generator, env, type, genStructures, providedSeed);
    this.database.setValue("worlds." + name + ".seed", seed);
    if(generator != null) {
        this.database.setValue("worlds." + name + ".generator", generator);
    }

    this.database.setValue("worlds." + name + ".environment", env.name());
    this.database.setValue("worlds." + name + ".type", type.name());
    this.database.setValue("worlds." + name + ".generateStructures", genStructures);
    this.database.setValue("worlds." + name + ".pvp", false);
    this.database.setValue("worlds." + name + ".difficulty", Difficulty.EASY.name());
    this.database.setValue("worlds." + name + ".gamemode", GameMode.SURVIVAL.name());
    WorldData world = new WorldData(this.module, this, name);
    world.setWorld(w);
    this.worlds.put(name, world);
}
项目:civcraft    文件:ArenaManager.java   
private static World createArenaWorld(ConfigArena arena, String name) {
    World world;
    world = Bukkit.getServer().getWorld(name);
    if (world == null) {
        WorldCreator wc = new WorldCreator(name);
        wc.environment(Environment.NORMAL);
        wc.type(WorldType.FLAT);
        wc.generateStructures(false);

        world = Bukkit.getServer().createWorld(wc);
        world.setAutoSave(false);
        world.setSpawnFlags(false, false);
        world.setKeepSpawnInMemory(false);
        ChunkCoord.addWorld(world);
    }

    return world;
}
项目:acidisland    文件:ChunkGeneratorWorld.java   
@SuppressWarnings("deprecation")
public byte[][] generateBlockSections(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) {
    // Bukkit.getLogger().info("DEBUG: world environment = " +
    // world.getEnvironment().toString());
    if (world.getEnvironment().equals(World.Environment.NETHER)) {
        return generateNetherBlockSections(world, random, chunkX, chunkZ, biomeGrid);
    }
    byte[][] result = new byte[world.getMaxHeight() / 16][];
    if (Settings.seaHeight == 0) {
        return result;
    } else {
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                for (int y = 0; y < Settings.seaHeight; y++) {
                    setBlock(result, x, y, z, (byte) Material.STATIONARY_WATER.getId()); // Stationary
                    // Water
                    // Allows stuff to fall through into oblivion, thus
                    // keeping lag to a minimum
                }
            }
        }
        return result;
    }
}
项目:askyblock    文件:ChunkGeneratorWorld.java   
@SuppressWarnings("deprecation")
public byte[][] generateBlockSections(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) {
    // Bukkit.getLogger().info("DEBUG: world environment = " +
    // world.getEnvironment().toString());
    if (world.getEnvironment().equals(World.Environment.NETHER)) {
        return generateNetherBlockSections(world, random, chunkX, chunkZ, biomeGrid);
    }
    byte[][] result = new byte[world.getMaxHeight() / 16][];
    if (Settings.seaHeight == 0) {
        return result;
    } else {
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                for (int y = 0; y < Settings.seaHeight; y++) {
                    setBlock(result, x, y, z, (byte) Material.STATIONARY_WATER.getId()); // Stationary
                    // Water
                    // Allows stuff to fall through into oblivion, thus
                    // keeping lag to a minimum
                }
            }
        }
        return result;
    }
}
项目:Cauldron    文件:DimensionManager.java   
public static boolean registerProviderType(int id, Class<? extends WorldProvider> provider, boolean keepLoaded)
{
    if (providers.containsKey(id))
    {
        return false;
    }
    // Cauldron start - register provider with bukkit and add appropriate config option
    String worldType = "unknown";
    if (id != -1 && id != 0 && id != 1) // ignore vanilla
    {
        worldType = provider.getSimpleName().toLowerCase();
        worldType = worldType.replace("worldprovider", "");
        worldType = worldType.replace("provider", "");
        registerBukkitEnvironment(id, worldType);
    }
    else
    {
        worldType = Environment.getEnvironment(id).name().toLowerCase();
    }
    keepLoaded = MinecraftServer.getServer().cauldronConfig.getBoolean("world-environment-settings." + worldType + ".keep-world-loaded", keepLoaded);
    // Cauldron end
    providers.put(id, provider);
    classToProviders.put(provider, id);
    spawnSettings.put(id, keepLoaded);
    return true;
}
项目:SwornCritters    文件:CreatureSpawnTask.java   
public CreatureSpawnTask(SwornCritters plugin)
{
    this.plugin = plugin;
    this.spawnChance = plugin.getConfig().getInt("spawnChance");
    this.monsterCapPerPlayer = plugin.getConfig().getInt("monsterCapPerPlayer");
    this.animalCapPerPlayer = plugin.getConfig().getInt("animalCapPerPlayer");

    this.passiveEntities = new HashMap<Environment, List<EntityType>>();
    this.hostileEntities = new HashMap<Environment, List<EntityType>>();

    this.passiveEntities.put(World.Environment.NORMAL, getEntityListFromConfig("passiveNormal"));
    this.passiveEntities.put(World.Environment.THE_END, getEntityListFromConfig("passiveEnd"));
    this.passiveEntities.put(World.Environment.NETHER, getEntityListFromConfig("passiveNether"));
    this.hostileEntities.put(World.Environment.NORMAL, getEntityListFromConfig("hostileNormal"));
    this.hostileEntities.put(World.Environment.THE_END, getEntityListFromConfig("hostileEnd"));
    this.hostileEntities.put(World.Environment.NETHER, getEntityListFromConfig("hostileNether"));
}
项目:greenhouses    文件:GreenhouseEvents.java   
/**
 * Permits water to be placed in the Nether if in a greenhouse and in an acceptable biome 
 * @param event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onPlayerInteract(PlayerInteractEvent event){        
    Player player = event.getPlayer();
    World world = player.getWorld();
    // Check we are in the right world
    if (!Settings.worldName.contains(world.getName())) {
        return;
    }
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        // Find out which greenhouse the player is in
        if(event.getClickedBlock().getWorld().getEnvironment() == Environment.NETHER 
                && event.getItem() != null && event.getItem().getType() == Material.WATER_BUCKET) {
            Greenhouse g = plugin.players.getInGreenhouse(player);
            if (g != null && !g.getBiome().equals(Biome.HELL) && !g.getBiome().equals(Biome.DESERT)
                    && !g.getBiome().equals(Biome.DESERT_HILLS)) {
                event.setCancelled(true);
                event.getClickedBlock().getRelative(event.getBlockFace()).setType(Material.WATER);
            }
        }
    }
}
项目:greenhouses    文件:GreenhouseEvents.java   
/**
 * Makes water in the Nether if ice is broken and in a greenhouse
 * @param event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onIceBreak(BlockBreakEvent event){        
    Player player = event.getPlayer();
    World world = player.getWorld();
    // Check we are in the right world
    if (!Settings.worldName.contains(world.getName())) {
        return;
    }
    // Find out which greenhouse the player is in
    if(event.getBlock().getWorld().getEnvironment() == Environment.NETHER 
            && event.getBlock().getType() == Material.ICE) {
        Greenhouse g = plugin.players.getInGreenhouse(player);
        if (g != null && !g.getBiome().equals(Biome.HELL) && !g.getBiome().equals(Biome.DESERT)
                && !g.getBiome().equals(Biome.DESERT_HILLS)) {
            event.setCancelled(true);
            event.getBlock().setType(Material.WATER);
        }
    }
}
项目:greenhouses    文件:GreenhouseEvents.java   
/**
 * Prevents placing of blocks above the greenhouses
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
public void onPlayerBlockPlace(final BlockPlaceEvent e) {
    if (!Settings.worldName.contains(e.getPlayer().getWorld().getName())) {
        return;
    }
    if (e.getPlayer().getWorld().getEnvironment().equals(Environment.NETHER)) {
        return;
    }
    // If the offending block is not above a greenhouse, forget it!
    Greenhouse g = plugin.aboveAGreenhouse(e.getBlock().getLocation());
    if (g == null) {
        return;
    }
    e.getPlayer().sendMessage(ChatColor.RED + Locale.eventcannotplace);
    e.getPlayer().sendMessage("Greenhouse is at " + g.getPos1() + " to " + g.getPos2());
    e.setCancelled(true);
}
项目:CraftoPlugin    文件:WhiteBlacklistMenuListener.java   
void handleBlockInteraction(final PlayerInteractEvent event, final Menu menu) {
    if (!this.module.getState().isEnabled() || !event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { return; }

    final Player player = event.getPlayer();
    final Block block = event.getClickedBlock();

    // Checks: Itemcheck, Worldcheck, Blocktypecheck, Regioncheck
    if (Utility.getItemInHand(player).isPresent() || !player.isSneaking()) {return; }
    if (!player.getWorld().getEnvironment().equals(Environment.NORMAL)) { return; }
    if (!this.module.canBeProtected(block.getType(), block.getLocation())) { return; }
    if (!ProtUtils.doesRegionAllowProtections(this.module, player.getLocation(), player)) { return; }

    // Check if the block is protected
    Protection prot = this.module.cache.getByLoc(block.getX(), block.getY(), block.getZ()).orElse(null);
    if (prot == null) { return; }

    this.handleInteraction(prot, player, menu);
}
项目:CraftoPlugin    文件:WhiteBlacklistMenuListener.java   
void handleEntityInteraction(final PlayerInteractEntityEvent event, final Menu menu) {
    if (!this.module.getState().isEnabled()) { return; }

    final Player player = event.getPlayer();
    final Entity entity = event.getRightClicked();

    // Checks: Itemcheck, Worldcheck, Entitytypecheck, Regioncheck
    if (Utility.getItemInHand(player).isPresent() || !player.isSneaking()) { return; }
    if (!player.getWorld().getEnvironment().equals(Environment.NORMAL)) { return; }
    if (!this.module.canBeProtected(entity.getType(), entity.getLocation())) { return; }
    if (!ProtUtils.doesRegionAllowProtections(this.module, player.getLocation(), player)) { return; }

    // Check if the entity is protected
    Protection prot = this.module.cache.getByUniqueId(entity.getUniqueId()).orElse(null);
    if (prot == null) { return; }

    this.handleInteraction(prot, player, menu);
}
项目:CraftoPlugin    文件:ProtectionModule.java   
@Override
public Protection protect(final StoredPlayer owner, final Entity entity) {
    Check.nonNulls("The owner/entity cannot be null!", owner, entity);

    // Typecheck
    if (!this.canBeProtected(entity.getType(), entity.getLocation())) { throw new IllegalArgumentException("The specified block cant be protected!"); }

    // Worldcheck
    if (!entity.getWorld().getEnvironment().equals(Environment.NORMAL)) { throw new IllegalArgumentException("The given entity is not on the surface world!"); }

    if (this.cache.contains(entity.getUniqueId())) { return this.cache.getByUniqueId(entity.getUniqueId()).get(); }
    final StoredEntity storedEntity = SharedTablesModule.instance().get().getOrCreateEntity(entity);

    final EntityProtection prot = new EntityProtection(this, owner, entity.getLocation(), storedEntity, false, false);
    this.cache.store(prot);
    this.scheduler.scheduleInsert( prot );

    return prot;
}
项目:MGLib    文件:MGUtil.java   
/**
 * Determines the environment of the given world based on its folder
 * structure.
 *
 * @param world the name of the world to determine the environment of
 * @return the environment of the given world
 * @since 0.3.0
 */
public static Environment getEnvironment(String world) {
    File worldFolder = new File(Bukkit.getWorldContainer(), world);
    if (worldFolder.exists()) {
        for (File f : worldFolder.listFiles()) {
            if (f.getName().equals("region")) {
                return Environment.NORMAL;
            }
            else if (f.getName().equals("DIM1")) {
                return Environment.THE_END;
            }
            else if (f.getName().equals("DIM-1")) {
                return Environment.NETHER;
            }
        }
    }
    return null;
}
项目:NPlugins    文件:AdditionalSubWorld.java   
public AdditionalSubWorld(final NWorld instance, final AdditionalWorld parentWorld, final NLocation spawnLocation, final String requiredPermission, final boolean enabled, final boolean hidden, final Environment type) {
    super(instance);
    this.parentWorld = parentWorld;
    String worldName = parentWorld.getWorldName();
    if (type == Environment.NETHER) {
        worldName += "_nether";
        this.setType(WorldType.ADDITIONAL_SUB_NETHER);
        parentWorld.setNetherWorld(this);
    } else if (type == Environment.THE_END) {
        worldName += "_the_end";
        this.setType(WorldType.ADDITIONAL_SUB_END);
        parentWorld.setEndWorld(this);
    } else {
        throw new IllegalArgumentException("Invalid sub-world type: " + type);
    }
    this.setWorldName(worldName);
    this.setSpawnLocation(spawnLocation);
    this.setRequiredPermission(requiredPermission);
    this.setEnabled(enabled);
    this.setHidden(hidden);
    if (!this.plugin.getWorlds().containsKey(worldName)) {
        this.plugin.getWorlds().put(worldName, this);
    }
}
项目:NPlugins    文件:ChunkListener.java   
/**
 * Remove the unloaded EnderDragons from the loaded set
 *
 * @param event a Chunk Unload Event
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onEndChunkUnload(final ChunkUnloadEvent event) {
    if (event.getWorld().getEnvironment() == Environment.THE_END) {
        final String worldName = event.getWorld().getName();
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(worldName));
        if (handler != null) {
            EndChunk chunk = handler.getChunks().getChunk(event.getChunk());
            if (chunk == null) {
                chunk = handler.getChunks().addChunk(event.getChunk());
            }
            for (final Entity e : event.getChunk().getEntities()) {
                if (e.getType() == EntityType.ENDER_DRAGON) {
                    final EnderDragon ed = (EnderDragon)e;
                    handler.getLoadedDragons().remove(ed.getUniqueId());
                    chunk.incrementSavedDragons();
                }
            }
        }
    }
}
项目:NPlugins    文件:WorldListener.java   
/**
 * Creates an EndWorldHandler if the loaded world is an End world
 *
 * @param event a World Load Event
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onWorldLoad(final WorldLoadEvent event) {
    if (event.getWorld().getEnvironment() == Environment.THE_END) {
        this.plugin.getLogger().info("Additional End world detected: handling " + event.getWorld().getName());
        final EndWorldHandler handler = new EndWorldHandler(this.plugin, event.getWorld());
        try {
            handler.loadConfig();
            handler.loadChunks();
            this.plugin.getWorldHandlers().put(handler.getCamelCaseWorldName(), handler);
            handler.init();
        } catch (final IOException | InvalidConfigurationException e) {
            this.plugin.getLogger().severe("An error occured, stacktrace follows:");
            e.printStackTrace();
        }
    }
}
项目:NPlugins    文件:WorldListener.java   
/**
 * Creates an EndWorldHandler if the loaded world is an End world
 *
 * @param event a World Unload Event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onWorldUnload(final WorldUnloadEvent event) {
    if (event.getWorld().getEnvironment() == Environment.THE_END) {
        this.plugin.getLogger().info("Handling " + event.getWorld().getName() + " unload");
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getWorld().getName()));
        if (handler != null) {
            try {
                handler.unload(false);
            } catch (final InvalidConfigurationException e) {
                this.plugin.getLogger().severe("An error occured, stacktrace follows:");
                e.printStackTrace();
            }
        }
    }
}
项目:Ghosts    文件:Misc.java   
/**
 * Gets a random location near the specified location in a range of range
 *
 */
public static Location getRandomLocation(Location location, int minRange, int maxRange) {
    World world = location.getWorld();
    int blockX = location.getBlockX();
    int blockZ = location.getBlockZ();

    int distance;
    distance = minRange + random.nextInt(maxRange - minRange);
    blockX = (random.nextBoolean()) ? blockX + (distance) : blockX - (distance);

    distance = minRange + random.nextInt(maxRange - minRange);
    blockZ = (random.nextBoolean()) ? blockZ + (distance) : blockZ - (distance);

    int blockY = (Config.getInstance().getRespawnFromSky()) ? world.getMaxHeight() : world.getHighestBlockYAt(blockX, blockZ);

    if (world.getEnvironment() == Environment.NETHER) {
        for (int i = 0; i < world.getMaxHeight(); i++) {
            if (world.getBlockAt(blockX, i, blockZ).getType() == Material.AIR) {
                blockY = i;
                break;
            }
        }
    }

    return new Location(world, blockX, blockY, blockZ);
}
项目:AntiCheat    文件:Calculations.java   
private static void addBlocksToPalette(ChunkMapManager manager, Environment environment) {
    if(!manager.inputHasNonAirBlock()) {
        return;
    }

    int[] list = environment == Environment.NETHER
            ? OrebfuscatorConfig.NetherPaletteBlocks
            : OrebfuscatorConfig.NormalPaletteBlocks;

    for(int id : list) {
        int blockData = ChunkMapManager.getBlockDataFromId(id);
        manager.addToOutputPalette(blockData);
    }
}
项目:SamaGamesAPI    文件:SkyFactory.java   
private int getID(Environment env)
{
    if (env == Environment.NETHER)
        return -1;
    else if (env == Environment.NORMAL)
        return 0;
    else if (env == Environment.THE_END)
        return 1;
    else
        return -1;
}
项目:ProjectAres    文件:MapInfo.java   
public MapInfo(SemanticVersion proto,
               @Nullable String slug,
               String name,
               SemanticVersion version,
               MapDoc.Edition edition,
               MapDoc.Phase phase,
               @Nullable BaseComponent game,
               MapDoc.Genre genre,
               Set<MapDoc.Gamemode> gamemodes,
               BaseComponent objective,
               List<Contributor> authors,
               List<Contributor> contributors,
               List<String> rules,
               @Nullable Difficulty difficulty,
               Environment dimension,
               boolean friendlyFire) {

    this.id = new MapId(slug != null ? slug : MapId.slugifyName(name), edition, phase);

    this.proto = checkNotNull(proto);
    this.name = checkNotNull(name);
    this.version = checkNotNull(version);
    this.game = game;
    this.genre = checkNotNull(genre);
    this.gamemodes = checkNotNull(gamemodes);
    this.objective = checkNotNull(objective);
    this.authors = checkNotNull(authors);
    this.contributors = checkNotNull(contributors);
    this.rules = checkNotNull(rules);
    this.difficulty = difficulty;
    this.dimension = checkNotNull(dimension);
    this.friendlyFire = friendlyFire;

}
项目:Sunscreen    文件:CombustionListener.java   
/**
 * Triggers when something combusts in the world.
 * 
 * @param event
 *            The event being fired.
 * @author HomieDion
 * @since 1.1.0
 */
@EventHandler(ignoreCancelled = true)
public void onCombust(final EntityCombustEvent event) {
    // Ignore if this is caused by an event lower down the chain.
    if (event instanceof EntityCombustByEntityEvent || event instanceof EntityCombustByBlockEvent) {
        return;
    }

    // Variables
    final EntityType type = event.getEntityType();
    final World world = event.getEntity().getWorld();

    // Ignore world's without sunlight
    if (world.getEnvironment() != Environment.NORMAL) {
        return;
    }

    // Ignore disabled worlds
    if (settings.isDisabledWorld(world)) {
        return;
    }

    // Ignore someone without sunscreen
    if (!settings.hasSunscreen(type)) {
        return;
    }

    // Prevent the target from burning.
    event.setCancelled(true);
}
项目:HCFCore    文件:EndListener.java   
@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);
    }
  }
}
项目:HCFCore    文件:EndListener.java   
@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);
    }
  }
}
项目:DragonEggDrop    文件:EndWorldWrapper.java   
/**
 * Construct a new EndWorldWrapper around an existing world
 * 
 * @param plugin the plugin instance
 * @param world the world to wrap
 */
protected EndWorldWrapper(DragonEggDrop plugin, World world) {
    this.plugin = plugin;
    this.world = world.getUID();

    if (world.getEnvironment() != Environment.THE_END)
        throw new IllegalArgumentException("EndWorldWrapper worlds must be of environment \"THE_END\"");
}
项目:DragonEggDrop    文件:RespawnListeners.java   
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    // Version notification
    Player player = event.getPlayer();
    if (player.isOp() && plugin.isNewVersionAvailable()) {
        this.plugin.sendMessage(player, ChatColor.GRAY + "A new version is available for download (Version " + this.plugin.getNewVersion() + "). " + RESOURCE_PAGE);
    }

    World world = player.getWorld();
    if (world.getEnvironment() != Environment.THE_END) return;

    EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);

    // Reset end crystal states just in case something went awry
    if (!worldWrapper.isRespawnInProgress()) {
        world.getEntitiesByClass(EnderCrystal.class).forEach(e -> {
            e.setInvulnerable(false);
            e.setBeamTarget(null);
        });
    }

    // Dragon respawn logic
    if (!plugin.getConfig().getBoolean("respawn-on-join", false)) return;
    if (!world.getPlayers().isEmpty() || manager.getWorldWrapper(world).isRespawnInProgress()
            || world.getEntitiesByClass(EnderDragon.class).size() == 0) 
        return;

    manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
}
项目:DragonEggDrop    文件:LootListeners.java   
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    Item item = event.getEntity();
    ItemStack stack = item.getItemStack();
    World world = item.getWorld();

    if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG
            || stack.hasItemMeta()) return;

    DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle();
    DragonLoot loot = dragon.getLoot();

    String eggName = loot.getEggName().replace("%dragon%", dragon.getName());
    List<String> eggLore = loot.getEggLore().stream()
            .map(s -> s.replace("%dragon%", dragon.getName()))
            .collect(Collectors.toList());

    ItemMeta eggMeta = stack.getItemMeta();

    if (eggName != null && !eggName.isEmpty()) {
        eggMeta.setDisplayName(eggName);
    }
    if (eggLore != null && !eggLore.isEmpty()) {
        eggMeta.setLore(eggLore);
    }

    stack.setItemMeta(eggMeta);
}
项目:DragonEggDrop    文件:LootListeners.java   
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();

    if (!(entity instanceof EnderCrystal) || event.getEntity().getWorld().getEnvironment() != Environment.THE_END
            || !entity.isInvulnerable()) return;

    event.setCancelled(true);
}
项目:DragonEggDrop    文件:DragonLifeListeners.java   
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (!(event.getEntity() instanceof EnderDragon)) return;

    EnderDragon dragon = (EnderDragon) event.getEntity();
    if (dragon.getWorld().getEnvironment() != Environment.THE_END) return;

    DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);
    EndWorldWrapper world = plugin.getDEDManager().getWorldWrapper(dragon.getWorld());

    if (plugin.getConfig().getBoolean("strict-countdown") && world.isRespawnInProgress()) {
        world.stopRespawn();
    }

    DragonTemplate template = plugin.getDEDManager().getRandomTemplate();
    if (template != null) {
        template.applyToBattle(plugin.getNMSAbstract(), dragon, dragonBattle);
        world.setActiveBattle(template);

        if (template.shouldAnnounceRespawn()) {
            Bukkit.getOnlinePlayers().forEach(p -> p.sendMessage(
                    ChatColor.DARK_GRAY + "[" + ChatColor.RED.toString() + ChatColor.BOLD + "!!!" + ChatColor.DARK_GRAY + "] " 
                    + template.getName() + ChatColor.DARK_GRAY + " has respawned in the end!")
            );
        }
    }

    BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.DRAGON_RESPAWNING, BattleState.BATTLE_COMMENCED);
    Bukkit.getPluginManager().callEvent(bscEventCrystals);
}
项目:TallNether    文件:LoadHell.java   
public void overrideGenerator() {
    String worldName = this.world.getName();
    this.originalGenerator = this.nmsWorld.getChunkProviderServer().chunkGenerator;
    String originalGenName = this.originalGenerator.getClass().getSimpleName();
    boolean genFeatures = this.nmsWorld.getWorldData().shouldGenerateMapFeatures();
    long worldSeed = this.nmsWorld.getSeed();
    Environment environment = this.world.getEnvironment();

    if (environment != Environment.NETHER) {
        this.messages.unknownEnvironment(worldName, environment.toString());
        return;
    }

    if (originalGenName.equals("TallNether_ChunkProviderHell")) {
        this.messages.alreadyEnabled(worldName);
        return;
    }

    try {
        Field cp = net.minecraft.server.v1_9_R1.ChunkProviderServer.class.getDeclaredField("chunkGenerator");
        cp.setAccessible(true);

        if (!originalGenName.equals("NetherChunkGenerator") && !originalGenName.equals("TimedChunkGenerator")) {
            this.messages.unknownGenerator(worldName, originalGenName);
            return;
        }

        TallNether_ChunkProviderHell generator = new TallNether_ChunkProviderHell(this.nmsWorld, genFeatures,
                worldSeed, this.worldConfig, this.plugin);
        setFinal(cp, generator);
    } catch (Exception e) {
        e.printStackTrace();
    }

    this.messages.enabledSuccessfully(worldName);
}
项目:TallNether    文件:LoadHell.java   
public void overrideGenerator() {
    String worldName = this.world.getName();
    this.originalGenerator = this.nmsWorld.getChunkProviderServer().chunkGenerator;
    String originalGenName = this.originalGenerator.getClass().getSimpleName();
    boolean genFeatures = this.nmsWorld.getWorldData().shouldGenerateMapFeatures();
    long worldSeed = this.nmsWorld.getSeed();
    Environment environment = this.world.getEnvironment();

    if (environment != Environment.NETHER) {
        this.messages.unknownEnvironment(worldName, environment.toString());
        return;
    }

    if (originalGenName.equals("TallNether_ChunkProviderHell")) {
        this.messages.alreadyEnabled(worldName);
        return;
    }

    try {
        Field cp = net.minecraft.server.v1_9_R2.ChunkProviderServer.class.getDeclaredField("chunkGenerator");
        cp.setAccessible(true);

        if (!originalGenName.equals("NetherChunkGenerator") && !originalGenName.equals("TimedChunkGenerator")) {
            this.messages.unknownGenerator(worldName, originalGenName);
            return;
        }

        TallNether_ChunkProviderHell generator = new TallNether_ChunkProviderHell(this.nmsWorld, genFeatures,
                worldSeed, this.worldConfig, this.plugin);
        setFinal(cp, generator);
    } catch (Exception e) {
        e.printStackTrace();
    }

    this.messages.enabledSuccessfully(worldName);
}
项目:TallNether    文件:LoadHell.java   
public void overrideGenerator() {
    String worldName = this.world.getName();
    this.originalGenerator = this.nmsWorld.getChunkProviderServer().chunkGenerator;
    String originalGenName = this.originalGenerator.getClass().getSimpleName();
    boolean genFeatures = this.nmsWorld.getWorldData().shouldGenerateMapFeatures();
    long worldSeed = this.nmsWorld.getSeed();
    Environment environment = this.world.getEnvironment();

    if (environment != Environment.NETHER) {
        this.messages.unknownEnvironment(worldName, environment.toString());
        return;
    }

    if (originalGenName.equals("TallNether_ChunkProviderHell")) {
        this.messages.alreadyEnabled(worldName);
        return;
    }

    try {
        Field cp = net.minecraft.server.v1_10_R1.ChunkProviderServer.class.getDeclaredField("chunkGenerator");
        cp.setAccessible(true);

        if (!originalGenName.equals("NetherChunkGenerator") && !originalGenName.equals("TimedChunkGenerator")) {
            this.messages.unknownGenerator(worldName, originalGenName);
            return;
        }

        TallNether_ChunkProviderHell generator = new TallNether_ChunkProviderHell(this.nmsWorld, genFeatures,
                worldSeed, this.worldConfig, this.plugin);
        setFinal(cp, generator);
    } catch (Exception e) {
        e.printStackTrace();
    }

    this.messages.enabledSuccessfully(worldName);
}