Merge pull request #3857 from Warriorrrr/feature/stringify-async

Stringify json for json file client async
This commit is contained in:
mikeprimm 2022-11-29 15:43:31 -06:00 committed by GitHub
commit d048aad743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ import org.json.simple.parser.ParseException;
import static org.dynmap.JSONUtils.*; import static org.dynmap.JSONUtils.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.concurrent.CompletableFuture;
public class JsonFileClientUpdateComponent extends ClientUpdateComponent { public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
protected long jsonInterval; protected long jsonInterval;
@ -338,9 +339,12 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
else { else {
outputFile = "dynmap_" + dynmapWorld.getName() + ".json"; outputFile = "dynmap_" + dynmapWorld.getName() + ".json";
} }
CompletableFuture.runAsync(() -> {
byte[] content = Json.stringifyJson(update).getBytes(cs_utf8); byte[] content = Json.stringifyJson(update).getBytes(cs_utf8);
enqueueFileWrite(outputFile, content, dowrap); enqueueFileWrite(outputFile, content, dowrap);
});
} }
} }