PaperMC/patches/server/0128-Enforce-Sync-Player-Saves.patch
2022-02-28 22:52:39 -07:00

27 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 7 Jan 2017 15:41:58 -0500
Subject: [PATCH] Enforce Sync Player Saves
Saving players async is extremely dangerous. This will force it to main
the same way we handle async chunk loads.
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 5a7ca495a78f33e5449d47ce71dbf9b11678551f..288a046b8335a611e0c7a155a6d0565e6f7c272a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1036,11 +1036,13 @@ public abstract class PlayerList {
}
public void saveAll() {
+ net.minecraft.server.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
MinecraftTimings.savePlayers.startTiming(); // Paper
for (int i = 0; i < this.players.size(); ++i) {
- this.save((ServerPlayer) this.players.get(i));
+ this.save(this.players.get(i));
}
MinecraftTimings.savePlayers.stopTiming(); // Paper
+ return null; }); // Paper - ensure main
}
public UserWhiteList getWhiteList() {