gt:                 long i = System.currentTimeMillis();
context: 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 {
  
      public static Logger log = Logger.getLogger("Minecraft");
      private static MinecraftServer l = null;
      public Convertable convertable; // CraftBukkit - private final -> public
      private final MojangStatisticsGenerator n = new MojangStatisticsGenerator("server", this);
      public File universe; // CraftBukkit - private final -> public
      private final List p = new ArrayList();
      private final ICommandHandler q;
      public final MethodProfiler methodProfiler = new MethodProfiler();
      private String serverIp;
      private int s = -1;
      // public WorldServer[] worldServer; // CraftBukkit - removed!
      private ServerConfigurationManagerAbstract t;
      private boolean isRunning = true;
      private boolean isStopped = false;
      private int ticks = 0;
      public String d;
      public int e;
      private boolean onlineMode;
      private boolean spawnAnimals;
      private boolean spawnNPCs;
      private boolean pvpMode;
      private boolean allowFlight;
      private String motd;
      private int D;
      private long E;
      private long F;
      private long G;
      private long H;
      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 final long[] j = new long[100];
      public long[][] k;
      private KeyPair I;
      private String J;
      private String K;
      private boolean demoMode;
      private boolean N;
      private boolean O;
      private String P = "";
      private boolean Q = false;
      private long R;
      private String S;
      private boolean T;
  
      // CraftBukkit start
      public List<WorldServer> worlds = new ArrayList<WorldServer>();
      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<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
      public int autosavePeriod;
      // CraftBukkit end
  
      public MinecraftServer(OptionSet options) { // CraftBukkit - signature file -> OptionSet
          l = this;
          // this.universe = file1; // CraftBukkit
          this.q = new CommandDispatcher();
          // this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved to DedicatedServer.init
          this.al();
  
          // 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 al() {
          BlockDispenser.a.a(Item.ARROW, new DispenseBehaviorArrow(this));
          BlockDispenser.a.a(Item.EGG, new DispenseBehaviorEgg(this));
          BlockDispenser.a.a(Item.SNOW_BALL, new DispenseBehaviorSnowBall(this));
          BlockDispenser.a.a(Item.EXP_BOTTLE, new DispenseBehaviorExpBottle(this));
          BlockDispenser.a.a(Item.POTION, new DispenseBehaviorPotion(this));
          BlockDispenser.a.a(Item.MONSTER_EGG, new DispenseBehaviorMonsterEgg(this));
          BlockDispenser.a.a(Item.FIREBALL, new DispenseBehaviorFireball(this));
          DispenseBehaviorMinecart dispensebehaviorminecart = new DispenseBehaviorMinecart(this);
  
          BlockDispenser.a.a(Item.MINECART, dispensebehaviorminecart);
          BlockDispenser.a.a(Item.STORAGE_MINECART, dispensebehaviorminecart);
          BlockDispenser.a.a(Item.POWERED_MINECART, dispensebehaviorminecart);
          BlockDispenser.a.a(Item.BOAT, new DispenseBehaviorBoat(this));
          DispenseBehaviorFilledBucket dispensebehaviorfilledbucket = new DispenseBehaviorFilledBucket(this);
  
          BlockDispenser.a.a(Item.LAVA_BUCKET, dispensebehaviorfilledbucket);
          BlockDispenser.a.a(Item.WATER_BUCKET, dispensebehaviorfilledbucket);
          BlockDispenser.a.a(Item.BUCKET, new DispenseBehaviorEmptyBucket(this));
      }
  
      protected abstract boolean init() throws java.net.UnknownHostException; // CraftBukkit - throws UnknownHostException
  
      protected void b(String s) {
          if (this.getConvertable().isConvertable(s)) {
              log.info("Converting map!");
              this.c("menu.convertingLevel");
              this.getConvertable().convert(s, new ConvertProgressUpdater(this));
          }
      }
  
      protected synchronized void c(String s) {
          this.S = s;
      }
  
      protected void a(String s, String s1, long i, WorldType worldtype, String s2) {
          this.b(s);
          this.c("menu.loadingLevel");
          // CraftBukkit - removed world and 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);
                  } else {
                      // CraftBukkit
                      world = new WorldServer(this, new ServerNBTManager(server.getWorldContainer(), s1, true), s1, dimension, worldsettings, this.methodProfiler, 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())) {
                      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, 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.t.setPlayerFileData(this.worlds.toArray(new WorldServer[this.worlds.size()]));
              // CraftBukkit end
          }
  
          this.c(this.getDifficulty());
          this.e();
      }
  
      protected void e() {
          short short1 = 196;
          long i = System.currentTimeMillis();
  
          this.c("menu.generatingTerrain");
          byte b0 = 0;
  
          // CraftBukkit start
          for (int j = 0; j < this.worlds.size(); ++j) {
              WorldServer worldserver = this.worlds.get(j);
              log.info("Preparing start region for level " + j + " (Seed: " + worldserver.getSeed() + ")");
              if (!worldserver.getWorld().getKeepSpawnInMemory()) {
                  continue;
              }
              // CraftBukkit end
              ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
  
              for (int k = -short1; k <= short1 && this.isRunning(); k += 16) {
                  for (int l = -short1; l <= short1 && this.isRunning(); l += 16) {
                      long i1 = System.currentTimeMillis();
  
                      if (i1 < i) {
                          i = i1;
                      }
  
                      if (i1 > i + 1000L) {
                          int j1 = (short1 * 2 + 1) * (short1 * 2 + 1);
                          int k1 = (k + short1) * (short1 * 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);
                  }
              }
          }
  
          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.d = s;
          this.e = i;
          log.info(s + ": " + i + "%");
      }
  
      protected void j() {
          this.d = null;
          this.e = 0;
  
          this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit
      }
  
      protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws
          if (!this.O) {
              // CraftBukkit start
              for (int j = 0; j < this.worlds.size(); ++j) {
                  WorldServer worldserver = this.worlds.get(j);
  
                  if (worldserver != null) {
                      if (!flag) {
                          log.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.O) {
              log.info("Stopping server");
              // CraftBukkit start
              if (this.server != null) {
                  this.server.disablePlugins();
              }
              // CraftBukkit end
  
              if (this.ae() != null) {
                  this.ae().a();
              }
  
              if (this.t != null) {
                  log.info("Saving players");
                  this.t.savePlayers();
                  this.t.r();
              }
  
              log.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.n != null && this.n.d()) {
                  this.n.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()) {
  