2020-07-17 18:05:50 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-08-03 18:48:42 +02:00
|
|
|
From: tsao chi <tsao-chi@the-lingo.org>
|
|
|
|
Date: Fri, 31 Jul 2020 22:11:10 -0500
|
|
|
|
Subject: [PATCH] Akarin Updated Save json list async
|
2020-06-27 18:09:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
|
2020-08-03 18:48:42 +02:00
|
|
|
index 9213bfb78e92b838189161045e3945588251b486..6d7452d05c648cdee50b2077aec6f100449b8229 100644
|
2020-06-27 18:09:09 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/JsonList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/JsonList.java
|
|
|
|
@@ -20,6 +20,8 @@ import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
@@ -146,6 +148,7 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void save() throws IOException {
|
|
|
|
+ Runnable runnable = () -> { // Akarin - Save json list async
|
|
|
|
this.removeStaleEntries(); // Paper - remove expired values before saving
|
|
|
|
JsonArray jsonarray = new JsonArray();
|
|
|
|
|
2020-08-03 18:48:42 +02:00
|
|
|
@@ -155,29 +158,20 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
|
2020-06-27 18:09:09 +02:00
|
|
|
jsonlistentry.getClass();
|
|
|
|
return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error
|
|
|
|
}).forEach(jsonarray::add);
|
|
|
|
- BufferedWriter bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8);
|
|
|
|
+ BufferedWriter bufferedwriter = null;
|
|
|
|
Throwable throwable = null;
|
|
|
|
|
|
|
|
try {
|
2020-08-03 18:48:42 +02:00
|
|
|
+ bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8);
|
2020-06-27 18:09:09 +02:00
|
|
|
JsonList.b.toJson(jsonarray, bufferedwriter);
|
|
|
|
} catch (Throwable throwable1) {
|
2020-08-03 18:48:42 +02:00
|
|
|
- throwable = throwable1;
|
2020-06-27 18:09:09 +02:00
|
|
|
- throw throwable1;
|
2020-08-03 18:48:42 +02:00
|
|
|
+ throw new RuntimeException(throwable1);
|
2020-06-27 18:09:09 +02:00
|
|
|
} finally {
|
|
|
|
- if (bufferedwriter != null) {
|
|
|
|
- if (throwable != null) {
|
|
|
|
- try {
|
|
|
|
- bufferedwriter.close();
|
|
|
|
- } catch (Throwable throwable2) {
|
|
|
|
- throwable.addSuppressed(throwable2);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- bufferedwriter.close();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
2020-08-03 18:48:42 +02:00
|
|
|
+ IOUtils.closeQuietly(bufferedwriter);
|
|
|
|
}
|
|
|
|
|
2020-06-27 18:09:09 +02:00
|
|
|
+ }; // Akarin - Save json list async
|
|
|
|
+ MCUtil.scheduleAsyncTask(runnable); // Akarin - Save json list async
|
|
|
|
}
|
|
|
|
|
|
|
|
public void load() throws IOException {
|