summaryrefslogtreecommitdiffstats
path: root/nms-patches/NameReferencingFileConverter.patch
blob: 9877efe90d2f01dfca53bc1489da88ed8e7f3f20 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
--- a/net/minecraft/server/NameReferencingFileConverter.java
+++ b/net/minecraft/server/NameReferencingFileConverter.java
@@ -83,8 +83,9 @@
             if (gameprofilebanlist.c().exists()) {
                 try {
                     gameprofilebanlist.load();
-                } catch (FileNotFoundException filenotfoundexception) {
-                    NameReferencingFileConverter.e.warn("Could not load existing file {}", gameprofilebanlist.c().getName(), filenotfoundexception);
+                // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+                } catch (IOException filenotfoundexception) {
+                    NameReferencingFileConverter.e.warn("Could not load existing file {}", gameprofilebanlist.c().getName());
                 }
             }
 
@@ -113,7 +114,7 @@
                     public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) {
                         NameReferencingFileConverter.e.warn("Could not lookup user banlist entry for {}", gameprofile.getName(), exception);
                         if (!(exception instanceof ProfileNotFoundException)) {
-                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception, null);
+                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception); // CraftBukkit - decompile error
                         }
                     }
                 };
@@ -141,8 +142,9 @@
             if (ipbanlist.c().exists()) {
                 try {
                     ipbanlist.load();
-                } catch (FileNotFoundException filenotfoundexception) {
-                    NameReferencingFileConverter.e.warn("Could not load existing file {}", ipbanlist.c().getName(), filenotfoundexception);
+                // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+                } catch (IOException filenotfoundexception) {
+                    NameReferencingFileConverter.e.warn("Could not load existing file {}", ipbanlist.c().getName());
                 }
             }
 
@@ -182,8 +184,9 @@
             if (oplist.c().exists()) {
                 try {
                     oplist.load();
-                } catch (FileNotFoundException filenotfoundexception) {
-                    NameReferencingFileConverter.e.warn("Could not load existing file {}", oplist.c().getName(), filenotfoundexception);
+                // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+                } catch (IOException filenotfoundexception) {
+                    NameReferencingFileConverter.e.warn("Could not load existing file {}", oplist.c().getName());
                 }
             }
 
@@ -198,7 +201,7 @@
                     public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) {
                         NameReferencingFileConverter.e.warn("Could not lookup oplist entry for {}", gameprofile.getName(), exception);
                         if (!(exception instanceof ProfileNotFoundException)) {
-                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception, null);
+                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception); // CraftBukkit - decompile error
                         }
                     }
                 };
@@ -226,8 +229,9 @@
             if (whitelist.c().exists()) {
                 try {
                     whitelist.load();
-                } catch (FileNotFoundException filenotfoundexception) {
-                    NameReferencingFileConverter.e.warn("Could not load existing file {}", whitelist.c().getName(), filenotfoundexception);
+                // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+                } catch (IOException filenotfoundexception) {
+                    NameReferencingFileConverter.e.warn("Could not load existing file {}", whitelist.c().getName());
                 }
             }
 
@@ -242,7 +246,7 @@
                     public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) {
                         NameReferencingFileConverter.e.warn("Could not lookup user whitelist entry for {}", gameprofile.getName(), exception);
                         if (!(exception instanceof ProfileNotFoundException)) {
-                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception, null);
+                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception); // CraftBukkit - decompile error
                         }
                     }
                 };
@@ -337,7 +341,7 @@
 
                             this.a(file, s, s);
                         } else {
-                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception, null);
+                            throw new NameReferencingFileConverter.FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception); // CraftBukkit - decompile error
                         }
                     }
 
@@ -345,6 +349,30 @@
                         File file1 = new File(file2, s + ".dat");
                         File file3 = 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.b(file);
                         if (!file1.renameTo(file3)) {
                             throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s, null);
@@ -353,7 +381,7 @@
 
                     private String a(GameProfile gameprofile) {
                         String s = null;
-                        String[] astring = astring1;
+                        // String[] astring = astring1; // CraftBukkit - decompile error
                         int i = astring.length;
 
                         for (int j = 0; j < i; ++j) {
@@ -466,7 +494,7 @@
 
     private static File d(PropertyManager propertymanager) {
         String s = propertymanager.getString("level-name", "world");
-        File file = new File(s);
+        File file = new File(MinecraftServer.getServer().server.getWorldContainer(), s); // CraftBukkit - Respect container setting
 
         return new File(file, "players");
     }