mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 18:39:23 +00:00
* Added Leaf Commands base * Added WIP /leaf reload * Added /leaf version * Change /gale permission to OP as default
57 lines
2.8 KiB
Diff
57 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Fri, 23 Aug 2024 22:04:20 -0400
|
|
Subject: [PATCH] Nitori: Async playerdata Save
|
|
|
|
Original license: GPL v3
|
|
Original project: https://github.com/Gensokyo-Reimagined/Nitori
|
|
|
|
diff --git a/net/minecraft/world/level/storage/LevelStorageSource.java b/net/minecraft/world/level/storage/LevelStorageSource.java
|
|
index de43e54698125ce9f319d4889dd49f7029fe95e0..1fde2e33af9102017ab17cb766e9784ecec09822 100644
|
|
--- a/net/minecraft/world/level/storage/LevelStorageSource.java
|
|
+++ b/net/minecraft/world/level/storage/LevelStorageSource.java
|
|
@@ -514,7 +514,11 @@ public class LevelStorageSource {
|
|
CompoundTag compoundTag = serverConfiguration.createTag(registries, hostPlayerNBT);
|
|
CompoundTag compoundTag1 = new CompoundTag();
|
|
compoundTag1.put("Data", compoundTag);
|
|
- this.saveLevelData(compoundTag1);
|
|
+
|
|
+ // Leaf start - Nitori - Async playerdata save
|
|
+ Runnable runnable = () -> this.saveLevelData(compoundTag1);
|
|
+ org.dreeam.leaf.async.AsyncPlayerDataSaving.saveAsync(runnable);
|
|
+ // Leaf end - Nitori - Async playerdata save
|
|
}
|
|
|
|
private void saveLevelData(CompoundTag tag) {
|
|
@@ -601,7 +605,11 @@ public class LevelStorageSource {
|
|
this.checkLock();
|
|
CompoundTag levelDataTagRaw = LevelStorageSource.readLevelDataTagRaw(this.levelDirectory.dataFile());
|
|
modifier.accept(levelDataTagRaw.getCompound("Data"));
|
|
- this.saveLevelData(levelDataTagRaw);
|
|
+
|
|
+ // Leaf start - Nitori - Async playerdata save
|
|
+ Runnable runnable = () -> this.saveLevelData(levelDataTagRaw);
|
|
+ org.dreeam.leaf.async.AsyncPlayerDataSaving.saveAsync(runnable);
|
|
+ // Leaf end - Nitori - Async playerdata save
|
|
}
|
|
|
|
public long makeWorldBackup() throws IOException {
|
|
diff --git a/net/minecraft/world/level/storage/PlayerDataStorage.java b/net/minecraft/world/level/storage/PlayerDataStorage.java
|
|
index c44110b123ba5912af18faf0065e9ded780da9b7..e15221e70a1dd2bec1eb2aea3e70db28eb512e74 100644
|
|
--- a/net/minecraft/world/level/storage/PlayerDataStorage.java
|
|
+++ b/net/minecraft/world/level/storage/PlayerDataStorage.java
|
|
@@ -33,6 +33,13 @@ public class PlayerDataStorage {
|
|
}
|
|
|
|
public void save(Player player) {
|
|
+ // Leaf start - Nitori - Async playerdata save
|
|
+ Runnable runnable = () -> saveInternal(player);
|
|
+ org.dreeam.leaf.async.AsyncPlayerDataSaving.saveAsync(runnable);
|
|
+ }
|
|
+
|
|
+ private void saveInternal(Player player) {
|
|
+ // Leaf end - Nitori - Async playerdata save
|
|
if (org.spigotmc.SpigotConfig.disablePlayerDataSaving) return; // Spigot
|
|
try {
|
|
CompoundTag compoundTag = player.saveWithoutId(new CompoundTag());
|