mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-17 02:34:30 +01:00
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
This commit is contained in:
parent
aa91a6bd79
commit
448d693a4b
1 changed files with 50 additions and 0 deletions
50
Spigot-Server-Patches/Buffer-joins-to-world.patch
Normal file
50
Spigot-Server-Patches/Buffer-joins-to-world.patch
Normal file
|
@ -0,0 +1,50 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
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/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperConfig {
|
||||
maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public static int maxJoinsPerTick;
|
||||
+ private static void maxJoinsPerTick() {
|
||||
+ getInt("settings.max-joins-per-tick", 3);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ private static final int MAX_PER_TICK = com.destroystokyo.paper.PaperConfig.maxJoinsPerTick; // Paper
|
||||
+ private static int joinAttemptsThisTick; // Paper
|
||||
+ private static int currTick; // Paper
|
||||
public void a() {
|
||||
this.p();
|
||||
+ // Paper start
|
||||
+ if (currTick != MinecraftServer.currentTick) {
|
||||
+ currTick = MinecraftServer.currentTick;
|
||||
+ joinAttemptsThisTick = 0;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.packetListener instanceof LoginListener) {
|
||||
+ if ( ((LoginListener) this.packetListener).getLoginState() != LoginListener.EnumProtocolState.READY_TO_ACCEPT // Paper
|
||||
+ || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick
|
||||
((LoginListener) this.packetListener).tick();
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
if (this.packetListener instanceof PlayerConnection) {
|
Loading…
Add table
Reference in a new issue