From 0b0aa1201b2e84af1cd32f1384e200f527771f74 Mon Sep 17 00:00:00 2001 From: Noah van der Aa <ndvdaa@gmail.com> Date: Sat, 23 Sep 2023 21:37:26 +0200 Subject: [PATCH] Migrate paper log ips option to new server.properties option --- ...sing-logs-for-log-ips-config-option.patch} | 15 +---- patches/server/Paper-config-files.patch | 63 ++++++++++++++++++- 2 files changed, 61 insertions(+), 17 deletions(-) rename patches/server/{Support-Paper-ip-address-config-add-missing-logs.patch => Add-missing-logs-for-log-ips-config-option.patch} (75%) diff --git a/patches/server/Support-Paper-ip-address-config-add-missing-logs.patch b/patches/server/Add-missing-logs-for-log-ips-config-option.patch similarity index 75% rename from patches/server/Support-Paper-ip-address-config-add-missing-logs.patch rename to patches/server/Add-missing-logs-for-log-ips-config-option.patch index 8c8fe9823f..3fb50664e9 100644 --- a/patches/server/Support-Paper-ip-address-config-add-missing-logs.patch +++ b/patches/server/Add-missing-logs-for-log-ips-config-option.patch @@ -1,22 +1,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Sat, 23 Sep 2023 01:49:39 -0400 -Subject: [PATCH] Support Paper ip address config + add missing logs +Subject: [PATCH] Add missing logs for log-ips config option -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - - @Override - public boolean logIPs() { -- return this.getProperties().logIPs; -+ return this.getProperties().logIPs && io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses; // Paper - } - - protected boolean convertOldUsers() { diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 0cf12301ee..ebb87db9a2 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -11,6 +11,7 @@ public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;)I public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;I)I public org.spigotmc.SpigotWorldConfig getList(Ljava/lang/String;Ljava/lang/Object;)Ljava/util/List; public org.spigotmc.SpigotWorldConfig getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; +public net.minecraft.server.dedicated.DedicatedServerProperties reload(Lnet/minecraft/core/RegistryAccess;Ljava/util/Properties;Ljoptsimple/OptionSet;)Lnet/minecraft/server/dedicated/DedicatedServerProperties; public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES diff --git a/build.gradle.kts b/build.gradle.kts @@ -466,7 +467,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) +public class GlobalConfiguration extends ConfigurationPart { -+ static final int CURRENT_VERSION = 28; ++ static final int CURRENT_VERSION = 29; + private static GlobalConfiguration instance; + public static GlobalConfiguration get() { + return instance; @@ -611,7 +612,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public Logging logging; + + public class Logging extends ConfigurationPart { -+ public boolean logPlayerIpAddresses = true; + public boolean deobfuscateStacktraces = true; + } + @@ -974,6 +974,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer; +import io.papermc.paper.configuration.transformation.Transformations; +import io.papermc.paper.configuration.transformation.global.LegacyPaperConfig; ++import io.papermc.paper.configuration.transformation.global.versioned.V29_LogIPs; +import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration; +import io.papermc.paper.configuration.transformation.world.LegacyPaperWorldConfig; +import io.papermc.paper.configuration.transformation.world.versioned.V29_ZeroWorldHeight; @@ -1212,8 +1213,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (NodePath path : RemovedConfigurations.REMOVED_GLOBAL_PATHS) { + builder.addAction(path, TransformAction.remove()); + } -+ // ADD FUTURE TRANSFORMS TO builder HERE + builder.build().apply(node); ++ ++ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder(); ++ V29_LogIPs.apply(versionedBuilder); ++ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE ++ versionedBuilder.build().apply(node); + } + + private static final List<Transformations.DefaultsAware> DEFAULT_AWARE_TRANSFORMATIONS = List.of(FeatureSeedsGeneration::apply); @@ -3373,6 +3378,58 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + }); + } +} +diff --git a/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java b/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.configuration.transformation.global.versioned; ++ ++import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.dedicated.DedicatedServer; ++import org.checkerframework.checker.nullness.qual.Nullable; ++import org.spongepowered.configurate.ConfigurateException; ++import org.spongepowered.configurate.ConfigurationNode; ++import org.spongepowered.configurate.NodePath; ++import org.spongepowered.configurate.transformation.ConfigurationTransformation; ++import org.spongepowered.configurate.transformation.TransformAction; ++ ++import java.util.Properties; ++ ++import static org.spongepowered.configurate.NodePath.path; ++ ++public class V29_LogIPs implements TransformAction { ++ ++ private static final int VERSION = 29; ++ private static final NodePath PATH = path("logging", "log-player-ip-addresses"); ++ private static final V29_LogIPs INSTANCE = new V29_LogIPs(); ++ ++ private V29_LogIPs() { ++ } ++ ++ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { ++ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); ++ } ++ ++ @Nullable ++ @Override ++ public Object[] visitPath(final NodePath path, final ConfigurationNode value) throws ConfigurateException { ++ DedicatedServer server = ((DedicatedServer) MinecraftServer.getServer()); ++ ++ boolean val = value.getBoolean(server.settings.getProperties().logIPs); ++ server.settings.update((config) -> { ++ Properties newProps = new Properties(config.properties); ++ newProps.setProperty("log-ips", String.valueOf(val)); ++ return config.reload(server.registryAccess(), newProps, server.options); ++ }); ++ ++ value.raw(null); ++ ++ return null; ++ } ++ ++} diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java b/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000