Skip to content

Commit

Permalink
Formatting data in a file
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSerpskiStalker committed Jan 7, 2025
1 parent 22e780f commit 4823b8e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ private void saveEntityData()
{
try (Writer writer = new FileWriter(SAVE_FILE))
{
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonArray jsonArray = new JsonArray();

for (Map.Entry<UUID, EntityData> entry : ENTITY_DATA_MAP.entrySet())
{
JsonObject jsonEntity = new JsonObject();
Expand All @@ -184,7 +186,10 @@ private void saveEntityData()
jsonEntity.add("nbt", JsonUtils.convertNBTToJson(entry.getValue().nbt));
jsonArray.add(jsonEntity);
}
writer.write(jsonArray.toString());

String jsonOutput = gson.toJson(jsonArray);

writer.write(jsonOutput);
}
catch (IOException e)
{
Expand Down

0 comments on commit 4823b8e

Please sign in to comment.