summaryrefslogtreecommitdiffstats
path: root/nms-patches/WorldNBTStorage.patch
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-11-26 08:32:16 +1100
committermd_5 <git@md-5.net>2014-11-28 17:16:30 +1100
commit24557bc2b37deb6a0edf497d547471832457b1dd (patch)
treec560572889a3b0b34964a0cddb35dc87fda3c914 /nms-patches/WorldNBTStorage.patch
parenta4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff)
downloadcraftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'nms-patches/WorldNBTStorage.patch')
-rw-r--r--nms-patches/WorldNBTStorage.patch123
1 files changed, 123 insertions, 0 deletions
diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch
new file mode 100644
index 00000000..503af702
--- /dev/null
+++ b/nms-patches/WorldNBTStorage.patch
@@ -0,0 +1,123 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/WorldNBTStorage.java 2014-11-27 08:59:46.941420790 +1100
++++ src/main/java/net/minecraft/server/WorldNBTStorage.java 2014-11-27 08:42:10.156850903 +1100
+@@ -11,6 +11,12 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+
++// CraftBukkit start
++import java.util.UUID;
++
++import org.bukkit.craftbukkit.entity.CraftPlayer;
++// CraftBukkit end
++
+ public class WorldNBTStorage implements IDataManager, IPlayerFileData {
+
+ private static final Logger a = LogManager.getLogger();
+@@ -19,6 +25,7 @@
+ private final File dataDir;
+ private final long sessionId = MinecraftServer.ax();
+ private final String f;
++ private UUID uuid = null; // CraftBukkit
+
+ public WorldNBTStorage(File file, String s, boolean flag) {
+ this.baseDir = new File(file, s);
+@@ -55,7 +62,7 @@
+ return this.baseDir;
+ }
+
+- public void checkSession() {
++ public void checkSession() throws ExceptionWorldConflict { // CraftBukkit - throws ExceptionWorldConflict
+ try {
+ File file = new File(this.baseDir, "session.lock");
+ DataInputStream datainputstream = new DataInputStream(new FileInputStream(file));
+@@ -202,12 +209,39 @@
+ }
+
+ 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
++
+ entityhuman.f(nbttagcompound);
+ }
+
+ 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) {
++ a.warn("Failed to load player data for " + s);
++ }
++
++ return null;
++ }
++ // CraftBukkit end
++
+ public IPlayerFileData getPlayerFileData() {
+ return this;
+ }
+@@ -237,4 +271,50 @@
+ public String g() {
+ return this.f;
+ }
++
++ // CraftBukkit start
++ public UUID getUUID() {
++ if (uuid != null) return uuid;
++ File file1 = new File(this.baseDir, "uid.dat");
++ if (file1.exists()) {
++ DataInputStream dis = null;
++ try {
++ dis = new DataInputStream(new FileInputStream(file1));
++ return uuid = new UUID(dis.readLong(), dis.readLong());
++ } catch (IOException ex) {
++ a.warn("Failed to read " + file1 + ", generating new random UUID", ex);
++ } finally {
++ if (dis != null) {
++ try {
++ dis.close();
++ } catch (IOException ex) {
++ // NOOP
++ }
++ }
++ }
++ }
++ uuid = UUID.randomUUID();
++ DataOutputStream dos = null;
++ try {
++ dos = new DataOutputStream(new FileOutputStream(file1));
++ dos.writeLong(uuid.getMostSignificantBits());
++ dos.writeLong(uuid.getLeastSignificantBits());
++ } catch (IOException ex) {
++ a.warn("Failed to write " + file1, ex);
++ } finally {
++ if (dos != null) {
++ try {
++ dos.close();
++ } catch (IOException ex) {
++ // NOOP
++ }
++ }
++ }
++ return uuid;
++ }
++
++ public File getPlayerDir() {
++ return playerDir;
++ }
++ // CraftBukkit end
+ }