Example #1
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));
  }
  public void a(MojangStatisticsGenerator mojangstatisticsgenerator) {
    mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(false));
    mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(0));
    if (this.v != null) {
      mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.G()));
      mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.H()));
      mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.v.getSeenPlayers().length));
    }

    mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode));
    mojangstatisticsgenerator.a("gui_state", this.aq() ? "enabled" : "disabled");
    mojangstatisticsgenerator.a(
        "run_time", Long.valueOf((ax() - mojangstatisticsgenerator.g()) / 60L * 1000L));
    mojangstatisticsgenerator.a(
        "avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.g) * 1.0E-6D)));
    int i = 0;

    if (this.worldServer != null) {
      // CraftBukkit start
      for (int j = 0; j < this.worlds.size(); ++j) {
        WorldServer worldserver = this.worlds.get(j);
        if (worldserver != null) {
          // CraftBukkit end
          WorldData worlddata = worldserver.getWorldData();

          mojangstatisticsgenerator.a(
              "world[" + i + "][dimension]",
              Integer.valueOf(worldserver.worldProvider.getDimension()));
          mojangstatisticsgenerator.a("world[" + i + "][mode]", worlddata.getGameType());
          mojangstatisticsgenerator.a("world[" + i + "][difficulty]", worldserver.getDifficulty());
          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.F));
          mojangstatisticsgenerator.a(
              "world[" + i + "][chunks_loaded]",
              Integer.valueOf(worldserver.N().getLoadedChunks()));
          ++i;
        }
      }
    }

    mojangstatisticsgenerator.a("worlds", Integer.valueOf(i));
  }
Example #3
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);
        }
      }
    }
  }
  public void a(EnumDifficulty enumdifficulty) {
    // CraftBukkit start
    for (int i = 0; i < this.worlds.size(); ++i) {
      WorldServer worldserver = this.worlds.get(i);
      // CraftBukkit end

      if (worldserver != null) {
        if (worldserver.getWorldData().isHardcore()) {
          worldserver.getWorldData().setDifficulty(EnumDifficulty.HARD);
          worldserver.setSpawnFlags(true, true);
        } else if (this.S()) {
          worldserver.getWorldData().setDifficulty(enumdifficulty);
          worldserver.setSpawnFlags(worldserver.getDifficulty() != EnumDifficulty.PEACEFUL, true);
        } else {
          worldserver.getWorldData().setDifficulty(enumdifficulty);
          worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals);
        }
      }
    }
  }