papermc/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch
Nassim Jahnke f00727c57e
1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
2025-04-12 17:27:00 +02:00

86 lines
4.8 KiB
Diff

--- a/net/minecraft/server/players/OldUsersConverter.java
+++ b/net/minecraft/server/players/OldUsersConverter.java
@@ -49,7 +_,8 @@
private static void lookupPlayers(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback) {
String[] strings = names.stream().filter(name -> !StringUtil.isNullOrEmpty(name)).toArray(String[]::new);
- if (server.usesAuthentication()) {
+ if (server.usesAuthentication() ||
+ (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode())) { // Spigot: bungee = online mode, for now. // Paper - Add setting for proxy online mode status
server.getProfileRepository().findProfilesByNames(strings, callback);
} else {
for (String string : strings) {
@@ -65,7 +_,7 @@
try {
userBanList.load();
} catch (IOException var6) {
- LOGGER.warn("Could not load existing file {}", userBanList.getFile().getName(), var6);
+ LOGGER.warn("Could not load existing file {}", userBanList.getFile().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -120,7 +_,7 @@
try {
ipBanList.load();
} catch (IOException var11) {
- LOGGER.warn("Could not load existing file {}", ipBanList.getFile().getName(), var11);
+ LOGGER.warn("Could not load existing file {}", ipBanList.getFile().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -156,7 +_,7 @@
try {
serverOpList.load();
} catch (IOException var6) {
- LOGGER.warn("Could not load existing file {}", serverOpList.getFile().getName(), var6);
+ LOGGER.warn("Could not load existing file {}", serverOpList.getFile().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -200,7 +_,7 @@
try {
userWhiteList.load();
} catch (IOException var6) {
- LOGGER.warn("Could not load existing file {}", userWhiteList.getFile().getName(), var6);
+ LOGGER.warn("Could not load existing file {}", userWhiteList.getFile().getName()); // CraftBukkit - don't print stacktrace
}
}
@@ -313,6 +_,37 @@
private void movePlayerFile(File file3, String oldFileName, String newFileName) {
File file4 = new File(worldPlayersDirectory, oldFileName + ".dat");
File file5 = new File(file3, newFileName + ".dat");
+ // CraftBukkit start - Use old file name to seed lastKnownName
+ net.minecraft.nbt.CompoundTag root = null;
+
+ try {
+ root = net.minecraft.nbt.NbtIo.readCompressed(new java.io.FileInputStream(file4), net.minecraft.nbt.NbtAccounter.unlimitedHeap());
+ } catch (Exception exception) {
+ // Paper start
+ io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(exception);
+ exception.printStackTrace();
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception);
+ // Paper end
+ }
+
+ if (root != null) {
+ if (!root.contains("bukkit")) {
+ root.put("bukkit", new net.minecraft.nbt.CompoundTag());
+ }
+ net.minecraft.nbt.CompoundTag data = root.getCompoundOrEmpty("bukkit");
+ data.putString("lastKnownName", oldFileName);
+
+ try {
+ net.minecraft.nbt.NbtIo.writeCompressed(root, new java.io.FileOutputStream(file1));
+ } catch (Exception exception) {
+ // Paper start
+ io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(exception);
+ exception.printStackTrace();
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception);
+ // Paper end
+ }
+ }
+ // CraftBukkit end
OldUsersConverter.ensureDirectoryExists(file3);
if (!file4.renameTo(file5)) {
throw new OldUsersConverter.ConversionError("Could not convert file for " + oldFileName);