Paper/nms-patches/WorldNBTStorage.patch

67 lines
2.1 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/WorldNBTStorage.java
+++ b/net/minecraft/server/WorldNBTStorage.java
2020-08-11 23:00:00 +02:00
@@ -6,6 +6,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
2020-08-11 23:00:00 +02:00
+import java.io.FileInputStream;
+import java.io.InputStream;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+// CraftBukkit end
+
2020-06-25 02:00:00 +02:00
public class WorldNBTStorage {
2019-04-25 04:00:00 +02:00
private static final Logger LOGGER = LogManager.getLogger();
2020-08-11 23:00:00 +02:00
@@ -49,6 +55,16 @@
}
if (nbttagcompound != null) {
+ // CraftBukkit start
+ if (entityhuman instanceof EntityPlayer) {
+ CraftPlayer player = (CraftPlayer) entityhuman.getBukkitEntity();
+ // Only update first played if it is older than the one we have
+ long modified = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat").lastModified();
+ if (modified < player.getFirstPlayed()) {
+ player.setFirstPlayed(modified);
+ }
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1;
2020-06-25 02:00:00 +02:00
entityhuman.load(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i));
2020-08-11 23:00:00 +02:00
@@ -57,6 +73,22 @@
return nbttagcompound;
}
+ // CraftBukkit start
+ public NBTTagCompound getPlayerData(String s) {
+ try {
+ File file1 = new File(this.playerDir, s + ".dat");
+
+ if (file1.exists()) {
+ return NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1)));
+ }
+ } catch (Exception exception) {
2019-04-25 04:00:00 +02:00
+ LOGGER.warn("Failed to load player data for " + s);
+ }
+
+ return null;
+ }
+ // CraftBukkit end
+
2019-04-23 04:00:00 +02:00
public String[] getSeenPlayers() {
String[] astring = this.playerDir.list();
2020-08-11 23:00:00 +02:00
@@ -72,4 +104,10 @@
2020-06-25 02:00:00 +02:00
return astring;
}
+
+ // CraftBukkit start
+ public File getPlayerDir() {
+ return playerDir;
+ }
+ // CraftBukkit end
}