From 3d37b42a89db7af2dd367861fa66c28b9e4aae97 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 13 Jun 2022 15:29:44 -0700 Subject: [PATCH] Couple config fixes (#7975) --- patches/server/0004-Paper-config-files.patch | 12 +++++++----- patches/server/0746-Add-packet-limiter-config.patch | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/patches/server/0004-Paper-config-files.patch b/patches/server/0004-Paper-config-files.patch index 7f446dfd5..ba46f83f9 100644 --- a/patches/server/0004-Paper-config-files.patch +++ b/patches/server/0004-Paper-config-files.patch @@ -416,7 +416,7 @@ index 0000000000000000000000000000000000000000..13d7d1c24ec9192d0163f6eedeac8fca +} diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..5a808a09291da691cbee75a55f6aa1b70ac9f018 +index 0000000000000000000000000000000000000000..3e7086d31b2f101b2d6e982f3935922886cadc77 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -0,0 +1,264 @@ @@ -631,7 +631,7 @@ index 0000000000000000000000000000000000000000..5a808a09291da691cbee75a55f6aa1b7 + public Map>, PacketLimit> overrides = Map.of(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); + + @ConfigSerializable -+ public record PacketLimit(@Constraint(Constraints.Positive.class) @Required double interval, @Constraint(Constraints.Positive.class) @Required double maxPacketRate, ViolateAction action) { ++ public record PacketLimit(@Required double interval, @Required double maxPacketRate, ViolateAction action) { + public PacketLimit(final double interval, final double maxPacketRate, final @Nullable ViolateAction action) { + this.interval = interval; + this.maxPacketRate = maxPacketRate; @@ -1308,10 +1308,10 @@ index 0000000000000000000000000000000000000000..518a00886f7bde1de95150366541fc99 +} diff --git a/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java b/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..d69d203eea014fc9fb40a556f0771dba15fcd2ea +index 0000000000000000000000000000000000000000..1bb16fc7598cd53e822d84b69d6a9727b37f484f --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/RemovedConfigurations.java -@@ -0,0 +1,61 @@ +@@ -0,0 +1,63 @@ +package io.papermc.paper.configuration; + +import org.spongepowered.configurate.NodePath; @@ -1354,6 +1354,8 @@ index 0000000000000000000000000000000000000000..d69d203eea014fc9fb40a556f0771dba + path("use-hopper-check"), + path("use-async-lighting"), + path("tnt-explosion-volume"), ++ path("entities", "spawning", "despawn-ranges", "soft"), ++ path("entities", "spawning", "despawn-ranges", "hard") + }; + + NodePath[] REMOVED_GLOBAL_PATHS = { @@ -4236,7 +4238,7 @@ index a96cb7a5f7c94cd9a46b31cf8ec90b544221557b..7c35d86eac0d69ba4be48faf364fd6dc for ( Method method : clazz.getDeclaredMethods() ) { diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java -index a04da0a7d690fe3fcf10810b4e8c92a8ae027b86..feef74e3a6d50344245c4a61ece5b2194af1072f 100644 +index bd0bf398f900302187f3436119c754592d575416..d139cbcf0b159372f229bef6ae49b45a74c163ad 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -58,8 +58,14 @@ public class SpigotWorldConfig diff --git a/patches/server/0746-Add-packet-limiter-config.patch b/patches/server/0746-Add-packet-limiter-config.patch index 882a6b664..374c9fb3d 100644 --- a/patches/server/0746-Add-packet-limiter-config.patch +++ b/patches/server/0746-Add-packet-limiter-config.patch @@ -24,7 +24,7 @@ and an action can be defined: DROP or KICK If interval or rate are less-than 0, the limit is ignored diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 05a15b2da76a6d246b705e682b61a7c40c5dade7..8c6e2aa1a5e98456684f74d677ac0af24aa90246 100644 +index 05a15b2da76a6d246b705e682b61a7c40c5dade7..1d98e328982255b6dab8e24223c97eaea2612a45 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -135,6 +135,22 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -73,7 +73,7 @@ index 05a15b2da76a6d246b705e682b61a7c40c5dade7..8c6e2aa1a5e98456684f74d677ac0af2 + for (Class check = packet.getClass(); check != Object.class; check = check.getSuperclass()) { + io.papermc.paper.configuration.GlobalConfiguration.PacketLimiter.PacketLimit packetSpecificLimit = + io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.get(check); -+ if (packetSpecificLimit == null) { ++ if (packetSpecificLimit == null || !packetSpecificLimit.isEnabled()) { + continue; + } + io.papermc.paper.util.IntervalledCounter counter = this.packetSpecificLimits.computeIfAbsent((Class)check, (clazz) -> {