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;
  }
예제 #2
0
  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();
  }