PaperMC/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch
2024-12-13 18:06:27 +01:00

96 lines
5.1 KiB
Diff

--- a/net/minecraft/server/players/OldUsersConverter.java
+++ b/net/minecraft/server/players/OldUsersConverter.java
@@ -20,6 +_,9 @@
import java.util.UUID;
import javax.annotation.Nullable;
import net.minecraft.core.UUIDUtil;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtAccounter;
+import net.minecraft.nbt.NbtIo;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.util.StringUtil;
@@ -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
+ CompoundTag root = null;
+
+ try {
+ root = NbtIo.readCompressed(new java.io.FileInputStream(file4), 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 CompoundTag());
+ }
+ CompoundTag data = root.getCompound("bukkit");
+ data.putString("lastKnownName", oldFileName);
+
+ try {
+ 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);