From e516ecfd45056f9379a6a6714265cb1ed320e957 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 8 Jun 2023 09:09:43 -0700 Subject: [PATCH] apply a couple network patches --- patches/server/Add-API-for-quit-reason.patch | 18 ------------------ patches/server/Add-packet-limiter-config.patch | 9 ++++----- ...ntrolled-flushing-for-network-manager.patch | 0 patches/server/Buffer-joins-to-world.patch | 2 +- ...k-Manager-and-add-advanced-packet-sup.patch | 0 5 files changed, 5 insertions(+), 24 deletions(-) rename patches/{unapplied => }/server/Allow-controlled-flushing-for-network-manager.patch (100%) rename patches/{unapplied => }/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch (100%) diff --git a/patches/server/Add-API-for-quit-reason.patch b/patches/server/Add-API-for-quit-reason.patch index 93d9767c7e..e24fc825bb 100644 --- a/patches/server/Add-API-for-quit-reason.patch +++ b/patches/server/Add-API-for-quit-reason.patch @@ -8,24 +8,6 @@ diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { - this.receiving = side; - } - -+ // Paper start -+ @Nullable -+ public net.minecraft.server.level.ServerPlayer getPlayer() { -+ if (this.packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl serverGamePacketListener) { -+ return serverGamePacketListener.player; -+ } else { -+ return null; -+ } -+ } -+ // Paper end -+ - public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { - super.channelActive(channelhandlercontext); - this.channel = channelhandlercontext.channel(); @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { this.handlingFault = true; diff --git a/patches/server/Add-packet-limiter-config.patch b/patches/server/Add-packet-limiter-config.patch index a1ab2e48dc..1a9bbeede1 100644 --- a/patches/server/Add-packet-limiter-config.patch +++ b/patches/server/Add-packet-limiter-config.patch @@ -28,9 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { - private static boolean enableExplicitFlush = Boolean.getBoolean("paper.explicit-flush"); - // Paper end - + } + } + // Paper end - allow controlled flushing + // Paper start - packet limiter + protected final Object PACKET_LIMIT_LOCK = new Object(); + protected final @Nullable io.papermc.paper.util.IntervalledCounter allPacketCounts = io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.isEnabled() ? new io.papermc.paper.util.IntervalledCounter( @@ -47,10 +47,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.stopReadingPackets = true; + } + // Paper end - packet limiter -+ + public Connection(PacketFlow side) { this.receiving = side; - } @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet packet) { diff --git a/patches/unapplied/server/Allow-controlled-flushing-for-network-manager.patch b/patches/server/Allow-controlled-flushing-for-network-manager.patch similarity index 100% rename from patches/unapplied/server/Allow-controlled-flushing-for-network-manager.patch rename to patches/server/Allow-controlled-flushing-for-network-manager.patch diff --git a/patches/server/Buffer-joins-to-world.patch b/patches/server/Buffer-joins-to-world.patch index 30c714d791..6e51274d45 100644 --- a/patches/server/Buffer-joins-to-world.patch +++ b/patches/server/Buffer-joins-to-world.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { - } // Paper end - add pending task queue } + // Paper end + private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper + private static int joinAttemptsThisTick; // Paper diff --git a/patches/unapplied/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch similarity index 100% rename from patches/unapplied/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch rename to patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch