PaperMC/paper-server/nms-patches/net/minecraft/server/players/NameReferencingFileConverter.patch
CraftBukkit/Spigot e8c9836ec9 Update to Minecraft 1.17.1
By: md_5 <git@md-5.net>
2021-07-07 00:00:00 +10:00

81 lines
3.8 KiB
Diff

--- a/net/minecraft/server/players/NameReferencingFileConverter.java
+++ b/net/minecraft/server/players/NameReferencingFileConverter.java
@@ -28,6 +28,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import net.minecraft.nbt.NBTCompressedStreamTools;
+import net.minecraft.nbt.NBTTagCompound;
+// CraftBukkit end
+
public class NameReferencingFileConverter {
static final Logger LOGGER = LogManager.getLogger();
@@ -88,7 +93,7 @@
try {
gameprofilebanlist.load();
} catch (IOException ioexception) {
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName(), ioexception);
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -146,7 +151,7 @@
try {
ipbanlist.load();
} catch (IOException ioexception) {
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName(), ioexception);
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -187,7 +192,7 @@
try {
oplist.load();
} catch (IOException ioexception) {
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName(), ioexception);
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -231,7 +236,7 @@
try {
whitelist.load();
} catch (IOException ioexception) {
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName(), ioexception);
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -354,6 +359,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.a(new java.io.FileInputStream(file5));
+ } 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", s2);
+
+ try {
+ NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2));
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+ // CraftBukkit end
+
NameReferencingFileConverter.a(file4);
if (!file5.renameTo(file6)) {
throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2);