summaryrefslogtreecommitdiffstats
path: root/nms-patches/PlayerDatFileConverter.patch
blob: 5c9fc1af47ad8fddf56473ee6eef192ff0619166 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerDatFileConverter.java	2014-11-28 17:43:43.329707430 +0000
+++ src/main/java/net/minecraft/server/PlayerDatFileConverter.java	2014-11-28 17:38:20.000000000 +0000
@@ -47,6 +47,30 @@
     private void a(File file, String s, String s1) {
         File file1 = new File(this.d, s + ".dat");
         File file2 = new File(file, s1 + ".dat");
+ 
+        // CraftBukkit start - Use old file name to seed lastKnownName
+        NBTTagCompound root = null;
+
+        try {
+            root = NBTCompressedStreamTools.a(new java.io.FileInputStream(file1));
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+
+        if (root != null) {
+            if (!root.hasKey("bukkit")) {
+                root.set("bukkit", new NBTTagCompound());
+            }
+            NBTTagCompound data = root.getCompound("bukkit");
+            data.setString("lastKnownName", s);
+
+            try {
+                NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2));
+            } catch (Exception exception) {
+                exception.printStackTrace();
+            }
+       }
+        // CraftBukkit end
 
         NameReferencingFileConverter.a(file);
         if (!file1.renameTo(file2)) {