Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public World createWorld(WorldCreator creator) {
- Validate.notNull(creator, "Creator may not be null");
- String name = creator.name();
- ChunkGenerator generator = creator.generator();
- File folder = new File(getWorldContainer(), name);
- World world = getWorld(name);
- WorldType type = WorldType.getType(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(name);
- }
- Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().getDataConverterManager());
- if (converter.isConvertable(name)) {
- getLogger().info("Converting world '" + name + "'");
- converter.convert(name, new IProgressUpdate() {
- private long b = System.currentTimeMillis();
- public void a(String s) {}
- public void a(int i) {
- if (System.currentTimeMillis() - this.b >= 1000L) {
- this.b = System.currentTimeMillis();
- MinecraftServer.LOGGER.info("Converting... " + i + "%");
- }
- }
- public void c(String s) {}
- });
- }
- int dimension = CraftWorld.CUSTOM_DIMENSION_OFFSET + console.worlds.size();
- boolean used = false;
- do {
- for (WorldServer server : console.worlds) {
- used = server.dimension == dimension;
- if (used) {
- dimension++;
- break;
- }
- }
- } while(used);
- boolean hardcore = false;
- IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().getDataConverterManager());
- WorldData worlddata = sdm.getWorldData();
- WorldSettings worldSettings = null;
- if (worlddata == null) {
- worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
- worldSettings.setGeneratorSettings(creator.generatorSettings());
- worlddata = new WorldData(worldSettings, name);
- }
- worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
- WorldServer internal = (WorldServer) new WorldServer(console, sdm, worlddata, dimension, consolef.methodProfiler, creator.environment(), generator).b();
- if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
- return null;
- }
- if (worldSettings != null) {
- internal.a(worldSettings);
- }
- internal.scoreboard = getScoreboardManager().getMainScoreboard().getHandle();
- internal.tracker = new EntityTracker(internal);
- internal.addIWorldAccess(new WorldManager(console, internal));
- internal.worldData.setDifficulty(EnumDifficulty.EASY);
- internal.setSpawnFlags(true, true);
- console.worlds.add(internal);
- pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
- System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Seed: " + internal.getSeed() + ")");
- if (internal.getWorld().getKeepSpawnInMemory()) {
- 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;
- }
- BlockPosition chunkcoordinates = internal.getSpawn();
- internal.getChunkProviderServer().getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4);
- }
- }
- }
- pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
- return internal.getWorld();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement