PaperMC/nms-patches/NameReferencingFileConverter.patch

91 lines
4.6 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/NameReferencingFileConverter.java
+++ b/net/minecraft/server/NameReferencingFileConverter.java
2018-12-25 22:00:00 +01:00
@@ -81,8 +81,9 @@
if (gameprofilebanlist.c().exists()) {
try {
gameprofilebanlist.load();
- } catch (FileNotFoundException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
- NameReferencingFileConverter.e.warn("Could not load existing file {}", gameprofilebanlist.c().getName(), filenotfoundexception);
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
+ NameReferencingFileConverter.e.warn("Could not load existing file {}", gameprofilebanlist.c().getName());
}
}
2018-12-25 22:00:00 +01:00
@@ -139,8 +140,9 @@
if (ipbanlist.c().exists()) {
try {
ipbanlist.load();
- } catch (FileNotFoundException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
- NameReferencingFileConverter.e.warn("Could not load existing file {}", ipbanlist.c().getName(), filenotfoundexception);
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
+ NameReferencingFileConverter.e.warn("Could not load existing file {}", ipbanlist.c().getName());
}
}
2018-12-25 22:00:00 +01:00
@@ -180,8 +182,9 @@
if (oplist.c().exists()) {
try {
oplist.load();
- } catch (FileNotFoundException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
- NameReferencingFileConverter.e.warn("Could not load existing file {}", oplist.c().getName(), filenotfoundexception);
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
+ NameReferencingFileConverter.e.warn("Could not load existing file {}", oplist.c().getName());
}
}
2018-12-25 22:00:00 +01:00
@@ -224,8 +227,9 @@
if (whitelist.c().exists()) {
try {
whitelist.load();
- } catch (FileNotFoundException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
- NameReferencingFileConverter.e.warn("Could not load existing file {}", whitelist.c().getName(), filenotfoundexception);
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2017-05-14 04:00:00 +02:00
+ NameReferencingFileConverter.e.warn("Could not load existing file {}", whitelist.c().getName());
}
}
2018-12-25 22:00:00 +01:00
@@ -343,6 +347,30 @@
File file5 = new File(file, s2 + ".dat");
File file6 = new File(file4, s3 + ".dat");
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start - Use old file name to seed lastKnownName
+ NBTTagCompound root = null;
+
+ try {
2018-12-25 22:00:00 +01:00
+ root = NBTCompressedStreamTools.a(new java.io.FileInputStream(file5));
2015-02-26 23:41:06 +01:00
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
+ if (root != null) {
+ if (!root.hasKey("bukkit")) {
+ root.set("bukkit", new NBTTagCompound());
+ }
+ NBTTagCompound data = root.getCompound("bukkit");
2018-12-25 22:00:00 +01:00
+ data.setString("lastKnownName", s2);
2015-02-26 23:41:06 +01:00
+
+ try {
+ NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2));
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+ // CraftBukkit end
+
2018-12-25 22:00:00 +01:00
NameReferencingFileConverter.b(file4);
if (!file5.renameTo(file6)) {
throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2);
@@ -464,7 +492,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");
}