aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/server/players/NameReferencingFileConverter.patch
blob: 57e1d5a7c486c93d12afc6cfe1be0bfbd1d35a9e (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- a/net/minecraft/server/players/NameReferencingFileConverter.java
+++ b/net/minecraft/server/players/NameReferencingFileConverter.java
@@ -27,6 +27,12 @@
 import net.minecraft.world.level.storage.SavedFile;
 import org.slf4j.Logger;
 
+// CraftBukkit start
+import net.minecraft.nbt.NBTCompressedStreamTools;
+import net.minecraft.nbt.NBTReadLimiter;
+import net.minecraft.nbt.NBTTagCompound;
+// CraftBukkit end
+
 public class NameReferencingFileConverter {
 
     static final Logger LOGGER = LogUtils.getLogger();
@@ -85,7 +91,7 @@
                 try {
                     gameprofilebanlist.load();
                 } catch (IOException ioexception) {
-                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.getFile().getName(), ioexception);
+                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.getFile().getName()); // CraftBukkit - don't print stacktrace
                 }
             }
 
@@ -143,7 +149,7 @@
                 try {
                     ipbanlist.load();
                 } catch (IOException ioexception) {
-                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName(), ioexception);
+                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName()); // CraftBukkit - don't print stacktrace
                 }
             }
 
@@ -184,7 +190,7 @@
                 try {
                     oplist.load();
                 } catch (IOException ioexception) {
-                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.getFile().getName(), ioexception);
+                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.getFile().getName()); // CraftBukkit - don't print stacktrace
                 }
             }
 
@@ -228,7 +234,7 @@
                 try {
                     whitelist.load();
                 } catch (IOException ioexception) {
-                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName(), ioexception);
+                    NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName()); // CraftBukkit - don't print stacktrace
                 }
             }
 
@@ -347,6 +353,30 @@
                         File file5 = new File(file, s2 + ".dat");
                         File file6 = new File(file4, s3 + ".dat");
 
+                        // CraftBukkit start - Use old file name to seed lastKnownName
+                        NBTTagCompound root = null;
+
+                        try {
+                            root = NBTCompressedStreamTools.readCompressed(new java.io.FileInputStream(file5), NBTReadLimiter.unlimitedHeap());
+                        } catch (Exception exception) {
+                            exception.printStackTrace();
+                        }
+
+                        if (root != null) {
+                            if (!root.contains("bukkit")) {
+                                root.put("bukkit", new NBTTagCompound());
+                            }
+                            NBTTagCompound data = root.getCompound("bukkit");
+                            data.putString("lastKnownName", s2);
+
+                            try {
+                                NBTCompressedStreamTools.writeCompressed(root, new java.io.FileOutputStream(file2));
+                            } catch (Exception exception) {
+                                exception.printStackTrace();
+                            }
+                       }
+                        // CraftBukkit end
+
                         NameReferencingFileConverter.ensureDirectoryExists(file4);
                         if (!file5.renameTo(file6)) {
                             throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2);