9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 11:59:24 +00:00

Update changes from ver/1.21.4 branch

This commit is contained in:
Dreeam
2025-04-17 03:44:13 -04:00
parent 3f4246fe9a
commit c12312bc33
50 changed files with 1082 additions and 309 deletions

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Async playerdata saving
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index 1456f2d1a92c8315177fb03d0c7ec943d5f5b097..e70692272aae39ea01fb6860ec4cb703ea531781 100644
index 1456f2d1a92c8315177fb03d0c7ec943d5f5b097..aadc92b9e82bfe3d65ea8f47ac28ba2d70eb3a7f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -199,7 +199,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
@@ -17,34 +17,21 @@ index 1456f2d1a92c8315177fb03d0c7ec943d5f5b097..e70692272aae39ea01fb6860ec4cb703
}
private CompoundTag getBukkitData() {
@@ -744,6 +744,17 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
@@ -744,16 +744,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
* @param compoundTag
*/
private void save(CompoundTag compoundTag) {
+ // Leaf start - Async playerdata saving
+ synchronized (server.console.playerDataStorage) {
+ while (server.console.playerDataStorage.savingQueue.contains(getUniqueId())) {
+ try {
+ Thread.sleep(1L);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ server.console.playerDataStorage.savingQueue.add(getUniqueId());
+ }
+ // Leaf end - Async playerdata saving
File playerDir = server.console.playerDataStorage.getPlayerDir();
try {
File tempFile = File.createTempFile(this.getUniqueId()+"-", ".dat", playerDir);
@@ -753,6 +764,12 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
net.minecraft.Util.safeReplaceFile(playerDataFile.toPath(), tempFile.toPath(), playerDataFileOld.toPath());
} catch (java.io.IOException e) {
e.printStackTrace();
+ // Leaf start - Async playerdata saving
+ } finally {
+ synchronized (server.console.playerDataStorage) {
+ server.console.playerDataStorage.savingQueue.remove(getUniqueId());
+ }
+ // Leaf end - Async playerdata saving
}
- File playerDir = server.console.playerDataStorage.getPlayerDir();
- try {
- File tempFile = File.createTempFile(this.getUniqueId()+"-", ".dat", playerDir);
- net.minecraft.nbt.NbtIo.writeCompressed(compoundTag, tempFile.toPath());
- File playerDataFile = new File(playerDir, this.getUniqueId()+".dat");
- File playerDataFileOld = new File(playerDir, this.getUniqueId()+".dat_old");
- net.minecraft.Util.safeReplaceFile(playerDataFile.toPath(), tempFile.toPath(), playerDataFileOld.toPath());
- } catch (java.io.IOException e) {
- e.printStackTrace();
- }
+ server.console.playerDataStorage.save(this.getName(), this.getUniqueId(), this.getUniqueId().toString(), compoundTag); // Leaf - Async playerdata saving
}
// Purpur end - OfflinePlayer API
}