13
0
geforkt von Mirrors/Paper
Paper/nms-patches/WorldNBTStorage.patch
2020-08-12 07:00:00 +10:00

67 Zeilen
2.1 KiB
Diff

--- a/net/minecraft/server/WorldNBTStorage.java
+++ b/net/minecraft/server/WorldNBTStorage.java
@@ -6,6 +6,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.io.FileInputStream;
+import java.io.InputStream;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+// CraftBukkit end
+
public class WorldNBTStorage {
private static final Logger LOGGER = LogManager.getLogger();
@@ -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
int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1;
entityhuman.load(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i));
@@ -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) {
+ LOGGER.warn("Failed to load player data for " + s);
+ }
+
+ return null;
+ }
+ // CraftBukkit end
+
public String[] getSeenPlayers() {
String[] astring = this.playerDir.list();
@@ -72,4 +104,10 @@
return astring;
}
+
+ // CraftBukkit start
+ public File getPlayerDir() {
+ return playerDir;
+ }
+ // CraftBukkit end
}