diff --git a/patches/server/0025-Purpur-Alternative-Keepalive-Handling.patch b/patches/server/0025-Purpur-Alternative-Keepalive-Handling.patch deleted file mode 100644 index 8892314d2..000000000 --- a/patches/server/0025-Purpur-Alternative-Keepalive-Handling.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Fri, 11 Oct 2019 00:17:39 -0500 -Subject: [PATCH] Purpur: Alternative Keepalive Handling - -Original license: MIT -Original project: https://github.com/PurpurMC/Purpur - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index d3d24ef11292966b33aafa038ba58d09c4dba36f..0146f7555be18fd1ee5bb5b2882d72c750a5bf65 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -261,6 +261,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - private long keepAliveTime = Util.getMillis(); - private boolean keepAlivePending; - private long keepAliveChallenge; -+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur - // CraftBukkit start - multithreaded fields - private final AtomicInteger chatSpamTickCount = new AtomicInteger(); - private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits -@@ -408,6 +409,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - long currentTime = Util.getMillis(); - long elapsedTime = currentTime - this.keepAliveTime; - -+ // Purpur start -+ if (org.dreeam.leaf.LeafConfig.useAlternateKeepAlive) { -+ if (elapsedTime >= 1000L) { // 1 second -+ if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) { -+ LOGGER.warn("{} was kicked due to keepalive timeout!", player.getName()); -+ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); -+ } else { -+ keepAliveTime = currentTime; // hijack this field for 1 second intervals -+ keepAlives.add(currentTime); // currentTime is ID -+ send(new ClientboundKeepAlivePacket(currentTime)); -+ } -+ } -+ } else -+ // Purpur end -+ - 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 -@@ -3608,6 +3624,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - - @Override - public void handleKeepAlive(ServerboundKeepAlivePacket packet) { -+ // Purpur start -+ if (org.dreeam.leaf.LeafConfig.useAlternateKeepAlive) { -+ long id = packet.getId(); -+ if (keepAlives.size() > 0 && keepAlives.contains(id)) { -+ int ping = (int) (Util.getMillis() - id); -+ player.latency = (player.latency * 3 + ping) / 4; -+ keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest -+ } -+ } else -+ // Purpur end - //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread - if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { - int i = (int) (Util.getMillis() - this.keepAliveTime); -diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 6e634269a28e7717ddf0dad2c4b7aeaabb31f3dc..e7a9ac8f3841a74e6bd0a6fb67ef3adcbd3d8b0e 100644 ---- a/src/main/java/org/dreeam/leaf/LeafConfig.java -+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -279,4 +279,9 @@ public class LeafConfig { - private static void tileentitySetting() { - persistentTileEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-tileentity-display-names-and-lore", persistentTileEntityDisplayNames); - } -+ -+ public static boolean useAlternateKeepAlive = false; -+ private static void useAlternateKeepAlive() { -+ useAlternateKeepAlive = getBoolean("settings.use-alternate-keepalive", useAlternateKeepAlive); -+ } - } diff --git a/patches/server/0026-Purpur-Skip-events-if-there-s-no-listeners.patch b/patches/server/0025-Purpur-Skip-events-if-there-s-no-listeners.patch similarity index 100% rename from patches/server/0026-Purpur-Skip-events-if-there-s-no-listeners.patch rename to patches/server/0025-Purpur-Skip-events-if-there-s-no-listeners.patch diff --git a/patches/server/0027-Purpur-Add-toggle-for-sand-duping-fix.patch b/patches/server/0026-Purpur-Add-toggle-for-sand-duping-fix.patch similarity index 84% rename from patches/server/0027-Purpur-Add-toggle-for-sand-duping-fix.patch rename to patches/server/0026-Purpur-Add-toggle-for-sand-duping-fix.patch index 05ad3440c..b1c1bf40c 100644 --- a/patches/server/0027-Purpur-Add-toggle-for-sand-duping-fix.patch +++ b/patches/server/0026-Purpur-Add-toggle-for-sand-duping-fix.patch @@ -29,12 +29,12 @@ index b2d1a17867cdbaad0c6e5c2376c716f9461af124..1bd3f04c4e461abbca4948195eaeee64 } // Paper end - fix sand duping diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index e7a9ac8f3841a74e6bd0a6fb67ef3adcbd3d8b0e..2799a3b57591aa940ddda2c0df855d56b25beb2f 100644 +index 6e634269a28e7717ddf0dad2c4b7aeaabb31f3dc..141174946c9bc50ddbb740cfb28c712c49234efb 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -284,4 +284,9 @@ public class LeafConfig { - private static void useAlternateKeepAlive() { - useAlternateKeepAlive = getBoolean("settings.use-alternate-keepalive", useAlternateKeepAlive); +@@ -279,4 +279,9 @@ public class LeafConfig { + private static void tileentitySetting() { + persistentTileEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-tileentity-display-names-and-lore", persistentTileEntityDisplayNames); } + + public static boolean fixSandDuping = true; diff --git a/patches/server/0028-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch b/patches/server/0027-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch similarity index 83% rename from patches/server/0028-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch rename to patches/server/0027-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch index afe8106ee..9eed2d2e1 100644 --- a/patches/server/0028-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch +++ b/patches/server/0027-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0146f7555be18fd1ee5bb5b2882d72c750a5bf65..a1846d06c65b0f53432d0fd155f75faad37d4fcd 100644 +index d3d24ef11292966b33aafa038ba58d09c4dba36f..785e07549c15a9355ff45187ad7faf83bc31ade5 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2397,7 +2397,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2381,7 +2381,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic do { instant1 = (Instant) this.lastChatTimeStamp.get(); if (timestamp.isBefore(instant1)) { @@ -20,10 +20,10 @@ index 0146f7555be18fd1ee5bb5b2882d72c750a5bf65..a1846d06c65b0f53432d0fd155f75faa } while (!this.lastChatTimeStamp.compareAndSet(instant1, timestamp)); diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 2799a3b57591aa940ddda2c0df855d56b25beb2f..3fde2da26556f6c05da48a6be5808dc797ff71f9 100644 +index 141174946c9bc50ddbb740cfb28c712c49234efb..8de8900f4523b484b090ac4602a4edf8ee121f9d 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -289,4 +289,9 @@ public class LeafConfig { +@@ -284,4 +284,9 @@ public class LeafConfig { private static void sandSettings() { fixSandDuping = getBoolean("blocks.sand.fix-duping", fixSandDuping); } diff --git a/patches/server/0029-KeYi-Smarter-statistics-ticking.patch b/patches/server/0028-KeYi-Smarter-statistics-ticking.patch similarity index 100% rename from patches/server/0029-KeYi-Smarter-statistics-ticking.patch rename to patches/server/0028-KeYi-Smarter-statistics-ticking.patch diff --git a/patches/server/0030-KeYi-Smooth-Teleports.patch b/patches/server/0029-KeYi-Smooth-Teleports.patch similarity index 100% rename from patches/server/0030-KeYi-Smooth-Teleports.patch rename to patches/server/0029-KeYi-Smooth-Teleports.patch diff --git a/patches/server/0031-KeYi-Fast-speed-check.patch b/patches/server/0030-KeYi-Fast-speed-check.patch similarity index 100% rename from patches/server/0031-KeYi-Fast-speed-check.patch rename to patches/server/0030-KeYi-Fast-speed-check.patch diff --git a/patches/server/0032-KeYi-Do-not-save-firework-entities-or-the-server-may.patch b/patches/server/0031-KeYi-Do-not-save-firework-entities-or-the-server-may.patch similarity index 100% rename from patches/server/0032-KeYi-Do-not-save-firework-entities-or-the-server-may.patch rename to patches/server/0031-KeYi-Do-not-save-firework-entities-or-the-server-may.patch diff --git a/patches/server/0033-KeYi-Don-t-create-new-random-instance.patch b/patches/server/0032-KeYi-Don-t-create-new-random-instance.patch similarity index 100% rename from patches/server/0033-KeYi-Don-t-create-new-random-instance.patch rename to patches/server/0032-KeYi-Don-t-create-new-random-instance.patch diff --git a/patches/server/0034-KeYi-Skip-entity-move-if-no-movement.patch b/patches/server/0033-KeYi-Skip-entity-move-if-no-movement.patch similarity index 100% rename from patches/server/0034-KeYi-Skip-entity-move-if-no-movement.patch rename to patches/server/0033-KeYi-Skip-entity-move-if-no-movement.patch diff --git a/patches/server/0035-KeYi-Optimized-getBiome-method.patch b/patches/server/0034-KeYi-Optimized-getBiome-method.patch similarity index 100% rename from patches/server/0035-KeYi-Optimized-getBiome-method.patch rename to patches/server/0034-KeYi-Optimized-getBiome-method.patch diff --git a/patches/server/0036-KeYi-Use-optimized-RecipeManager.patch b/patches/server/0035-KeYi-Use-optimized-RecipeManager.patch similarity index 100% rename from patches/server/0036-KeYi-Use-optimized-RecipeManager.patch rename to patches/server/0035-KeYi-Use-optimized-RecipeManager.patch diff --git a/patches/server/0037-KeYi-Use-cached-pool-for-mob-spawning-executor.patch b/patches/server/0036-KeYi-Use-cached-pool-for-mob-spawning-executor.patch similarity index 100% rename from patches/server/0037-KeYi-Use-cached-pool-for-mob-spawning-executor.patch rename to patches/server/0036-KeYi-Use-cached-pool-for-mob-spawning-executor.patch diff --git a/patches/server/0038-KeYi-Add-Java19-Support-for-SIMD.patch b/patches/server/0037-KeYi-Add-Java19-Support-for-SIMD.patch similarity index 100% rename from patches/server/0038-KeYi-Add-Java19-Support-for-SIMD.patch rename to patches/server/0037-KeYi-Add-Java19-Support-for-SIMD.patch diff --git a/patches/server/0039-KeYi-Use-a-faster-random-implementation.patch b/patches/server/0038-KeYi-Use-a-faster-random-implementation.patch similarity index 100% rename from patches/server/0039-KeYi-Use-a-faster-random-implementation.patch rename to patches/server/0038-KeYi-Use-a-faster-random-implementation.patch diff --git a/patches/server/0040-KeYi-Player-Skull-API.patch b/patches/server/0039-KeYi-Player-Skull-API.patch similarity index 100% rename from patches/server/0040-KeYi-Player-Skull-API.patch rename to patches/server/0039-KeYi-Player-Skull-API.patch diff --git a/patches/server/0041-Petal-async-path-processing.patch b/patches/server/0040-Petal-async-path-processing.patch similarity index 100% rename from patches/server/0041-Petal-async-path-processing.patch rename to patches/server/0040-Petal-async-path-processing.patch diff --git a/patches/server/0042-Petal-reduce-work-done-by-game-event-system.patch b/patches/server/0041-Petal-reduce-work-done-by-game-event-system.patch similarity index 100% rename from patches/server/0042-Petal-reduce-work-done-by-game-event-system.patch rename to patches/server/0041-Petal-reduce-work-done-by-game-event-system.patch diff --git a/patches/server/0043-Petal-reduce-sensor-work.patch b/patches/server/0042-Petal-reduce-sensor-work.patch similarity index 100% rename from patches/server/0043-Petal-reduce-sensor-work.patch rename to patches/server/0042-Petal-reduce-sensor-work.patch diff --git a/patches/server/0043-Gale-Send-multiple-keep-alive-packets.patch b/patches/server/0043-Gale-Send-multiple-keep-alive-packets.patch new file mode 100644 index 000000000..be468aedd --- /dev/null +++ b/patches/server/0043-Gale-Send-multiple-keep-alive-packets.patch @@ -0,0 +1,124 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 00:43:42 +0100 +Subject: [PATCH] Gale: Send multiple keep-alive packets + +Original license: MIT +Original project: https://github.com/GaleMC/Gale + +This patch is based on the following patch: +"Alternative Keepalive Handling" +By: William Blake Galbreath +As part of: Purpur (https://github.com/PurpurMC/Purpur) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Purpur copyright * + +MIT License + +Copyright (c) 2019-2022 PurpurMC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 785e07549c15a9355ff45187ad7faf83bc31ade5..80c41496614b28abd947182bfd895e6d75914d2d 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -9,6 +9,8 @@ import com.mojang.datafixers.util.Pair; + import com.mojang.logging.LogUtils; + import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry; + import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; ++import it.unimi.dsi.fastutil.longs.LongArrayList; ++import it.unimi.dsi.fastutil.longs.LongList; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + import it.unimi.dsi.fastutil.objects.ObjectIterator; + import java.time.Instant; +@@ -261,6 +263,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + private long keepAliveTime = Util.getMillis(); + private boolean keepAlivePending; + private long keepAliveChallenge; ++ private LongList keepAlives = new LongArrayList(); // Gale - Purpur - send multiple keep-alive packets + // CraftBukkit start - multithreaded fields + private final AtomicInteger chatSpamTickCount = new AtomicInteger(); + private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits +@@ -297,7 +300,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + private final SignedMessageChain.Decoder signedMessageDecoder; + private final LastSeenMessagesValidator lastSeenMessagesValidator; + private final FutureChain chatMessageChain; +- private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit ++ // Gale start - Purpur - send multiple keep-alive packets ++ private static final long KEEPALIVE_LIMIT_IN_SECONDS = Long.getLong("paper.playerconnection.keepalive", 30); // Paper - provide property to set keepalive limit ++ private static final long KEEPALIVE_LIMIT = KEEPALIVE_LIMIT_IN_SECONDS * 1000; ++ // Gale end - Purpur - send multiple keep-alive packets + private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper + + private String clientBrandName = null; // Paper - Brand name +@@ -408,6 +414,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + long currentTime = Util.getMillis(); + long elapsedTime = currentTime - this.keepAliveTime; + ++ // Gale start - Purpur - send multiple keep-alive packets ++ if (LeafConfig.sendMultipleKeepalive) { ++ if (elapsedTime >= 1000L) { // 1 second ++ if (!this.processedDisconnect && this.keepAlives.size() >= KEEPALIVE_LIMIT_IN_SECONDS) { ++ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getName()); ++ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); ++ } else { ++ this.keepAliveTime = currentTime; // hijack this field for 1 second intervals ++ this.keepAlives.add(currentTime); // currentTime is ID ++ send(new ClientboundKeepAlivePacket(currentTime)); ++ } ++ } ++ } else ++ // Gale end - Purpur - send multiple keep-alive packets ++ + 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 +@@ -3608,6 +3629,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + + @Override + public void handleKeepAlive(ServerboundKeepAlivePacket packet) { ++ // Gale start - Purpur - send multiple keep-alive packets ++ if (LeafConfig.sendMultipleKeepalive) { ++ long id = packet.getId(); ++ if (!this.keepAlives.isEmpty() && this.keepAlives.contains(id)) { ++ int ping = (int) (Util.getMillis() - id); ++ this.player.latency = (this.player.latency * 3 + ping) / 4; ++ this.keepAlives.clear(); // We got a valid response, let's roll with it and forget the rest ++ } ++ } else ++ // Gale end - Purpur - send multiple keep-alive packets + //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread + if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { + int i = (int) (Util.getMillis() - this.keepAliveTime); +diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java +index 8de8900f4523b484b090ac4602a4edf8ee121f9d..b1a4768b31fd4ae32d0b8f1b4d983b18042be9de 100644 +--- a/src/main/java/org/dreeam/leaf/LeafConfig.java ++++ b/src/main/java/org/dreeam/leaf/LeafConfig.java +@@ -286,7 +286,9 @@ public class LeafConfig { + } + + public static boolean kickForOutOfOrderChat = true; ++ public static boolean sendMultipleKeepalive = true; + private static void networkSettings() { + kickForOutOfOrderChat = getBoolean("settings.network.kick-for-out-of-order-chat", kickForOutOfOrderChat); ++ sendMultipleKeepalive = getBoolean("settings.network.send-multiple-keepalive", sendMultipleKeepalive); + } + }