Files
Shiroha/shiroha-server/minecraft-patches/features/0069-Leaves-Disable-packet-limit-Shiroha-Option-to-full-d.patch
T
NanaChiyo0721 1bb895c165
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s
Fix incorrect ticket lock size computing
Yeah this would fully solve the issue of chunk unloading race condition

The same fix was already initially added at "Force clamp grid-exponent to 1~6"
2026-08-09 14:57:32 +08:00

62 lines
4.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Sun, 28 Jun 2026 20:57:48 +0800
Subject: [PATCH] Leaves: Disable packet limit & Shiroha: Option to full
disable packet limiter
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
index d3fb20f465c0b69662d81b53201963634d8b53d2..4e557a304e2c1c6d581fdf4a8d30c6a23dd945af 100644
--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -258,8 +258,8 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.stopReadingPackets) {
return;
}
- if (this.allPacketCounts != null ||
- io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass())) {
+ if (!io.nanachiyo0721.shiroha.config.modules.misc.PaperPacketLimiterConfig.forceDisable && (this.allPacketCounts != null || // Shiroha - Add config to force disable the packet limiter of Paper
+ io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.overrides.containsKey(packet.getClass()))) { // Shiroha - Add config to force disable the packet limiter of Paper
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 acb148f14593bf8a468a4623b68ba1c7935b5ba6..be8d2a76ec1b93f6110f2a65c701bcbdc3dfe79d 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -890,7 +890,7 @@ public class ServerGamePacketListenerImpl
public void handleCustomCommandSuggestions(final 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.nameAndId()) && !this.server.isSingleplayerOwner(this.player.nameAndId())) { // Paper - configurable tab spam limits
+ if (!io.nanachiyo0721.shiroha.config.modules.misc.PaperPacketLimiterConfig.forceDisable && !this.tabSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.nameAndId()) && !this.server.isSingleplayerOwner(this.player.nameAndId())) { // 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;
}
@@ -2125,6 +2125,7 @@ public class ServerGamePacketListenerImpl
private long lastLimitedPacket = -1;
private boolean checkLimit(long timestamp) {
+ if (io.nanachiyo0721.shiroha.config.modules.misc.PaperPacketLimiterConfig.forceDisable) return true; // Leaves - disable
if (!io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold.enabled()) {
return true;
}
@@ -2691,6 +2692,8 @@ public class ServerGamePacketListenerImpl
// Spigot start - spam exclusions
private void detectRateSpam(final TickThrottler throttler, final String message) {
+ if (io.nanachiyo0721.shiroha.config.modules.misc.PaperPacketLimiterConfig.forceDisable) return; // Leaves - disable
+ // CraftBukkit start - replaced with thread safe throttle
if (org.spigotmc.SpigotConfig.enableSpamExclusions) {
for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) {
if (exclude != null && message.startsWith(exclude)) {
@@ -3489,7 +3492,7 @@ public class ServerGamePacketListenerImpl
@Override
public void handlePlaceRecipe(final ServerboundPlaceRecipePacket packet) {
// Paper start - auto recipe limit
- if (!org.bukkit.Bukkit.isPrimaryThread()) {
+ if (!io.nanachiyo0721.shiroha.config.modules.misc.PaperPacketLimiterConfig.forceDisable && !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;