From cdb6ba8ef1fc609289e813fa1dcbe62ac610ed0d Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 10 May 2024 17:23:58 -0700 Subject: [PATCH] Fix keepalive time interval (#10690) --- .../0158-revert-serverside-behavior-of-keepalives.patch | 6 +++--- patches/server/0558-Add-PlayerKickEvent-causes.patch | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/server/0158-revert-serverside-behavior-of-keepalives.patch b/patches/server/0158-revert-serverside-behavior-of-keepalives.patch index fa7ee14322..167f18e6c9 100644 --- a/patches/server/0158-revert-serverside-behavior-of-keepalives.patch +++ b/patches/server/0158-revert-serverside-behavior-of-keepalives.patch @@ -17,7 +17,7 @@ from networking or during connections flood of chunk packets on slower clients, at the cost of dead connections being kept open for longer. diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 8cc454ad3f6b865253bdd4902fbf19fc4a3e4a7f..b8b22a2b140b4d757add6eefa562d32430fb7424 100644 +index 8cc454ad3f6b865253bdd4902fbf19fc4a3e4a7f..a0dc17702fb6c8c96f262bc917624a46a40920fa 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -68,7 +68,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -49,8 +49,8 @@ index 8cc454ad3f6b865253bdd4902fbf19fc4a3e4a7f..b8b22a2b140b4d757add6eefa562d324 - if (!this.isSingleplayerOwner() && i - this.keepAliveTime >= 25000L) { // CraftBukkit - if (this.keepAlivePending) { -+ if (!this.isSingleplayerOwner() && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected -+ if (this.keepAlivePending && !this.processedDisconnect) { // Paper ++ if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets ++ if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE); - } else if (this.checkIfClosed(i)) { + } else if (this.checkIfClosed(currentTime)) { // Paper diff --git a/patches/server/0558-Add-PlayerKickEvent-causes.patch b/patches/server/0558-Add-PlayerKickEvent-causes.patch index 8bf3ee985a..a107a7926d 100644 --- a/patches/server/0558-Add-PlayerKickEvent-causes.patch +++ b/patches/server/0558-Add-PlayerKickEvent-causes.patch @@ -95,7 +95,7 @@ index d1caaecfdfba1cdeba032f0bc38c06541fa61633..6468b3a25c7527a2fde6899e4812b5cb i++; } diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 2872bef40440b11a206c3ec88e2c6d95cd1a72e9..dde1d3850af610241e1f76a194efe1a58dc96bd5 100644 +index 661765a9fe1c2e49299262190501ee3b3294a2f1..7659a3f50f5a90814dc7331ea00d6251dcf32600 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -127,7 +127,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -154,8 +154,8 @@ index 2872bef40440b11a206c3ec88e2c6d95cd1a72e9..dde1d3850af610241e1f76a194efe1a5 protected void keepConnectionAlive() { @@ -249,7 +249,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - if (!this.isSingleplayerOwner() && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected - if (this.keepAlivePending && !this.processedDisconnect) { // Paper + if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets + if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected - this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE); + this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause } else if (this.checkIfClosed(currentTime)) { // Paper @@ -486,7 +486,7 @@ index f472dea0bd4f834c0c8f0aa59ae7cdae082b14af..2fa51c3a70f43cd23b8f494fc643d66c } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 6100e2313a86f9baca136a178cc30d4adc5cae53..1cbf70e8f238a3e67f27d86b9f685d5303fa5527 100644 +index dc8e6a4e62cc094300d20a057720b51b31c40b56..62a95876b01f1a8065c67bc844fe53920074fc57 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -633,7 +633,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {