Ejemplo n.º 1
0
  /** Saves all necessary data as preparation for stopping the server. */
  public void stopServer() {
    if (!this.worldIsBeingDeleted) {
      logger.info("Stopping server");

      if (this.getNetworkSystem() != null) {
        this.getNetworkSystem().terminateEndpoints();
      }

      if (this.serverConfigManager != null) {
        logger.info("Saving players");
        this.serverConfigManager.saveAllPlayerData();
        this.serverConfigManager.removeAllPlayers();
      }

      if (this.worldServers != null) {
        logger.info("Saving worlds");
        this.saveAllWorlds(false);

        for (int var1 = 0; var1 < this.worldServers.length; ++var1) {
          WorldServer var2 = this.worldServers[var1];
          var2.flush();
        }
      }

      if (this.usageSnooper.isSnooperRunning()) {
        this.usageSnooper.stopSnooper();
      }
    }
  }
Ejemplo n.º 2
0
  /** par1 indicates if a log message should be output. */
  protected void saveAllWorlds(boolean dontLog) {
    if (!this.worldIsBeingDeleted) {
      WorldServer[] var2 = this.worldServers;
      int var3 = var2.length;

      for (int var4 = 0; var4 < var3; ++var4) {
        WorldServer var5 = var2[var4];

        if (var5 != null) {
          if (!dontLog) {
            logger.info(
                "Saving chunks for level \'"
                    + var5.getWorldInfo().getWorldName()
                    + "\'/"
                    + var5.provider.getDimensionName());
          }

          try {
            var5.saveAllChunks(true, (IProgressUpdate) null);
          } catch (MinecraftException var7) {
            logger.warn(var7.getMessage());
          }
        }
      }
    }
  }
Ejemplo n.º 3
0
  protected void initialWorldChunkLoad() {
    boolean var1 = true;
    boolean var2 = true;
    boolean var3 = true;
    boolean var4 = true;
    int var5 = 0;
    this.setUserMessage("menu.generatingTerrain");
    byte var6 = 0;
    logger.info("Preparing start region for level " + var6);
    WorldServer var7 = this.worldServers[var6];
    BlockPos var8 = var7.getSpawnPoint();
    long var9 = getCurrentTimeMillis();

    for (int var11 = -192; var11 <= 192 && this.isServerRunning(); var11 += 16) {
      for (int var12 = -192; var12 <= 192 && this.isServerRunning(); var12 += 16) {
        long var13 = getCurrentTimeMillis();

        if (var13 - var9 > 1000L) {
          this.outputPercentRemaining("Preparing spawn area", var5 * 100 / 625);
          var9 = var13;
        }

        ++var5;
        var7.theChunkProviderServer.loadChunk(var8.getX() + var11 >> 4, var8.getZ() + var12 >> 4);
      }
    }

    this.clearCurrentTask();
  }
Ejemplo n.º 4
0
  public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper) {
    playerSnooper.addClientStat("whitelist_enabled", Boolean.valueOf(false));
    playerSnooper.addClientStat("whitelist_count", Integer.valueOf(0));

    if (this.serverConfigManager != null) {
      playerSnooper.addClientStat("players_current", Integer.valueOf(this.getCurrentPlayerCount()));
      playerSnooper.addClientStat("players_max", Integer.valueOf(this.getMaxPlayers()));
      playerSnooper.addClientStat(
          "players_seen", Integer.valueOf(this.serverConfigManager.getAvailablePlayerDat().length));
    }

    playerSnooper.addClientStat("uses_auth", Boolean.valueOf(this.onlineMode));
    playerSnooper.addClientStat("gui_state", this.getGuiEnabled() ? "enabled" : "disabled");
    playerSnooper.addClientStat(
        "run_time",
        Long.valueOf(
            (getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat(
        "avg_tick_ms", Integer.valueOf((int) (MathHelper.average(this.tickTimeArray) * 1.0E-6D)));
    int var2 = 0;

    if (this.worldServers != null) {
      for (int var3 = 0; var3 < this.worldServers.length; ++var3) {
        if (this.worldServers[var3] != null) {
          WorldServer var4 = this.worldServers[var3];
          WorldInfo var5 = var4.getWorldInfo();
          playerSnooper.addClientStat(
              "world[" + var2 + "][dimension]", Integer.valueOf(var4.provider.getDimensionId()));
          playerSnooper.addClientStat("world[" + var2 + "][mode]", var5.getGameType());
          playerSnooper.addClientStat("world[" + var2 + "][difficulty]", var4.getDifficulty());
          playerSnooper.addClientStat(
              "world[" + var2 + "][hardcore]", Boolean.valueOf(var5.isHardcoreModeEnabled()));
          playerSnooper.addClientStat(
              "world[" + var2 + "][generator_name]", var5.getTerrainType().getWorldTypeName());
          playerSnooper.addClientStat(
              "world[" + var2 + "][generator_version]",
              Integer.valueOf(var5.getTerrainType().getGeneratorVersion()));
          playerSnooper.addClientStat(
              "world[" + var2 + "][height]", Integer.valueOf(this.buildLimit));
          playerSnooper.addClientStat(
              "world[" + var2 + "][chunks_loaded]",
              Integer.valueOf(var4.getChunkProvider().getLoadedChunkCount()));
          ++var2;
        }
      }
    }

    playerSnooper.addClientStat("worlds", Integer.valueOf(var2));
  }
Ejemplo n.º 5
0
  /**
   * WARNING : directly calls
   * getActiveAnvilConverter().deleteWorldDirectory(theWorldServer[0].getSaveHandler().getWorldDirectoryName());
   */
  public void deleteWorldAndStopServer() {
    this.worldIsBeingDeleted = true;
    this.getActiveAnvilConverter().flushCache();

    for (int var1 = 0; var1 < this.worldServers.length; ++var1) {
      WorldServer var2 = this.worldServers[var1];

      if (var2 != null) {
        var2.flush();
      }
    }

    this.getActiveAnvilConverter()
        .deleteWorldDirectory(this.worldServers[0].getSaveHandler().getWorldDirectoryName());
    this.initiateShutdown();
  }
Ejemplo n.º 6
0
  public Entity getEntityFromUuid(UUID uuid) {
    WorldServer[] var2 = this.worldServers;
    int var3 = var2.length;

    for (int var4 = 0; var4 < var3; ++var4) {
      WorldServer var5 = var2[var4];

      if (var5 != null) {
        Entity var6 = var5.getEntityFromUuid(uuid);

        if (var6 != null) {
          return var6;
        }
      }
    }

    return null;
  }
Ejemplo n.º 7
0
  public void setDifficultyForAllWorlds(EnumDifficulty difficulty) {
    for (int var2 = 0; var2 < this.worldServers.length; ++var2) {
      WorldServer var3 = this.worldServers[var2];

      if (var3 != null) {
        if (var3.getWorldInfo().isHardcoreModeEnabled()) {
          var3.getWorldInfo().setDifficulty(EnumDifficulty.HARD);
          var3.setAllowedSpawnTypes(true, true);
        } else if (this.isSinglePlayer()) {
          var3.getWorldInfo().setDifficulty(difficulty);
          var3.setAllowedSpawnTypes(var3.getDifficulty() != EnumDifficulty.PEACEFUL, true);
        } else {
          var3.getWorldInfo().setDifficulty(difficulty);
          var3.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals);
        }
      }
    }
  }
Ejemplo n.º 8
0
  public void updateTimeLightAndEntities() {
    this.theProfiler.startSection("jobs");
    Queue var1 = this.futureTaskQueue;

    synchronized (this.futureTaskQueue) {
      while (!this.futureTaskQueue.isEmpty()) {
        try {
          ((FutureTask) this.futureTaskQueue.poll()).run();
        } catch (Throwable var9) {
          logger.fatal(var9);
        }
      }
    }

    this.theProfiler.endStartSection("levels");
    int var11;

    for (var11 = 0; var11 < this.worldServers.length; ++var11) {
      long var2 = System.nanoTime();

      if (var11 == 0 || this.getAllowNether()) {
        WorldServer var4 = this.worldServers[var11];
        this.theProfiler.startSection(var4.getWorldInfo().getWorldName());

        if (this.tickCounter % 20 == 0) {
          this.theProfiler.startSection("timeSync");
          this.serverConfigManager.sendPacketToAllPlayersInDimension(
              new S03PacketTimeUpdate(
                  var4.getTotalWorldTime(),
                  var4.getWorldTime(),
                  var4.getGameRules().getGameRuleBooleanValue("doDaylightCycle")),
              var4.provider.getDimensionId());
          this.theProfiler.endSection();
        }

        this.theProfiler.startSection("tick");
        CrashReport var6;

        try {
          var4.tick();
        } catch (Throwable var8) {
          var6 = CrashReport.makeCrashReport(var8, "Exception ticking world");
          var4.addWorldInfoToCrashReport(var6);
          throw new ReportedException(var6);
        }

        try {
          var4.updateEntities();
        } catch (Throwable var7) {
          var6 = CrashReport.makeCrashReport(var7, "Exception ticking world entities");
          var4.addWorldInfoToCrashReport(var6);
          throw new ReportedException(var6);
        }

        this.theProfiler.endSection();
        this.theProfiler.startSection("tracker");
        var4.getEntityTracker().updateTrackedEntities();
        this.theProfiler.endSection();
        this.theProfiler.endSection();
      }

      this.timeOfLastDimensionTick[var11][this.tickCounter % 100] = System.nanoTime() - var2;
    }

    this.theProfiler.endStartSection("connection");
    this.getNetworkSystem().networkTick();
    this.theProfiler.endStartSection("players");
    this.serverConfigManager.onTick();
    this.theProfiler.endStartSection("tickables");

    for (var11 = 0; var11 < this.playersOnline.size(); ++var11) {
      ((IUpdatePlayerListBox) this.playersOnline.get(var11)).update();
    }

    this.theProfiler.endSection();
  }