public World create(org.bukkit.WorldType type) { if (type == null) { type = org.bukkit.WorldType.NORMAL; } try { if (WorldUtil.isLoaded(this.worldName) != null || WorldUtil.exists(this.worldName) != null) { throw new IllegalStateException("World already exists"); } } catch (final IOException e) { return null; } final WorldCreator creator = new WorldCreator(this.worldName); creator.seed(this.getSeed()); creator.type(type); switch (this.type) { case ADDITIONAL: case STOCK: creator.environment(World.Environment.NORMAL); break; case ADDITIONAL_SUB_NETHER: case STOCK_NETHER: creator.environment(World.Environment.NETHER); break; case ADDITIONAL_SUB_END: case STOCK_END: creator.environment(World.Environment.THE_END); break; default: throw new IllegalStateException("Incorrect world type: " + this.type); } final World result = creator.createWorld(); this.setSpawnLocation(result.getSpawnLocation()); return result; }
public void onEnable() { // PluginManager pm = getServer().getPluginManager(); // pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this); // pm.registerEvent(Event.Type.WORLD_INIT, worldListener, Event.Priority.High, this); // reload(); World bio = getServer().getWorld("biosphere"); if (null == bio) { // BiosphereGenerator gen = new BiosphereGenerator(); // bio = // getServer().createWorld("biosphere",Environment.NORMAL,getServer().getWorlds().get(0).getSeed(), gen); /* WorldCreator wc = new WorldCreator("biosphere"); wc.environment(Environment.NORMAL); wc.seed(getServer().getWorlds().get(0).getSeed()); wc.generator((ChunkGenerator) (bio = getServer().createWorld(wc))); */ WorldCreator wc = new WorldCreator("biosphere"); wc.environment(Environment.NORMAL); wc.seed(getServer().getWorlds().get(0).getSeed()); BiosphereGenerator gen = new BiosphereGenerator(); wc.generator(gen); System.out.printf("start making world"); bio = getServer().createWorld(wc); } // Register our commands getCommand("biosphere").setExecutor(new BiosphereCommand(this)); getCommand("biome").setExecutor(new BiomeCommand(this)); getCommand("test").setExecutor(new TestCommand(this)); PluginDescriptionFile pdfFile = this.getDescription(); System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " enabled"); }
public void load() { WorldCreator creator = WorldCreator.name(this.worldName); creator.environment(Environment.NORMAL); creator.generator("CleanroomGenerator:."); this.world = creator.createWorld(); world.setAutoSave(false); // new Location(this.world, this.X, this.Y, this.Z); }
private World createWorld() { WorldCreator worldCreator = new WorldCreator(WORLD_NAME); try { worldCreator.generator(new DungeonChunkGenerator()); } catch (DungeonArgumentException argumentException) { log.log(Level.SEVERE, "Couldn't initialize chunk generator", argumentException); } worldCreator.environment(Environment.NORMAL); return Bukkit.getServer().createWorld(worldCreator); }
/** * Creates or loads a world with the given name using the specified options. * * <p>If the world is already loaded, it will just return the equivalent of * getWorld(creator.name()). * * @param creator Options to use when creating the world * @return Newly created or loaded world */ public GlowWorld createWorld(WorldCreator creator) { GlowWorld world = getWorld(creator.name()); if (world != null) { return world; } if (creator.generator() == null) { creator.generator(getGenerator(creator.name(), creator.environment())); } world = new GlowWorld( this, creator.name(), creator.environment(), creator.seed(), new McRegionWorldStorageProvider(new File(getWorldContainer(), creator.name())), creator.generator()); worlds.add(world); return world; }
@Override public GlowWorld createWorld(WorldCreator creator) { GlowWorld world = getWorld(creator.name()); if (world != null) { return world; } if (creator.generator() == null) { creator.generator(getGenerator(creator.name(), creator.environment(), creator.type())); } // GlowWorld's constructor calls addWorld below. return new GlowWorld(this, creator); }
@Override protected World generateWorld() { if (!TFM_ConfigEntry.FLATLANDS_GENERATE.getBoolean()) { return null; } wipeFlatlandsIfFlagged(); WorldCreator worldCreator = new WorldCreator(WORLD_NAME); worldCreator.generateStructures(false); worldCreator.type(WorldType.NORMAL); worldCreator.environment(World.Environment.NORMAL); worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS)); World world = Bukkit.getServer().createWorld(worldCreator); world.setSpawnFlags(false, false); world.setSpawnLocation(0, 50, 0); Block welcomeSignBlock = world.getBlockAt(0, 50, 0); welcomeSignBlock.setType(Material.SIGN_POST); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); signData.setFacingDirection(BlockFace.NORTH); welcomeSign.setLine(0, ChatColor.GREEN + "DonatorWorld"); welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---"); welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point"); welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---"); welcomeSign.update(); TFM_GameRuleHandler.commitGameRules(); return world; }
@Override public World createWorld(WorldCreator creator) { if (creator == null) { throw new IllegalArgumentException("Creator may not be null"); } String name = creator.name(); ChunkGenerator generator = creator.generator(); File folder = new File(getWorldContainer().getParentFile(), name); int dimension = DimensionManager.getNextFreeDimId(); World world = getWorld(dimension); WorldType type = WorldType.parseWorldType(creator.type().getName()); boolean generateStructures = creator.generateStructures(); if (world != null) { return world; } if ((folder.exists()) && (!folder.isDirectory())) { throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder"); } if (generator == null) { generator = getGenerator(dimension); } AnvilSaveConverter converter = new AnvilSaveConverter(getWorldContainer()); if (converter.isOldMapFormat(name)) { getLogger().info("Converting world '" + name + "'"); converter.convertMapFormat(name, new ConvertingProgressUpdate(theServer)); } boolean hardcore = false; WorldServer internal = new WorldServer(theServer, new AnvilSaveHandler(getWorldContainer().getParentFile(), name, true), name, dimension, new WorldSettings(creator.seed(), EnumGameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type), theServer.theProfiler); if (!(worlds.containsKey(dimension))) { return null; } //internal.getWorldInfo().get = console.worldServerForDimension(0).worldMaps; //internal. = new EntityTracker(internal); // CraftBukkit internal.addWorldAccess((IWorldAccess) new WorldManager(theServer, internal)); internal.difficultySetting = 1; //internal.(true, true); //theServer.worldServers[theServer.worldServers.length] = internal; DimensionManager.setWorld(dimension, internal); this.worlds.put(dimension, new BukkitWorld(internal, creator.generator(), creator.environment())); if (generator != null) { (worlds.get(dimension)).getPopulators().addAll(generator.getDefaultPopulators(worlds.get(dimension))); } pluginManager.callEvent(new WorldInitEvent((worlds.get(dimension)))); System.out.print("Preparing start region for level " + (theServer.worldServers.length - 1) + " (Seed: " + internal.getSeed() + ")"); if (DimensionManager.shouldLoadSpawn(dimension)) { short short1 = 196; long i = System.currentTimeMillis(); for (int j = -short1; j <= short1; j += 16) { for (int k = -short1; k <= short1; k += 16) { long l = System.currentTimeMillis(); if (l < i) { i = l; } if (l > i + 1000L) { int i1 = (short1 * 2 + 1) * (short1 * 2 + 1); int j1 = (j + short1) * (short1 * 2 + 1) + k + 1; System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%"); i = l; } ChunkCoordinates chunkcoordinates = internal.getSpawnPoint(); internal.theChunkProviderServer.provideChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4); //while (internal.updateLights()) { // ; }// } } pluginManager.callEvent( new WorldLoadEvent(worlds.get(dimension))); return worlds.get(dimension); }
public static World createWorld(String worldname, long seed) { String gen = getGeneratorPlugin(worldname); if (gen == null) { MyWorlds.log(Level.INFO, "Loading or creating world: '" + worldname + "' using seed " + seed); } else { MyWorlds.log( Level.INFO, "Loading or creating world: '" + worldname + "' using seed " + seed + " and chunk generator: '" + gen + "'"); } final int retrycount = 3; World w = null; int i = 0; ChunkGenerator cgen = null; try { if (gen != null) { cgen = getGenerator(worldname, gen); } } catch (Exception ex) { } if (gen != null && cgen == null) { MyWorlds.log( Level.SEVERE, "World '" + worldname + "' could not be loaded because the chunk generator '" + gen + "' was not found!"); return null; } WorldConfig wc = WorldConfig.get(worldname); wc.chunkGeneratorName = gen; for (i = 0; i < retrycount + 1; i++) { try { WorldCreator c = new WorldCreator(worldname); c.environment(wc.environment); c.seed(seed); c.generator(cgen); w = c.createWorld(); } catch (Exception ex) { MyWorlds.log(Level.WARNING, "World load issue: " + ex.getMessage()); } if (w != null) break; } if (w != null) { wc.updatePVP(w); // Data file is made? if (!worldExists(worldname)) { w.save(); } } if (w == null) { MyWorlds.log(Level.WARNING, "Operation failed after " + i + " retries!"); } else if (i == 1) { MyWorlds.log(Level.INFO, "Operation succeeded after 1 retry!"); } else if (i > 0) { MyWorlds.log(Level.INFO, "Operation succeeded after " + i + " retries!"); } return w; }