aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0414-Buffer-joins-to-world.patch
diff options
context:
space:
mode:
authorJason Penilla <[email protected]>2024-04-27 13:27:01 -0700
committerJason Penilla <[email protected]>2024-04-27 13:27:01 -0700
commite2552eea2481871c9d8445a3c5653a2329112648 (patch)
tree727c90f395576b66200f8d9e59f38859f3850562 /patches/server/0414-Buffer-joins-to-world.patch
parent0b1b1fe067444c5e879313e017da0ffd5d6b826d (diff)
downloadPaper-e2552eea2481871c9d8445a3c5653a2329112648.tar.gz
Paper-e2552eea2481871c9d8445a3c5653a2329112648.zip
Start cleaning up plugin remapping patches
Diffstat (limited to 'patches/server/0414-Buffer-joins-to-world.patch')
-rw-r--r--patches/server/0414-Buffer-joins-to-world.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/patches/server/0414-Buffer-joins-to-world.patch b/patches/server/0414-Buffer-joins-to-world.patch
new file mode 100644
index 0000000000..26675cacaf
--- /dev/null
+++ b/patches/server/0414-Buffer-joins-to-world.patch
@@ -0,0 +1,40 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Shane Freeder <[email protected]>
+Date: Wed, 19 Aug 2020 05:05:54 +0100
+Subject: [PATCH] Buffer joins to world
+
+This patch buffers the number of logins which will attempt to join
+the world per tick, this attempts to reduce the impact that join floods
+has on the server
+
+diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
+index 9885dec92cd26dec61c303dda687b0f910d49749..68d5be903a0d13e59c9e4bd6d85baaf0773547a0 100644
+--- a/src/main/java/net/minecraft/network/Connection.java
++++ b/src/main/java/net/minecraft/network/Connection.java
+@@ -437,12 +437,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
+ }
+ }
+
++ private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world
++ private static int joinAttemptsThisTick; // Paper - Buffer joins to world
++ private static int currTick; // Paper - Buffer joins to world
+ public void tick() {
+ this.flushQueue();
++ // Paper start - Buffer joins to world
++ if (Connection.currTick != net.minecraft.server.MinecraftServer.currentTick) {
++ Connection.currTick = net.minecraft.server.MinecraftServer.currentTick;
++ Connection.joinAttemptsThisTick = 0;
++ }
++ // Paper end - Buffer joins to world
+ PacketListener packetlistener = this.packetListener;
+
+ if (packetlistener instanceof TickablePacketListener tickablepacketlistener) {
++ // Paper start - Buffer joins to world
++ if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener)
++ || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING
++ || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) {
+ tickablepacketlistener.tick();
++ } // Paper end - Buffer joins to world
+ }
+
+ if (!this.isConnected() && !this.disconnectionHandled) {