Package org.bukkit.generator

Examples of org.bukkit.generator.ChunkGenerator


     * @param name Name of the generator to retrieve
     * @param output Where to output if errors are present
     * @return Resulting generator, or null
     */
    public static ChunkGenerator getGeneratorForName(String world, String name, CommandSender output) {
        ChunkGenerator result = null;

        if (world == null) {
            throw new IllegalArgumentException("World name must be specified");
        }

View Full Code Here


    MyWorlds.plugin.log(Level.INFO, msg.toString());
   
    final int retrycount = 3;
    World w = null;
    int i = 0;
    ChunkGenerator cgen = null;
    try {
      if (chunkGeneratorName != null) {
        cgen = getGenerator(worldname, chunkGeneratorName);
      }
    } catch (Exception ex) {}
View Full Code Here

   */
  public String getChunkGeneratorName() {
    if (this.chunkGeneratorName == null) {
      World world = this.getWorld();
      if (world != null) {
        ChunkGenerator gen = world.getGenerator();
        if (gen != null) {
          Plugin genPlugin = CommonUtil.getPluginByClass(gen.getClass());
          if (genPlugin != null) {
            this.chunkGeneratorName = genPlugin.getName();
          }
        }
      }
View Full Code Here

    private ChunkGenerator getGenerator(String name, Environment environment, WorldType type) {
        // find generator based on configuration
        ConfigurationSection worlds = config.getWorlds();
        if (worlds != null) {
            String genName = worlds.getString(name + ".generator", null);
            ChunkGenerator generator = WorldCreator.getGeneratorForName(name, genName, getConsoleSender());
            if (generator != null) {
                return generator;
            }
        }
View Full Code Here

        name = creator.name();
        environment = creator.environment();
        worldType = creator.type();
        generateStructures = creator.generateStructures();

        final ChunkGenerator generator = creator.generator();
        storageProvider = new AnvilWorldStorageProvider(new File(server.getWorldContainer(), name));
        storageProvider.setWorld(this);
        chunks = new ChunkManager(this, storageProvider.getChunkIoService(), generator);
        populators = generator.getDefaultPopulators(this);

        // set up values from server defaults
        ticksPerAnimal = server.getTicksPerAnimalSpawns();
        ticksPerMonster = server.getTicksPerMonsterSpawns();
        monsterLimit = server.getMonsterSpawnLimit();
        animalLimit = server.getAnimalSpawnLimit();
        waterAnimalLimit = server.getWaterAnimalSpawnLimit();
        ambientLimit = server.getAmbientSpawnLimit();
        keepSpawnLoaded = server.keepSpawnLoaded();
        difficulty = server.getDifficulty();

        // read in world data
        WorldFinalValues values = null;
        try {
            values = storageProvider.getMetadataService().readWorldData();
        } catch (IOException e) {
            server.getLogger().log(Level.SEVERE, "Error reading world for creation", e);
        }
        if (values != null) {
            if (values.getSeed() == 0L) {
                this.seed = creator.seed();
            } else {
                this.seed = values.getSeed();
            }
            this.uid = values.getUuid();
        } else {
            this.seed = creator.seed();
            this.uid = UUID.randomUUID();
        }

        // begin loading spawn area
        spawnChunkLock = newChunkLock("spawn");
        server.addWorld(this);
        server.getLogger().info("Preparing spawn for " + name + "...");
        EventFactory.callEvent(new WorldInitEvent(this));

        // determine the spawn location if we need to
        if (spawnLocation == null) {
            // no location loaded, look for fixed spawn
            spawnLocation = generator.getFixedSpawnLocation(this, random);

            if (spawnLocation == null) {
                // determine a location randomly
                int spawnX = random.nextInt(128) - 64, spawnZ = random.nextInt(128) - 64;
                GlowChunk chunk = getChunkAt(spawnX >> 4, spawnZ >> 4);
                //GlowServer.logger.info("determining spawn: " + chunk.getX() + " " + chunk.getZ());
                chunk.load(true)// I'm not sure there's a sane way around this
                for (int tries = 0; tries < 10 && !generator.canSpawn(this, spawnX, spawnZ); ++tries) {
                    spawnX += random.nextInt(128) - 64;
                    spawnZ += random.nextInt(128) - 64;
                }
                setSpawnLocation(spawnX, getHighestBlockYAt(spawnX, spawnZ), spawnZ);
            }
View Full Code Here

TOP

Related Classes of org.bukkit.generator.ChunkGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.