private void w() {
    long i = System.nanoTime();
    ArrayList arraylist = new ArrayList();
    Iterator iterator = trackerList.keySet().iterator();

    while (iterator.hasNext()) {
      String s = (String) iterator.next();
      int j = ((Integer) trackerList.get(s)).intValue();

      if (j > 0) {
        trackerList.put(s, Integer.valueOf(j - 1));
      } else {
        arraylist.add(s);
      }
    }

    int k;

    for (k = 0; k < arraylist.size(); ++k) {
      trackerList.remove(arraylist.get(k));
    }

    AxisAlignedBB.a();
    Vec3D.a();
    ++this.ticks;

    // CraftBukkit start - only send timeupdates to the people in that world

    ((org.bukkit.craftbukkit.scheduler.CraftScheduler) this.server.getScheduler())
        .mainThreadHeartbeat(this.ticks);

    // Send timeupdates to everyone, it will get the right time from the world the player is in.
    if (this.ticks % 20 == 0) {
      for (k = 0; k < this.serverConfigurationManager.players.size(); ++k) {
        EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k);
        entityplayer.netServerHandler.sendPacket(
            new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time
      }
    }

    for (k = 0; k < this.worlds.size(); ++k) {
      long l = System.nanoTime();
      // if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
      WorldServer worldserver = this.worlds.get(k);

      /* Drop global timeupdates
      if (this.ticks % 20 == 0) {
          this.serverConfigurationManager.a(new Packet4UpdateTime(worldserver.getTime()), worldserver.worldProvider.dimension);
      }
      // CraftBukkit end */

      worldserver.doTick();

      while (true) {
        if (!worldserver.updateLights()) {
          worldserver.tickEntities();
          break;
        }
      }
    }

    // this.g[k][this.ticks % 100] = System.nanoTime() - l; // CraftBukkit
    // } // CraftBukkit

    this.networkListenThread.a();
    this.serverConfigurationManager.tick();

    // CraftBukkit start
    for (k = 0; k < this.worlds.size(); ++k) {
      this.worlds.get(k).tracker.updatePlayers();
    }
    // CraftBukkit end

    for (k = 0; k < this.C.size(); ++k) {
      ((IUpdatePlayerListBox) this.C.get(k)).a();
    }

    try {
      this.b();
    } catch (Exception exception) {
      log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
    }

    this.f[this.ticks % 100] = System.nanoTime() - i;
    this.u[this.ticks % 100] = Packet.n - this.E;
    this.E = Packet.n;
    this.v[this.ticks % 100] = Packet.o - this.F;
    this.F = Packet.o;
    this.w[this.ticks % 100] = Packet.l - this.G;
    this.G = Packet.l;
    this.x[this.ticks % 100] = Packet.m - this.H;
    this.H = Packet.m;
  }
Esempio n. 2
0
  private void w() {
    long i = System.nanoTime();
    ArrayList arraylist = new ArrayList();
    Iterator iterator = trackerList.keySet().iterator();

    while (iterator.hasNext()) {
      String s = (String) iterator.next();
      int j = ((Integer) trackerList.get(s)).intValue();

      if (j > 0) {
        trackerList.put(s, Integer.valueOf(j - 1));
      } else {
        arraylist.add(s);
      }
    }

    int k;

    for (k = 0; k < arraylist.size(); ++k) {
      trackerList.remove(arraylist.get(k));
    }

    AxisAlignedBB.a();
    Vec3D.a();
    ++this.ticks;

    for (k = 0; k < this.worldServer.length; ++k) {
      long l = System.nanoTime();

      if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) {
        WorldServer worldserver = this.worldServer[k];

        if (this.ticks % 20 == 0) {
          this.serverConfigurationManager.a(
              new Packet4UpdateTime(worldserver.getTime()), worldserver.worldProvider.dimension);
        }

        worldserver.doTick();

        while (true) {
          if (!worldserver.updateLights()) {
            worldserver.tickEntities();
            break;
          }
        }
      }

      this.g[k][this.ticks % 100] = System.nanoTime() - l;
    }

    this.networkListenThread.a();
    this.serverConfigurationManager.tick();

    for (k = 0; k < this.tracker.length; ++k) {
      this.tracker[k].updatePlayers();
    }

    for (k = 0; k < this.C.size(); ++k) {
      ((IUpdatePlayerListBox) this.C.get(k)).a();
    }

    try {
      this.b();
    } catch (Exception exception) {
      log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
    }

    this.f[this.ticks % 100] = System.nanoTime() - i;
    this.u[this.ticks % 100] = Packet.n - this.E;
    this.E = Packet.n;
    this.v[this.ticks % 100] = Packet.o - this.F;
    this.F = Packet.o;
    this.w[this.ticks % 100] = Packet.l - this.G;
    this.G = Packet.l;
    this.x[this.ticks % 100] = Packet.m - this.H;
    this.H = Packet.m;
  }
  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();
  }
Esempio n. 4
0
  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));
    }

    this.worldServer = new WorldServer[3];
    this.g = new long[this.worldServer.length][100];
    int j = this.propertyManager.getInt("gamemode", 0);

    j = WorldSettings.a(j);
    log.info("Default game type: " + j);
    boolean flag = this.propertyManager.getBoolean("generate-structures", true);
    WorldSettings worldsettings = new WorldSettings(i, j, flag, false, worldtype);
    ServerNBTManager servernbtmanager = new ServerNBTManager(new File("."), s, true);

    for (int k = 0; k < this.worldServer.length; ++k) {
      byte b0 = 0;

      if (k == 1) {
        b0 = -1;
      }

      if (k == 2) {
        b0 = 1;
      }

      if (k == 0) {
        this.worldServer[k] = new WorldServer(this, servernbtmanager, s, b0, worldsettings);
      } else {
        this.worldServer[k] =
            new SecondaryWorldServer(
                this, servernbtmanager, s, b0, worldsettings, this.worldServer[0]);
      }

      this.worldServer[k].addIWorldAccess(new WorldManager(this, this.worldServer[k]));
      this.worldServer[k].difficulty = this.propertyManager.getInt("difficulty", 1);
      this.worldServer[k].setSpawnFlags(
          this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals);
      this.worldServer[k].getWorldData().setGameType(j);
      this.serverConfigurationManager.setPlayerFileData(this.worldServer);
    }

    short short1 = 196;
    long l = System.currentTimeMillis();

    for (int i1 = 0; i1 < 1; ++i1) {
      log.info("Preparing start region for level " + i1);
      WorldServer worldserver = this.worldServer[i1];
      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) {;
          }
        }
      }
    }

    this.t();
  }