3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/nms-patches/WorldNBTStorage.patch

65 Zeilen
2.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/WorldNBTStorage.java
+++ b/net/minecraft/server/WorldNBTStorage.java
2020-06-25 02:00:00 +02:00
@@ -10,6 +10,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+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-06-25 02:00:00 +02:00
@@ -53,6 +57,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));
@@ -61,6 +75,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-06-25 02:00:00 +02:00
@@ -76,4 +106,10 @@
return astring;
}
+
+ // CraftBukkit start
+ public File getPlayerDir() {
+ return playerDir;
+ }
+ // CraftBukkit end
}