protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws if (!this.M) { // CraftBukkit start - fire WorldSaveEvent // WorldServer[] aworldserver = this.worldServer; int i = this.worlds.size(); for (int j = 0; j < i; ++j) { WorldServer worldserver = this.worlds.get(j); if (worldserver != null) { if (!flag) { MinecraftServer.i.info( "Saving chunks for level \'" + worldserver.getWorldData().getName() + "\'/" + worldserver.worldProvider.getName()); } worldserver.save(true, (IProgressUpdate) null); worldserver.saveLevel(); WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld()); this.server.getPluginManager().callEvent(event); // CraftBukkit end } } } }
public void a(EnumDifficulty enumdifficulty) { // CraftBukkit start for (int i = 0; i < this.worlds.size(); ++i) { WorldServer worldserver = this.worlds.get(i); // CraftBukkit end if (worldserver != null) { if (worldserver.getWorldData().isHardcore()) { worldserver.getWorldData().setDifficulty(EnumDifficulty.HARD); worldserver.setSpawnFlags(true, true); } else if (this.S()) { worldserver.getWorldData().setDifficulty(enumdifficulty); worldserver.setSpawnFlags(worldserver.getDifficulty() != EnumDifficulty.PEACEFUL, true); } else { worldserver.getWorldData().setDifficulty(enumdifficulty); worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals); } } } }
public void a(MojangStatisticsGenerator mojangstatisticsgenerator) { mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(false)); mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(0)); if (this.v != null) { mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.G())); mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.H())); mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.v.getSeenPlayers().length)); } mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode)); mojangstatisticsgenerator.a("gui_state", this.aq() ? "enabled" : "disabled"); mojangstatisticsgenerator.a( "run_time", Long.valueOf((ax() - mojangstatisticsgenerator.g()) / 60L * 1000L)); mojangstatisticsgenerator.a( "avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.g) * 1.0E-6D))); int i = 0; if (this.worldServer != null) { // CraftBukkit start for (int j = 0; j < this.worlds.size(); ++j) { WorldServer worldserver = this.worlds.get(j); if (worldserver != null) { // CraftBukkit end WorldData worlddata = worldserver.getWorldData(); mojangstatisticsgenerator.a( "world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension())); mojangstatisticsgenerator.a("world[" + i + "][mode]", worlddata.getGameType()); mojangstatisticsgenerator.a("world[" + i + "][difficulty]", worldserver.getDifficulty()); mojangstatisticsgenerator.a( "world[" + i + "][hardcore]", Boolean.valueOf(worlddata.isHardcore())); mojangstatisticsgenerator.a( "world[" + i + "][generator_name]", worlddata.getType().name()); mojangstatisticsgenerator.a( "world[" + i + "][generator_version]", Integer.valueOf(worlddata.getType().getVersion())); mojangstatisticsgenerator.a("world[" + i + "][height]", Integer.valueOf(this.F)); mojangstatisticsgenerator.a( "world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.N().getLoadedChunks())); ++i; } } } mojangstatisticsgenerator.a("worlds", Integer.valueOf(i)); }
public void a(EnumDifficulty enumdifficulty) { // CraftBukkit start - Use worlds list for iteration for (int j = 0; j < this.worlds.size(); ++j) { WorldServer worldserver = this.worlds.get(j); // CraftBukkit end if (worldserver != null) { if (worldserver.getWorldData().isHardcore()) { worldserver.difficulty = EnumDifficulty.HARD; worldserver.setSpawnFlags(true, true); } else if (this.N()) { worldserver.difficulty = enumdifficulty; worldserver.setSpawnFlags(worldserver.difficulty != EnumDifficulty.PEACEFUL, true); } else { worldserver.difficulty = enumdifficulty; worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals); } } } }
protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws if (!this.N) { // CraftBukkit start for (int j = 0; j < worlds.size(); ++j) { WorldServer worldserver = worlds.get(j); // CraftBukkit end if (worldserver != null) { if (!flag) { MinecraftServer.LOGGER.info( "Saving chunks for level \'" + worldserver.getWorldData().getName() + "\'/" + worldserver.worldProvider.getName()); } worldserver.save(true, (IProgressUpdate) null); worldserver.saveLevel(); } } } }
private void a(Convertable convertable, String s, long i, WorldType worldtype) { if (convertable.isConvertable(s)) { log.info("Converting map!"); convertable.convert(s, new ConvertProgressUpdater(this)); } // CraftBukkit - removed world and ticktime arrays int j = this.propertyManager.getInt("gamemode", 0); j = WorldSettings.a(j); log.info("Default game type: " + j); // CraftBukkit start (+ removed worldsettings and servernbtmanager) boolean generateStructures = this.propertyManager.getBoolean("generate-structures", true); int worldCount = 3; for (int k = 0; k < worldCount; ++k) { WorldServer world; int dimension = 0; if (k == 1) { if (this.propertyManager.getBoolean("allow-nether", true)) { dimension = -1; } else { continue; } } if (k == 2) { // CraftBukkit - (+ don't do this in server.properties, do it in bukkit.yml) if (this.server.getAllowEnd()) { dimension = 1; } else { continue; } } String worldType = Environment.getEnvironment(dimension).toString().toLowerCase(); String name = (dimension == 0) ? s : s + "_" + worldType; org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); WorldSettings settings = new WorldSettings(i, j, generateStructures, false, worldtype); if (k == 0) { world = new WorldServer( this, new ServerNBTManager(server.getWorldContainer(), s, true), s, dimension, settings, org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit } else { String dim = "DIM" + dimension; File newWorld = new File(new File(name), dim); File oldWorld = new File(new File(s), dim); if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) { log.info("---- Migration of old " + worldType + " folder required ----"); log.info( "Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your " + worldType + " folder to a new location in order to operate correctly."); log.info( "We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future."); log.info("Attempting to move " + oldWorld + " to " + newWorld + "..."); if (newWorld.exists()) { log.severe("A file or folder already exists at " + newWorld + "!"); log.info("---- Migration of old " + worldType + " folder failed ----"); } else if (newWorld.getParentFile().mkdirs()) { if (oldWorld.renameTo(newWorld)) { log.info( "Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld); log.info("---- Migration of old " + worldType + " folder complete ----"); } else { log.severe("Could not move folder " + oldWorld + " to " + newWorld + "!"); log.info("---- Migration of old " + worldType + " folder failed ----"); } } else { log.severe("Could not create path for " + newWorld + "!"); log.info("---- Migration of old " + worldType + " folder failed ----"); } } if (convertable.isConvertable(name)) { log.info("Converting map!"); convertable.convert(name, new ConvertProgressUpdater(this)); } world = new SecondaryWorldServer( this, new ServerNBTManager(server.getWorldContainer(), name, true), name, dimension, settings, this.worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit } if (gen != null) { world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld())); } this.server .getPluginManager() .callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); world.tracker = new EntityTracker(this, world); // CraftBukkit world.addIWorldAccess(new WorldManager(this, world)); world.difficulty = this.propertyManager.getInt("difficulty", 1); world.setSpawnFlags( this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals); world.getWorldData().setGameType(j); this.worlds.add(world); this.serverConfigurationManager.setPlayerFileData(this.worlds.toArray(new WorldServer[0])); } // CraftBukkit end short short1 = 196; long l = System.currentTimeMillis(); // CraftBukkit start for (int i1 = 0; i1 < this.worlds.size(); ++i1) { WorldServer worldserver = this.worlds.get(i1); log.info("Preparing start region for level " + i1 + " (Seed: " + worldserver.getSeed() + ")"); if (!worldserver.getWorld().getKeepSpawnInMemory()) { continue; } // CraftBukkit end ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); for (int j1 = -short1; j1 <= short1 && this.isRunning; j1 += 16) { for (int k1 = -short1; k1 <= short1 && this.isRunning; k1 += 16) { long l1 = System.currentTimeMillis(); if (l1 < l) { l = l1; } if (l1 > l + 1000L) { int i2 = (short1 * 2 + 1) * (short1 * 2 + 1); int j2 = (j1 + short1) * (short1 * 2 + 1) + k1 + 1; this.b("Preparing spawn area", j2 * 100 / i2); l = l1; } worldserver.chunkProviderServer.getChunkAt( chunkcoordinates.x + j1 >> 4, chunkcoordinates.z + k1 >> 4); while (worldserver.updateLights() && this.isRunning) {; } } } } // CraftBukkit start for (World world : this.worlds) { this.server .getPluginManager() .callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); } // CraftBukkit end this.t(); }
public void z() { this.methodProfiler.a("jobs"); Queue queue = this.i; synchronized (this.i) { while (!this.i.isEmpty()) { try { // CraftBukkit start - log exceptions FutureTask task = ((FutureTask) this.i.poll()); task.run(); task.get(); } catch (Throwable throwable) { MinecraftServer.LOGGER.fatal("Handling task", throwable); // CraftBukkit end } } } this.methodProfiler.c("levels"); SpigotTimings.schedulerTimer.startTiming(); // Spigot // CraftBukkit start this.server.getScheduler().mainThreadHeartbeat(this.ticks); SpigotTimings.schedulerTimer.stopTiming(); // Spigot // Run tasks that are waiting on processing SpigotTimings.processQueueTimer.startTiming(); // Spigot while (!processQueue.isEmpty()) { processQueue.remove().run(); } SpigotTimings.processQueueTimer.stopTiming(); // Spigot SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick(); SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot SpigotTimings.timeUpdateTimer.startTiming(); // Spigot // Send time updates to everyone, it will get the right time from the world the player is in. if (this.ticks % 20 == 0) { for (int i = 0; i < this.getPlayerList().players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i); entityplayer.playerConnection.sendPacket( new PacketPlayOutUpdateTime( entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer .world .getGameRules() .getBoolean("doDaylightCycle"))); // Add support for per player time } } SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot int i; for (i = 0; i < this.worlds.size(); ++i) { long j = System.nanoTime(); // if (i == 0 || this.getAllowNether()) { WorldServer worldserver = this.worlds.get(i); this.methodProfiler.a(worldserver.getWorldData().getName()); /* Drop global time updates if (this.ticks % 20 == 0) { this.methodProfiler.a("timeSync"); this.v.a(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")), worldserver.worldProvider.getDimension()); this.methodProfiler.b(); } // CraftBukkit end */ this.methodProfiler.a("tick"); CrashReport crashreport; try { worldserver.timings.doTick.startTiming(); // Spigot worldserver.doTick(); worldserver.timings.doTick.stopTiming(); // Spigot } catch (Throwable throwable1) { // Spigot Start try { crashreport = CrashReport.a(throwable1, "Exception ticking world"); } catch (Throwable t) { throw new RuntimeException("Error generating crash report", t); } // Spigot End worldserver.a(crashreport); throw new ReportedException(crashreport); } try { worldserver.timings.tickEntities.startTiming(); // Spigot worldserver.tickEntities(); worldserver.timings.tickEntities.stopTiming(); // Spigot } catch (Throwable throwable2) { // Spigot Start try { crashreport = CrashReport.a(throwable2, "Exception ticking world entities"); } catch (Throwable t) { throw new RuntimeException("Error generating crash report", t); } // Spigot End worldserver.a(crashreport); throw new ReportedException(crashreport); } this.methodProfiler.b(); this.methodProfiler.a("tracker"); worldserver.timings.tracker.startTiming(); // Spigot worldserver.getTracker().updatePlayers(); worldserver.timings.tracker.stopTiming(); // Spigot this.methodProfiler.b(); this.methodProfiler.b(); // } // CraftBukkit // this.h[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit } this.methodProfiler.c("connection"); SpigotTimings.connectionTimer.startTiming(); // Spigot this.ao().c(); SpigotTimings.connectionTimer.stopTiming(); // Spigot this.methodProfiler.c("players"); SpigotTimings.playerListTimer.startTiming(); // Spigot this.v.tick(); SpigotTimings.playerListTimer.stopTiming(); // Spigot this.methodProfiler.c("tickables"); SpigotTimings.tickablesTimer.startTiming(); // Spigot for (i = 0; i < this.o.size(); ++i) { ((IUpdatePlayerListBox) this.o.get(i)).c(); } SpigotTimings.tickablesTimer.stopTiming(); // Spigot this.methodProfiler.b(); }
protected void a(String s, String s1, long i, WorldType worldtype, String s2) { this.a(s); this.b("menu.loadingLevel"); this.worldServer = new WorldServer[3]; /* CraftBukkit start - Remove ticktime arrays and worldsettings this.h = new long[this.worldServer.length][100]; IDataManager idatamanager = this.convertable.a(s, true); this.a(this.T(), idatamanager); WorldData worlddata = idatamanager.getWorldData(); WorldSettings worldsettings; if (worlddata == null) { if (this.W()) { worldsettings = DemoWorldServer.a; } else { worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); worldsettings.setGeneratorSettings(s2); if (this.M) { worldsettings.a(); } } worlddata = new WorldData(worldsettings, s1); } else { worlddata.a(s1); worldsettings = new WorldSettings(worlddata); } */ int worldCount = 3; for (int j = 0; j < worldCount; ++j) { WorldServer world; byte dimension = 0; if (j == 1) { if (getAllowNether()) { dimension = -1; } else { continue; } } if (j == 2) { if (server.getAllowEnd()) { dimension = 1; } else { continue; } } String worldType = org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase(); String name = (dimension == 0) ? s : s + "_" + worldType; org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); WorldSettings worldsettings = new WorldSettings( i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); worldsettings.setGeneratorSettings(s2); if (j == 0) { IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true); WorldData worlddata = idatamanager.getWorldData(); if (worlddata == null) { worlddata = new WorldData(worldsettings, s1); } worlddata.checkName( s1); // 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) if (this.W()) { world = (WorldServer) (new DemoWorldServer( this, idatamanager, worlddata, dimension, this.methodProfiler)) .b(); } else { world = (WorldServer) (new WorldServer( this, idatamanager, worlddata, dimension, this.methodProfiler, org.bukkit.World.Environment.getEnvironment(dimension), gen)) .b(); } world.a(worldsettings); this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager( this, world.getScoreboard()); } else { String dim = "DIM" + dimension; File newWorld = new File(new File(name), dim); File oldWorld = new File(new File(s), dim); if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) { MinecraftServer.LOGGER.info( "---- Migration of old " + worldType + " folder required ----"); MinecraftServer.LOGGER.info( "Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your " + worldType + " folder to a new location in order to operate correctly."); MinecraftServer.LOGGER.info( "We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future."); MinecraftServer.LOGGER.info("Attempting to move " + oldWorld + " to " + newWorld + "..."); if (newWorld.exists()) { MinecraftServer.LOGGER.warn("A file or folder already exists at " + newWorld + "!"); MinecraftServer.LOGGER.info( "---- Migration of old " + worldType + " folder failed ----"); } else if (newWorld.getParentFile().mkdirs()) { if (oldWorld.renameTo(newWorld)) { MinecraftServer.LOGGER.info( "Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld); // Migrate world data too. try { com.google.common.io.Files.copy( new File(new File(s), "level.dat"), new File(new File(name), "level.dat")); } catch (IOException exception) { MinecraftServer.LOGGER.warn("Unable to migrate world data."); } MinecraftServer.LOGGER.info( "---- Migration of old " + worldType + " folder complete ----"); } else { MinecraftServer.LOGGER.warn( "Could not move folder " + oldWorld + " to " + newWorld + "!"); MinecraftServer.LOGGER.info( "---- Migration of old " + worldType + " folder failed ----"); } } else { MinecraftServer.LOGGER.warn("Could not create path for " + newWorld + "!"); MinecraftServer.LOGGER.info( "---- Migration of old " + worldType + " folder failed ----"); } } IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true); // world =, b0 to dimension, s1 to name, added Environment and gen WorldData worlddata = idatamanager.getWorldData(); if (worlddata == null) { 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) world = (WorldServer) new SecondaryWorldServer( this, idatamanager, dimension, this.worlds.get(0), this.methodProfiler, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen) .b(); } if (gen != null) { world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld())); } this.server .getPluginManager() .callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); world.addIWorldAccess(new WorldManager(this, world)); if (!this.S()) { world.getWorldData().setGameType(this.getGamemode()); } worlds.add(world); getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()])); } // CraftBukkit end this.a(this.getDifficulty()); this.k(); }