This is a part of Leaf(https://github.com/Winds-Studio/Leaf/blob/8293ae2d0ada9df24e944f755b50e93208c1496d/leaf-server/minecraft-patches/features/0281-Lithium-faster-hash-palette.patch) Original proj license: https://github.com/Winds-Studio/Leaf/blob/8293ae2d0ada9df24e944f755b50e93208c1496d/LICENSE.md This patch is based on the following mixins: * "net/caffeinemc/mods/lithium/mixin/chunk/palette/StrategyMixin.java" By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium) Licensed under: LGPL-3.0-only (https://www.gnu.org/licenses/lgpl-3.0.html)
62 lines
4.6 KiB
Diff
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 392c4b39a9c31be4b5b1fa61f6836920b43e58a3..9ed70554904b90fc686a6cf9039a7d24b6b040e1 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;
|
|
}
|
|
@@ -2124,6 +2124,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;
|
|
}
|
|
@@ -2690,6 +2691,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)) {
|
|
@@ -3488,7 +3491,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;
|