3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/NameReferencingFileConverter.patch

91 Zeilen
4.6 KiB
Diff

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) {
2019-04-25 04:00:00 +02:00
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.c().getName(), filenotfoundexception);
2017-05-14 04:00:00 +02:00
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2019-04-25 04:00:00 +02:00
+ NameReferencingFileConverter.LOGGER.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) {
2019-04-25 04:00:00 +02:00
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.c().getName(), filenotfoundexception);
2017-05-14 04:00:00 +02:00
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2019-04-25 04:00:00 +02:00
+ NameReferencingFileConverter.LOGGER.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) {
2019-04-25 04:00:00 +02:00
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.c().getName(), filenotfoundexception);
2017-05-14 04:00:00 +02:00
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2019-04-25 04:00:00 +02:00
+ NameReferencingFileConverter.LOGGER.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) {
2019-04-25 04:00:00 +02:00
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.c().getName(), filenotfoundexception);
2017-05-14 04:00:00 +02:00
+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace
+ } catch (IOException filenotfoundexception) {
2019-04-25 04:00:00 +02:00
+ NameReferencingFileConverter.LOGGER.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 @@
2019-04-23 04:00:00 +02:00
private static File getPlayersFolder(MinecraftServer minecraftserver) {
String s = minecraftserver.getWorld();
- File file = new File(s);
+ File file = new File(MinecraftServer.getServer().server.getWorldContainer(), s); // CraftBukkit - Respect container setting
return new File(file, "players");
}