From 8a46226fdd14e0f8cf80b21274ef2b79e92158ca Mon Sep 17 00:00:00 2001 From: granny Date: Sat, 23 Sep 2023 06:10:10 -0700 Subject: [PATCH] please the scanJarForBadCalls task --- .../server/0017-Alternative-Keepalive-Handling.patch | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/patches/server/0017-Alternative-Keepalive-Handling.patch b/patches/server/0017-Alternative-Keepalive-Handling.patch index d312e1997..a25df702c 100644 --- a/patches/server/0017-Alternative-Keepalive-Handling.patch +++ b/patches/server/0017-Alternative-Keepalive-Handling.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Alternative Keepalive Handling diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 566a9449cf8a10fff9266a4384cfeb9492f4666e..52e17511d44415bc26d61db1c013c796d816109f 100644 +index 566a9449cf8a10fff9266a4384cfeb9492f4666e..64b6d19db7cd0dff7c1461c051a5e4d81dcd7cae 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -51,6 +51,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -33,7 +33,7 @@ index 566a9449cf8a10fff9266a4384cfeb9492f4666e..52e17511d44415bc26d61db1c013c796 //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { int i = (int) (Util.getMillis() - this.keepAliveTime); -@@ -207,6 +218,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -207,10 +218,25 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack long currentTime = Util.getMillis(); long elapsedTime = currentTime - this.keepAliveTime; @@ -42,7 +42,7 @@ index 566a9449cf8a10fff9266a4384cfeb9492f4666e..52e17511d44415bc26d61db1c013c796 + if (elapsedTime >= 1000L) { // 1 second + if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) { + LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); -+ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); ++ disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); + } else { + keepAliveTime = currentTime; // hijack this field for 1 second intervals + keepAlives.add(currentTime); // currentTime is ID @@ -55,6 +55,11 @@ index 566a9449cf8a10fff9266a4384cfeb9492f4666e..52e17511d44415bc26d61db1c013c796 if (this.keepAlivePending) { if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info +- this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE); ++ this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Purpur - TODO: Paper + } + } else { + if (elapsedTime >= 15000L) { // 15 seconds diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java index 34afed28faeb56352b48faf8078a5fb07912eb5e..ad239ba9259c5a63b40261ebc44224893496b47d 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java