--- 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);