geforkt von Mirrors/Paper
0708fa363b
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes:eb2e6578
SPIGOT-5116: Fix concurrent modification exception inside ChunkMapDistance989f9b3d
SPIGOT-4849: Fix server crash when accessing chunks during chunk load/unload/populate eventsf554183c
SPIGOT-5171: Don't fire PlayerTeleportEvent if not actually moving2349feb8
SPIGOT-5163: Cancelling PlayerBucketFillEvent visually removes the targeted block Spigot Changes: 9a643a6a Remove DataWatcher Locking
66 Zeilen
2.6 KiB
Diff
66 Zeilen
2.6 KiB
Diff
From bb6ae177b15538c541022acce1296b1f20a6c35e Mon Sep 17 00:00:00 2001
|
|
From: Zach Brown <zach@zachbr.io>
|
|
Date: Tue, 11 Dec 2018 22:25:07 -0500
|
|
Subject: [PATCH] Lazy init world storage in CraftOfflinePlayer
|
|
|
|
Allows access to some offline player properties even when there are no
|
|
worlds loaded. This is typically a rare occurrence but probably one that
|
|
should be covered as best we can.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
|
index 6a448c02e..c1ef1c950 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
|
@@ -25,12 +25,12 @@ import org.bukkit.plugin.Plugin;
|
|
public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializable {
|
|
private final GameProfile profile;
|
|
private final CraftServer server;
|
|
- private final WorldNBTStorage storage;
|
|
+ private WorldNBTStorage storage; // Paper - lazy init
|
|
|
|
protected CraftOfflinePlayer(CraftServer server, GameProfile profile) {
|
|
this.server = server;
|
|
this.profile = profile;
|
|
- this.storage = (WorldNBTStorage) (server.console.getWorldServer(DimensionManager.OVERWORLD).getDataManager());
|
|
+ //this.storage = (WorldNBTStorage) (server.console.getWorldServer(DimensionManager.OVERWORLD).getDataManager()); // Paper - lazy init
|
|
|
|
}
|
|
|
|
@@ -177,8 +177,23 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|
return hash;
|
|
}
|
|
|
|
+ // Paper - lazy
|
|
+ private WorldNBTStorage getStorageLazy() {
|
|
+ if (this.storage == null) {
|
|
+ net.minecraft.server.WorldServer worldServer = server.console.getWorldServer(DimensionManager.OVERWORLD);
|
|
+ if (worldServer == null) {
|
|
+ throw new IllegalStateException("Cannot get world storage when there are no worlds loaded!");
|
|
+ } else {
|
|
+ this.storage = (WorldNBTStorage) worldServer.getDataManager();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return this.storage;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
private NBTTagCompound getData() {
|
|
- return storage.getPlayerData(getUniqueId().toString());
|
|
+ return getStorageLazy().getPlayerData(getUniqueId().toString());
|
|
}
|
|
|
|
private NBTTagCompound getBukkitData() {
|
|
@@ -195,7 +210,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|
}
|
|
|
|
private File getDataFile() {
|
|
- return new File(storage.getPlayerDir(), getUniqueId() + ".dat");
|
|
+ return new File(getStorageLazy().getPlayerDir(), getUniqueId() + ".dat");
|
|
}
|
|
|
|
@Override
|
|
--
|
|
2.22.0
|
|
|