diff --git a/lophine-server/minecraft-patches/features/0009-Leaves-Disable-packet-limit.patch b/lophine-server/minecraft-patches/features/0009-Leaves-Disable-packet-limit.patch new file mode 100644 index 0000000..4ded975 --- /dev/null +++ b/lophine-server/minecraft-patches/features/0009-Leaves-Disable-packet-limit.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Helvetica Volubi +Date: Sun, 27 Jul 2025 13:48:10 +0800 +Subject: [PATCH] Leaves: Disable packet limit + +Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com> +As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/6a2b9ee6b330cd18b0a8eb2a824d561fa76012bb/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java +index 6dc5f3e88a3886b03b99d59b317085fdc3e2fa9a..e556bcaf2a5863073a047947f5962179d054e8d9 100644 +--- a/net/minecraft/network/Connection.java ++++ b/net/minecraft/network/Connection.java +@@ -280,8 +280,8 @@ public class Connection extends SimpleChannelInboundHandler> { + if (this.stopReadingPackets) { + return; + } +- if (this.allPacketCounts != null || +- io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass())) { ++ if (!fun.bm.lophine.config.modules.optimizations.NetworkConfig.disablePacketLimit && (this.allPacketCounts != null || // Leaves - can disable ++ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass()))) { // Leaves - can disable + long time = System.nanoTime(); + synchronized (PACKET_LIMIT_LOCK) { + if (this.allPacketCounts != null) { +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 68f0023c4234585a8385a830ed410883c8bd1549..206b4a532eba02b2a1f6f3b832970bc4c94fc45b 100644 +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -856,7 +856,7 @@ public class ServerGamePacketListenerImpl + public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { + // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); // Paper - AsyncTabCompleteEvent; run this async + // CraftBukkit start +- if (!this.tabSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { // Paper - configurable tab spam limits ++ if (!fun.bm.lophine.config.modules.optimizations.NetworkConfig.disablePacketLimit && !this.tabSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { // Paper - configurable tab spam limits // Leaves - can disable + this.disconnectAsync(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - Kick event cause // Paper - add proper async disconnect + return; + } +@@ -2047,6 +2047,7 @@ public class ServerGamePacketListenerImpl + private static int getSpamThreshold() { return io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold; } // Paper - Configurable threshold + + private boolean checkLimit(long timestamp) { ++ if (fun.bm.lophine.config.modules.optimizations.NetworkConfig.disablePacketLimit) return true; // Leaves - disable + if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < getSpamThreshold() && this.limitedPackets++ >= 8) { // Paper - Configurable threshold; raise packet limit to 8 + return false; + } +@@ -2586,6 +2587,7 @@ public class ServerGamePacketListenerImpl + + // Spigot start - spam exclusions + private void detectRateSpam(String message) { ++ if (fun.bm.lophine.config.modules.optimizations.NetworkConfig.disablePacketLimit) return; // Leaves - disable + // CraftBukkit start - replaced with thread safe throttle + if (org.spigotmc.SpigotConfig.enableSpamExclusions) { + for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) { +@@ -3333,7 +3335,7 @@ public class ServerGamePacketListenerImpl + @Override + public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { + // Paper start - auto recipe limit +- if (!org.bukkit.Bukkit.isPrimaryThread()) { ++ if (!fun.bm.lophine.config.modules.optimizations.NetworkConfig.disablePacketLimit && !org.bukkit.Bukkit.isPrimaryThread()) { // Leaves - can disable + if (!this.recipeSpamPackets.isIncrementAndUnderThreshold()) { + this.disconnectAsync(net.minecraft.network.chat.Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - kick event cause // Paper - add proper async disconnect + return; diff --git a/lophine-server/minecraft-patches/features/0009-Leaves-Item-overstack-util.patch b/lophine-server/minecraft-patches/features/0010-Leaves-Item-overstack-util.patch similarity index 98% rename from lophine-server/minecraft-patches/features/0009-Leaves-Item-overstack-util.patch rename to lophine-server/minecraft-patches/features/0010-Leaves-Item-overstack-util.patch index ecc3241..71b417a 100644 --- a/lophine-server/minecraft-patches/features/0009-Leaves-Item-overstack-util.patch +++ b/lophine-server/minecraft-patches/features/0010-Leaves-Item-overstack-util.patch @@ -41,10 +41,10 @@ index 5a1c21b05545a03fbb00cf734605049870d3eecb..a0459bc6b2241e7fca74bfbfce058882 if (count > i) { source.sendFailure(Component.translatable("commands.give.failed.toomanyitems", i, itemStack.getDisplayName())); diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 68f0023c4234585a8385a830ed410883c8bd1549..ebb884743989097ef7b7fa8edaa824b27cab4a7a 100644 +index 206b4a532eba02b2a1f6f3b832970bc4c94fc45b..39b5422af26fce5f1d5437ed35676b511bf13241 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3076,7 +3076,7 @@ public class ServerGamePacketListenerImpl +@@ -3078,7 +3078,7 @@ public class ServerGamePacketListenerImpl } else if (slot.mayPlace(cursor)) { if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { int toPlace = packet.buttonNum() == 0 ? cursor.getCount() : 1; @@ -53,7 +53,7 @@ index 68f0023c4234585a8385a830ed410883c8bd1549..ebb884743989097ef7b7fa8edaa824b2 toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); if (toPlace == 1) { action = InventoryAction.PLACE_ONE; -@@ -3112,7 +3112,7 @@ public class ServerGamePacketListenerImpl +@@ -3114,7 +3114,7 @@ public class ServerGamePacketListenerImpl } } else if (ItemStack.isSameItemSameComponents(cursor, clickedItem)) { if (clickedItem.getCount() >= 0) { @@ -62,7 +62,7 @@ index 68f0023c4234585a8385a830ed410883c8bd1549..ebb884743989097ef7b7fa8edaa824b2 // As of 1.5, this is result slots only action = InventoryAction.PICKUP_ALL; } -@@ -3323,6 +3323,7 @@ public class ServerGamePacketListenerImpl +@@ -3325,6 +3325,7 @@ public class ServerGamePacketListenerImpl this.player.containerMenu.broadcastFullState(); } else { this.player.containerMenu.broadcastChanges(); @@ -70,7 +70,7 @@ index 68f0023c4234585a8385a830ed410883c8bd1549..ebb884743989097ef7b7fa8edaa824b2 } if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } -@@ -3433,7 +3434,7 @@ public class ServerGamePacketListenerImpl +@@ -3435,7 +3436,7 @@ public class ServerGamePacketListenerImpl } boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; @@ -79,7 +79,7 @@ index 68f0023c4234585a8385a830ed410883c8bd1549..ebb884743989097ef7b7fa8edaa824b2 if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packet.slotNum()).getItem(), packet.itemStack()))) { // Insist on valid slot // CraftBukkit start - Call click event org.bukkit.inventory.InventoryView inventory = this.player.inventoryMenu.getBukkitView(); -@@ -3475,6 +3476,7 @@ public class ServerGamePacketListenerImpl +@@ -3477,6 +3478,7 @@ public class ServerGamePacketListenerImpl this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack); this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack); this.player.inventoryMenu.broadcastChanges(); diff --git a/lophine-server/minecraft-patches/features/0010-Leaves-Redstone-Shears-Wrench.patch b/lophine-server/minecraft-patches/features/0011-Leaves-Redstone-Shears-Wrench.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0010-Leaves-Redstone-Shears-Wrench.patch rename to lophine-server/minecraft-patches/features/0011-Leaves-Redstone-Shears-Wrench.patch diff --git a/lophine-server/minecraft-patches/features/0011-Paper-Fix-quick-craft.patch b/lophine-server/minecraft-patches/features/0012-Paper-Fix-quick-craft.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0011-Paper-Fix-quick-craft.patch rename to lophine-server/minecraft-patches/features/0012-Paper-Fix-quick-craft.patch diff --git a/lophine-server/minecraft-patches/features/0012-Purpur-Barrels-and-enderchests-6-rows.patch b/lophine-server/minecraft-patches/features/0013-Purpur-Barrels-and-enderchests-6-rows.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0012-Purpur-Barrels-and-enderchests-6-rows.patch rename to lophine-server/minecraft-patches/features/0013-Purpur-Barrels-and-enderchests-6-rows.patch diff --git a/lophine-server/minecraft-patches/features/0013-Spawn-invulnerable-time.patch b/lophine-server/minecraft-patches/features/0014-Spawn-invulnerable-time.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0013-Spawn-invulnerable-time.patch rename to lophine-server/minecraft-patches/features/0014-Spawn-invulnerable-time.patch diff --git a/lophine-server/minecraft-patches/features/0014-Old-Explosion-Damage-Calculator.patch b/lophine-server/minecraft-patches/features/0015-Old-Explosion-Damage-Calculator.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0014-Old-Explosion-Damage-Calculator.patch rename to lophine-server/minecraft-patches/features/0015-Old-Explosion-Damage-Calculator.patch diff --git a/lophine-server/minecraft-patches/features/0015-Old-replaceable-by-mushrooms.patch b/lophine-server/minecraft-patches/features/0016-Old-replaceable-by-mushrooms.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0015-Old-replaceable-by-mushrooms.patch rename to lophine-server/minecraft-patches/features/0016-Old-replaceable-by-mushrooms.patch diff --git a/lophine-server/minecraft-patches/features/0016-Old-zombie-reinforcement.patch b/lophine-server/minecraft-patches/features/0017-Old-zombie-reinforcement.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0016-Old-zombie-reinforcement.patch rename to lophine-server/minecraft-patches/features/0017-Old-zombie-reinforcement.patch diff --git a/lophine-server/minecraft-patches/features/0017-I18n-support.patch b/lophine-server/minecraft-patches/features/0018-I18n-support.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0017-I18n-support.patch rename to lophine-server/minecraft-patches/features/0018-I18n-support.patch diff --git a/lophine-server/src/main/java/fun/bm/lophine/config/modules/optimizations/NetworkConfig.java b/lophine-server/src/main/java/fun/bm/lophine/config/modules/optimizations/NetworkConfig.java new file mode 100644 index 0000000..2965a5e --- /dev/null +++ b/lophine-server/src/main/java/fun/bm/lophine/config/modules/optimizations/NetworkConfig.java @@ -0,0 +1,21 @@ +package fun.bm.lophine.config.modules.optimizations; + +import me.earthme.luminol.config.EnumConfigCategory; +import me.earthme.luminol.config.IConfigModule; +import me.earthme.luminol.config.flags.ConfigInfo; + +public class NetworkConfig implements IConfigModule { + @ConfigInfo(baseName = "unlimit-packet", comments = """ + Disable packet limit""") + public static boolean disablePacketLimit = true; + + @Override + public EnumConfigCategory getCategory() { + return EnumConfigCategory.OPTIMIZATIONS; + } + + @Override + public String getBaseName() { + return "network"; + } +} \ No newline at end of file