mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 20:21:51 +01:00
2f34301581
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 Bukkit Changes: 7361a62e SPIGOT-5641: Add Block.getDrops(ItemStack, Entity) 1dc91b15 Add specific notes about what is not API 2b05ef88 #484: Allow statistics to be accessed for offline players CraftBukkit Changes:f7d6ad53
SPIGOT-5603: Use LootContext#lootingModifier in CraftLootTable5838285d
SPIGOT-5657: BlockPlaceEvent not cancelling for tripwire hooksf325b9be
SPIGOT-5641: Add Block.getDrops(ItemStack, Entity)e25a2272
Fix some formatting in CraftHumanEntity498540e0
Add Merchant slot delegateb2de47d5
SPIGOT-5621: Add missing container types for opening InventoryViewaa3a2f27
#645: Allow statistics to be accessed for offline players2122c0b1
#649: CraftBell should implement Bell
65 lines
2.6 KiB
Diff
65 lines
2.6 KiB
Diff
From 484723eb66e15561e7b4ff672d91d24758e48aea 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 58e10381c8..0e8a21b803 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
|
|
@@ -29,12 +29,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
|
|
|
|
}
|
|
|
|
@@ -181,8 +181,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() {
|
|
@@ -199,7 +214,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.25.1
|
|
|