package net.minecraft.server; import java.awt.GraphicsEnvironment; import java.io.File; import java.security.KeyPair; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; // CraftBukkit start import java.util.concurrent.ExecutionException; import java.io.IOException; import com.google.common.io.Files; import jline.console.ConsoleReader; import joptsimple.OptionSet; import org.bukkit.World.Environment; import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.server.RemoteServerCommandEvent; import org.bukkit.event.world.WorldSaveEvent; // CraftBukkit end public abstract class MinecraftServer implements ICommandListener, Runnable, IMojangStatistics { private static MinecraftServer k = null; public Convertable convertable; // CraftBukkit - private final -> public private final MojangStatisticsGenerator m = new MojangStatisticsGenerator("server", this); public File universe; // CraftBukkit - private final -> public private final List o = new ArrayList(); private final ICommandHandler p; public final MethodProfiler methodProfiler = new MethodProfiler(); private String serverIp; private int r = -1; public WorldServer[] worldServer; private PlayerList s; private boolean isRunning = true; private boolean isStopped = false; private int ticks = 0; public String c; public int d; private boolean onlineMode; private boolean spawnAnimals; private boolean spawnNPCs; private boolean pvpMode; private boolean allowFlight; private String motd; private int C; private long D; private long E; private long F; private long G; public final long[] e = new long[100]; public final long[] f = new long[100]; public final long[] g = new long[100]; public final long[] h = new long[100]; public final long[] i = new long[100]; public long[][] j; private KeyPair H; private String I; private String J; private boolean demoMode; private boolean M; private boolean N; private String O = ""; private boolean P = false; private long Q; private String R; private boolean S; // CraftBukkit start public List worlds = new ArrayList(); public org.bukkit.craftbukkit.CraftServer server; public OptionSet options; public org.bukkit.command.ConsoleCommandSender console; public org.bukkit.command.RemoteConsoleCommandSender remoteConsole; public ConsoleReader reader; public static int currentTick; public final Thread primaryThread; public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; // CraftBukkit end public MinecraftServer(OptionSet options) { // CraftBukkit - signature file -> OptionSet k = this; // this.universe = file1; // CraftBukkit this.p = new CommandDispatcher(); // this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved to DedicatedServer.init this.am(); // CraftBukkit start this.options = options; try { this.reader = new ConsoleReader(System.in, System.out); this.reader.setExpandEvents(false); // Avoid parsing exceptions for uncommonly used event designators } catch (Exception e) { try { // Try again with jline disabled for Windows users without C++ 2008 Redistributable System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); System.setProperty("user.language", "en"); org.bukkit.craftbukkit.Main.useJline = false; this.reader = new ConsoleReader(System.in, System.out); this.reader.setExpandEvents(false); } catch (java.io.IOException ex) { Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex); } } Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); primaryThread = new ThreadServerApplication(this, "Server thread"); // Moved from main } public abstract PropertyManager getPropertyManager(); // CraftBukkit end private void am() { DispenserRegistry.a(); } protected abstract boolean init() throws java.net.UnknownHostException; // CraftBukkit - throws UnknownHostException protected void b(String s) { if (this.getConvertable().isConvertable(s)) { this.getLogger().info("Converting map!"); this.c("menu.convertingLevel"); this.getConvertable().convert(s, new ConvertProgressUpdater(this)); } } protected synchronized void c(String s) { this.R = s; } protected void a(String s, String s1, long i, WorldType worldtype, String s2) { this.b(s); this.c("menu.loadingLevel"); this.worldServer = new WorldServer[3]; // CraftBukkit - removed ticktime arrays IDataManager idatamanager = this.convertable.a(s, true); WorldData worlddata = idatamanager.getWorldData(); // CraftBukkit start - removed worldsettings int worldCount = 3; for (int j = 0; j < worldCount; ++j) { WorldServer world; int dimension = 0; if (j == 1) { if (this.getAllowNether()) { dimension = -1; } else { continue; } } if (j == 2) { 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 worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); worldsettings.a(s2); if (j == 0) { if (this.M()) { // Strip out DEMO? // CraftBukkit world = new DemoWorldServer(this, new ServerNBTManager(server.getWorldContainer(), s1, true), s1, dimension, this.methodProfiler, this.getLogger()); } else { // CraftBukkit world = new WorldServer(this, new ServerNBTManager(server.getWorldContainer(), s1, true), s1, dimension, worldsettings, this.methodProfiler, this.getLogger(), Environment.getEnvironment(dimension), gen); } } 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())) { final IConsoleLogManager log = this.getLogger(); 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); // Migrate world data too. try { Files.copy(new File(new File(s), "level.dat"), new File(new File(name), "level.dat")); } catch (IOException exception) { log.severe("Unable to migrate world data."); } 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 ----"); } } this.c(name); // CraftBukkit world = new SecondaryWorldServer(this, new ServerNBTManager(server.getWorldContainer(), name, true), name, dimension, worldsettings, this.worlds.get(0), this.methodProfiler, this.getLogger(), Environment.getEnvironment(dimension), gen); } 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.I()) { world.getWorldData().setGameType(this.getGamemode()); } this.worlds.add(world); this.s.setPlayerFileData(this.worlds.toArray(new WorldServer[this.worlds.size()])); // CraftBukkit end } this.c(this.getDifficulty()); this.e(); } protected void e() { long i = System.currentTimeMillis(); // CraftBukkit - current time this.c("menu.generatingTerrain"); byte b0 = 0; // CraftBukkit start for (int j = 0; j < this.worlds.size(); ++j) { WorldServer worldserver = this.worlds.get(j); this.getLogger().info("Preparing start region for level " + j + " (Seed: " + worldserver.getSeed() + ")"); if (!worldserver.getWorld().getKeepSpawnInMemory()) { continue; } ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); for (int k = -192; k <= 192 && this.isRunning(); k += 16) { for (int l = -192; l <= 192 && this.isRunning(); l += 16) { long i1 = System.currentTimeMillis(); if (i1 < i) { i = i1; } if (i1 > i + 1000L) { int j1 = (192 * 2 + 1) * (192 * 2 + 1); int k1 = (k + 192) * (192 * 2 + 1) + l + 1; this.a_("Preparing spawn area", k1 * 100 / j1); i = i1; } worldserver.chunkProviderServer.getChunkAt(chunkcoordinates.x + k >> 4, chunkcoordinates.z + l >> 4); } } } // CraftBukkit end this.j(); } public abstract boolean getGenerateStructures(); public abstract EnumGamemode getGamemode(); public abstract int getDifficulty(); public abstract boolean isHardcore(); protected void a_(String s, int i) { this.c = s; this.d = i; this.getLogger().info(s + ": " + i + "%"); } protected void j() { this.c = null; this.d = 0; this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit } protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws if (!this.N) { // CraftBukkit start for (int j = 0; j < this.worlds.size(); ++j) { WorldServer worldserver = this.worlds.get(j); if (worldserver != null) { if (!flag) { this.getLogger().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 stop() throws ExceptionWorldConflict { // CraftBukkit - added throws if (!this.N) { this.getLogger().info("Stopping server"); // CraftBukkit start if (this.server != null) { this.server.disablePlugins(); } // CraftBukkit end if (this.ae() != null) { this.ae().a(); } if (this.s != null) { this.getLogger().info("Saving players"); this.s.savePlayers(); this.s.r(); } this.getLogger().info("Saving worlds"); this.saveChunks(false); /* CraftBukkit start - handled in saveChunks for (int i = 0; i < this.worldServer.length; ++i) { WorldServer worldserver = this.worldServer[i]; worldserver.saveLevel(); } // CraftBukkit end */ if (this.m != null && this.m.d()) { this.m.e(); } } } public String getServerIp() { return this.serverIp; } public void d(String s) { this.serverIp = s; } public boolean isRunning() { return this.isRunning; } public void safeShutdown() { this.isRunning = false; } public void run() { try { if (this.init()) { long i = System.currentTimeMillis(); for (long j = 0L; this.isRunning; this.P = true) { long k = System.currentTimeMillis(); long l = k - i; if (l > 2000L && i - this.Q >= 15000L) { if (this.server.getWarnOnOverload()) // CraftBukkit - Added option to suppress warning messages this.getLogger().warning("Can\'t keep up! Did the system time change, or is the server overloaded?"); l = 2000L; this.Q = i; } if (l < 0L) { this.getLogger().warning("Time ran backwards! Did the system time change?"); l = 0L; } j += l; i = k; if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit this.q(); j = 0L; } else { while (j > 50L) { MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit j -= 50L; this.q(); } } Thread.sleep(1L); } } else { this.a((CrashReport) null); } } catch (Throwable throwable) { throwable.printStackTrace(); this.getLogger().severe("Encountered an unexpected exception " + throwable.getClass().getSimpleName(), throwable); CrashReport crashreport = null; if (throwable instanceof ReportedException) { crashreport = this.b(((ReportedException) throwable).a()); } else { crashreport = this.b(new CrashReport("Exception in server tick loop", throwable)); } File file1 = new File(new File(this.o(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); if (crashreport.a(file1, this.getLogger())) { this.getLogger().severe("This crash report has been saved to: " + file1.getAbsolutePath()); } else { this.getLogger().severe("We were unable to save this crash report to disk."); } this.a(crashreport); } finally { try { this.stop(); this.isStopped = true; } catch (Throwable throwable1) { throwable1.printStackTrace(); } finally { // CraftBukkit start - restore terminal to original settings try { this.reader.getTerminal().restore(); } catch (Exception e) { } // CraftBukkit end this.p(); } } } protected File o() { return new File("."); } protected void a(CrashReport crashreport) {} protected void p() {} protected void q() throws ExceptionWorldConflict { // CraftBukkit - added throws long i = System.nanoTime(); AxisAlignedBB.a().a(); ++this.ticks; if (this.S) { this.S = false; this.methodProfiler.a = true; this.methodProfiler.a(); } this.methodProfiler.a("root"); this.r(); if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit this.methodProfiler.a("save"); this.s.savePlayers(); this.saveChunks(true); this.methodProfiler.b(); } this.methodProfiler.a("tallying"); this.i[this.ticks % 100] = System.nanoTime() - i; this.e[this.ticks % 100] = Packet.q - this.D; this.D = Packet.q; this.f[this.ticks % 100] = Packet.r - this.E; this.E = Packet.r; this.g[this.ticks % 100] = Packet.o - this.F; this.F = Packet.o; this.h[this.ticks % 100] = Packet.p - this.G; this.G = Packet.p; this.methodProfiler.b(); this.methodProfiler.a("snooper"); if (!this.m.d() && this.ticks > 100) { this.m.a(); } if (this.ticks % 6000 == 0) { this.m.b(); } this.methodProfiler.b(); this.methodProfiler.b(); } public void r() { this.methodProfiler.a("levels"); // CraftBukkit start - only send timeupdates to the people in that world this.server.getScheduler().mainThreadHeartbeat(this.ticks); // Run tasks that are waiting on processing while (!processQueue.isEmpty()) { processQueue.remove().run(); } org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick(); // Send timeupdates 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 Packet4UpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime())); // Add support for per player time } } 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()); this.methodProfiler.a("pools"); worldserver.getVec3DPool().a(); this.methodProfiler.b(); /* Drop global time updates if (this.ticks % 20 == 0) { this.methodProfiler.a("timeSync"); this.s.a(new Packet4UpdateTime(worldserver.getTime(), worldserver.getDayTime()), worldserver.worldProvider.dimension); this.methodProfiler.b(); } // CraftBukkit end */ this.methodProfiler.a("tick"); CrashReport crashreport; try { worldserver.doTick(); } catch (Throwable throwable) { crashreport = CrashReport.a(throwable, "Exception ticking world"); worldserver.a(crashreport); throw new ReportedException(crashreport); } try { worldserver.tickEntities(); } catch (Throwable throwable1) { crashreport = CrashReport.a(throwable1, "Exception ticking world entities"); worldserver.a(crashreport); throw new ReportedException(crashreport); } this.methodProfiler.b(); this.methodProfiler.a("tracker"); worldserver.getTracker().updatePlayers(); this.methodProfiler.b(); this.methodProfiler.b(); // } // CraftBukkit // this.j[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit } this.methodProfiler.c("connection"); this.ae().b(); this.methodProfiler.c("players"); this.s.tick(); this.methodProfiler.c("tickables"); for (i = 0; i < this.o.size(); ++i) { ((IUpdatePlayerListBox) this.o.get(i)).a(); } this.methodProfiler.b(); } public boolean getAllowNether() { return true; } public void a(IUpdatePlayerListBox iupdateplayerlistbox) { this.o.add(iupdateplayerlistbox); } public static void main(final OptionSet options) { // CraftBukkit - replaces main(String[] astring) StatisticList.a(); IConsoleLogManager iconsolelogmanager = null; try { /* CraftBukkit start - replace everything boolean flag = false; String s = null; String s1 = "."; String s2 = null; boolean flag1 = false; boolean flag2 = false; int i = -1; for (int j = 0; j < astring.length; ++j) { String s3 = astring[j]; String s4 = j == astring.length - 1 ? null : astring[j + 1]; boolean flag3 = false; if (!s3.equals("nogui") && !s3.equals("--nogui")) { if (s3.equals("--port") && s4 != null) { flag3 = true; try { i = Integer.parseInt(s4); } catch (NumberFormatException numberformatexception) { ; } } else if (s3.equals("--singleplayer") && s4 != null) { flag3 = true; s = s4; } else if (s3.equals("--universe") && s4 != null) { flag3 = true; s1 = s4; } else if (s3.equals("--world") && s4 != null) { flag3 = true; s2 = s4; } else if (s3.equals("--demo")) { flag1 = true; } else if (s3.equals("--bonusChest")) { flag2 = true; } } else { flag = false; } if (flag3) { ++j; } } // */ DedicatedServer dedicatedserver = new DedicatedServer(options); iconsolelogmanager = dedicatedserver.getLogger(); if (options.has("port")) { int port = (Integer) options.valueOf("port"); if (port > 0) { dedicatedserver.setPort(port); } } if (options.has("universe")) { dedicatedserver.universe = (File) options.valueOf("universe"); } if (options.has("world")) { dedicatedserver.l((String) options.valueOf("world")); } /* if (s != null) { dedicatedserver.k(s); } if (s2 != null) { dedicatedserver.l(s2); } if (i >= 0) { dedicatedserver.setPort(i); } if (flag1) { dedicatedserver.b(true); } if (flag2) { dedicatedserver.c(true); } if (flag) { dedicatedserver.ao(); } */ dedicatedserver.primaryThread.start(); // Runtime.getRuntime().addShutdownHook(new ThreadShutdown(dedicatedserver)); // CraftBukkit end } catch (Exception exception) { if (iconsolelogmanager != null) { iconsolelogmanager.severe("Failed to start the minecraft server", exception); } else { Logger.getAnonymousLogger().log(Level.SEVERE, "Failed to start the minecraft server", exception); } } } public void t() { // (new ThreadServerApplication(this, "Server thread")).start(); // CraftBukkit - prevent abuse } public File e(String s) { return new File(this.o(), s); } public void info(String s) { this.getLogger().info(s); } public void warning(String s) { this.getLogger().warning(s); } public WorldServer getWorldServer(int i) { // CraftBukkit start for (WorldServer world : this.worlds) { if (world.dimension == i) { return world; } } return this.worlds.get(0); // CraftBukkit end } public String u() { return this.serverIp; } public int v() { return this.r; } public String w() { return this.motd; } public String getVersion() { return "1.5"; } public int y() { return this.s.getPlayerCount(); } public int z() { return this.s.getMaxPlayers(); } public String[] getPlayers() { return this.s.d(); } public String getPlugins() { // CraftBukkit start - whole method StringBuilder result = new StringBuilder(); org.bukkit.plugin.Plugin[] plugins = server.getPluginManager().getPlugins(); result.append(server.getName()); result.append(" on Bukkit "); result.append(server.getBukkitVersion()); if (plugins.length > 0 && this.server.getQueryPlugins()) { result.append(": "); for (int i = 0; i < plugins.length; i++) { if (i > 0) { result.append("; "); } result.append(plugins[i].getDescription().getName()); result.append(" "); result.append(plugins[i].getDescription().getVersion().replaceAll(";", ",")); } } return result.toString(); // CraftBukkit end } // CraftBukkit start public String h(final String s) { // CraftBukkit - final parameter Waitable waitable = new Waitable() { @Override protected String evaluate() { RemoteControlCommandListener.instance.c(); // Event changes start RemoteServerCommandEvent event = new RemoteServerCommandEvent(MinecraftServer.this.remoteConsole, s); MinecraftServer.this.server.getPluginManager().callEvent(event); // Event changes end ServerCommand servercommand = new ServerCommand(event.getCommand(), RemoteControlCommandListener.instance); // this.p.a(RemoteControlCommandListener.instance, s); MinecraftServer.this.server.dispatchServerCommand(MinecraftServer.this.remoteConsole, servercommand); // CraftBukkit return RemoteControlCommandListener.instance.d(); }}; processQueue.add(waitable); try { return waitable.get(); } catch (ExecutionException e) { throw new RuntimeException("Exception processing rcon command " + s, e.getCause()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); // Maintain interrupted state throw new RuntimeException("Interrupted processing rcon command " + s, e); } // CraftBukkit end } public boolean isDebugging() { return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode } public void i(String s) { this.getLogger().severe(s); } public void j(String s) { if (this.isDebugging()) { this.getLogger().info(s); } } public String getServerModName() { return "craftbukkit"; // CraftBukkit - cb > vanilla! } public CrashReport b(CrashReport crashreport) { crashreport.g().a("Profiler Position", (Callable) (new CrashReportProfilerPosition(this))); if (this.worlds != null && this.worlds.size() > 0 && this.worlds.get(0) != null) { crashreport.g().a("Vec3 Pool Size", (Callable) (new CrashReportVec3DPoolSize(this))); } if (this.s != null) { crashreport.g().a("Player Count", (Callable) (new CrashReportPlayerCount(this))); } return crashreport; } public List a(ICommandListener icommandlistener, String s) { // CraftBukkit start - Allow tab-completion of Bukkit commands /* ArrayList arraylist = new ArrayList(); if (s.startsWith("/")) { s = s.substring(1); boolean flag = !s.contains(" "); List list = this.p.b(icommandlistener, s); if (list != null) { Iterator iterator = list.iterator(); while (iterator.hasNext()) { String s1 = (String) iterator.next(); if (flag) { arraylist.add("/" + s1); } else { arraylist.add(s1); } } } return arraylist; } else { String[] astring = s.split(" ", -1); String s2 = astring[astring.length - 1]; String[] astring1 = this.s.d(); int i = astring1.length; for (int j = 0; j < i; ++j) { String s3 = astring1[j]; if (CommandAbstract.a(s2, s3)) { arraylist.add(s3); } } return arraylist; } */ return this.server.tabComplete(icommandlistener, s); // CraftBukkit end } public static MinecraftServer getServer() { return k; } public String getName() { return "Server"; } public void sendMessage(String s) { this.getLogger().info(StripColor.a(s)); } public boolean a(int i, String s) { return true; } public String a(String s, Object... aobject) { return LocaleLanguage.a().a(s, aobject); } public ICommandHandler getCommandHandler() { return this.p; } public KeyPair F() { return this.H; } public int G() { return this.r; } public void setPort(int i) { this.r = i; } public String H() { return this.I; } public void k(String s) { this.I = s; } public boolean I() { return this.I != null; } public String J() { return this.J; } public void l(String s) { this.J = s; } public void a(KeyPair keypair) { this.H = keypair; } public void c(int i) { // CraftBukkit start 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 = 3; worldserver.setSpawnFlags(true, true); } else if (this.I()) { worldserver.difficulty = i; worldserver.setSpawnFlags(worldserver.difficulty > 0, true); } else { worldserver.difficulty = i; worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals); } } } } protected boolean getSpawnMonsters() { return true; } public boolean M() { return this.demoMode; } public void b(boolean flag) { this.demoMode = flag; } public void c(boolean flag) { this.M = flag; } public Convertable getConvertable() { return this.convertable; } public void P() { this.N = true; this.getConvertable().d(); // CraftBukkit start - This needs review, what does it do? (it's new) for (int i = 0; i < this.worlds.size(); ++i) { WorldServer worldserver = this.worlds.get(i); // CraftBukkit end if (worldserver != null) { worldserver.saveLevel(); } } this.getConvertable().e(this.worlds.get(0).getDataManager().g()); // CraftBukkit this.safeShutdown(); } public String getTexturePack() { return this.O; } public void setTexturePack(String s) { this.O = s; } public void a(MojangStatisticsGenerator mojangstatisticsgenerator) { mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(false)); mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(0)); mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.y())); mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.z())); mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.s.getSeenPlayers().length)); mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode)); mojangstatisticsgenerator.a("gui_state", this.ag() ? "enabled" : "disabled"); mojangstatisticsgenerator.a("avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.i) * 1.0E-6D))); mojangstatisticsgenerator.a("avg_sent_packet_count", Integer.valueOf((int) MathHelper.a(this.e))); mojangstatisticsgenerator.a("avg_sent_packet_size", Integer.valueOf((int) MathHelper.a(this.f))); mojangstatisticsgenerator.a("avg_rec_packet_count", Integer.valueOf((int) MathHelper.a(this.g))); mojangstatisticsgenerator.a("avg_rec_packet_size", Integer.valueOf((int) MathHelper.a(this.h))); int i = 0; // CraftBukkit start for (int j = 0; j < this.worlds.size(); ++j) { // if (this.worldServer[j] != null) { WorldServer worldserver = this.worlds.get(j); // CraftBukkit end WorldData worlddata = worldserver.getWorldData(); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.dimension)); mojangstatisticsgenerator.a("world[" + i + "][mode]", worlddata.getGameType()); mojangstatisticsgenerator.a("world[" + i + "][difficulty]", Integer.valueOf(worldserver.difficulty)); 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.C)); mojangstatisticsgenerator.a("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.J().getLoadedChunks())); ++i; // } // CraftBukkit } mojangstatisticsgenerator.a("worlds", Integer.valueOf(i)); } public void b(MojangStatisticsGenerator mojangstatisticsgenerator) { mojangstatisticsgenerator.a("singleplayer", Boolean.valueOf(this.I())); mojangstatisticsgenerator.a("server_brand", this.getServerModName()); mojangstatisticsgenerator.a("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported"); mojangstatisticsgenerator.a("dedicated", Boolean.valueOf(this.T())); } public boolean getSnooperEnabled() { return true; } public int S() { return 16; } public abstract boolean T(); public boolean getOnlineMode() { return this.server.getOnlineMode(); // CraftBukkit } public void setOnlineMode(boolean flag) { this.onlineMode = flag; } public boolean getSpawnAnimals() { return this.spawnAnimals; } public void setSpawnAnimals(boolean flag) { this.spawnAnimals = flag; } public boolean getSpawnNPCs() { return this.spawnNPCs; } public void setSpawnNPCs(boolean flag) { this.spawnNPCs = flag; } public boolean getPvP() { return this.pvpMode; } public void setPvP(boolean flag) { this.pvpMode = flag; } public boolean getAllowFlight() { return this.allowFlight; } public void setAllowFlight(boolean flag) { this.allowFlight = flag; } public abstract boolean getEnableCommandBlock(); public String getMotd() { return this.motd; } public void setMotd(String s) { this.motd = s; } public int getMaxBuildHeight() { return this.C; } public void d(int i) { this.C = i; } public boolean isStopped() { return this.isStopped; } public PlayerList getPlayerList() { return this.s; } public void a(PlayerList playerlist) { this.s = playerlist; } public void a(EnumGamemode enumgamemode) { // CraftBukkit start for (int i = 0; i < this.worlds.size(); ++i) { getServer().worlds.get(i).getWorldData().setGameType(enumgamemode); // CraftBukkit end } } public abstract ServerConnection ae(); public boolean ag() { return false; } public abstract String a(EnumGamemode enumgamemode, boolean flag); public int ah() { return this.ticks; } public void ai() { this.S = true; } public ChunkCoordinates b() { return new ChunkCoordinates(0, 0, 0); } public int getSpawnProtection() { return 16; } public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { return false; } public abstract IConsoleLogManager getLogger(); public static PlayerList a(MinecraftServer minecraftserver) { return minecraftserver.s; } }