mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-29 06:05:14 +01:00
ab975588e5
Also dropped a patch that I think was kinda unnecessary.
55 lines
2.3 KiB
Diff
55 lines
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
|
|
index 9213bfb78e92b838189161045e3945588251b486..3fb72d6ee587d66a9b7e1dec27fc4f64b82ab4df 100644
|
|
--- a/src/main/java/net/minecraft/server/JsonList.java
|
|
+++ b/src/main/java/net/minecraft/server/JsonList.java
|
|
@@ -146,6 +146,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();
|
|
|
|
@@ -155,29 +156,20 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
|
|
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 {
|
|
+ bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8);
|
|
JsonList.b.toJson(jsonarray, bufferedwriter);
|
|
} catch (Throwable throwable1) {
|
|
- throwable = throwable1;
|
|
- throw throwable1;
|
|
+ throw new RuntimeException(throwable1);
|
|
} finally {
|
|
- if (bufferedwriter != null) {
|
|
- if (throwable != null) {
|
|
- try {
|
|
- bufferedwriter.close();
|
|
- } catch (Throwable throwable2) {
|
|
- throwable.addSuppressed(throwable2);
|
|
- }
|
|
- } else {
|
|
- bufferedwriter.close();
|
|
- }
|
|
- }
|
|
-
|
|
+ org.apache.commons.io.IOUtils.closeQuietly(bufferedwriter);
|
|
}
|
|
|
|
+ }; // Akarin - Save json list async
|
|
+ MCUtil.scheduleAsyncTask(runnable); // Akarin - Save json list async
|
|
}
|
|
|
|
public void load() throws IOException {
|