Exemplo n.º 1
0
  public void outputWorldStats(File statsFile, String varNamePrefix) {
    if (statsFile.exists()) statsFile.delete();

    System.out.println("Outputting world stats to " + statsFile.getAbsolutePath());

    JsonWriter jsWriter = null;
    try {
      jsWriter = new JsonWriter(statsFile);
      jsWriter.startObject(varNamePrefix + "_worldStats");

      jsWriter.writeVariable("numChunks", "" + numChunks);
      jsWriter.writeVariable("numPortals", "" + numPortals);
      jsWriter.writeVariable("numPlayers", "" + numPlayers);

      jsWriter.endObject();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (jsWriter != null) jsWriter.close();
    }

    System.out.println("Outputted world stats");
  }