From 5a600445d016f54c26a7f5bc1aae790dcf81f5e2 Mon Sep 17 00:00:00 2001 From: Luohuayu Date: Fri, 23 Feb 2024 18:40:46 +0800 Subject: [PATCH] Add network.packetLimit.releaseUseItemThrottle option --- patches/net/minecraft/network/NetHandlerPlayServer.java.patch | 2 +- src/main/java/catserver/server/CatServerConfig.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch index 9a369a0af..8204845e0 100644 --- a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -726,7 +726,7 @@ return; case RELEASE_USE_ITEM: + // CatServer start -+ if (this.releasedUseItemThrottle++ >= 10) { ++ if (catserver.server.CatServer.getConfig().releaseUseItemThrottle > 0 && this.releasedUseItemThrottle++ >= catserver.server.CatServer.getConfig().releaseUseItemThrottle) { + LOGGER.warn(this.player.getName() + " released use item too quickly!"); + this.disconnect("You released use item too quickly (Hacking?)"); + return; diff --git a/src/main/java/catserver/server/CatServerConfig.java b/src/main/java/catserver/server/CatServerConfig.java index 984146364..ad3135c6d 100644 --- a/src/main/java/catserver/server/CatServerConfig.java +++ b/src/main/java/catserver/server/CatServerConfig.java @@ -48,6 +48,7 @@ public class CatServerConfig { public int itemNBTThrottle = 200; public boolean limitFastClickGUI = false; public int clickGUIThrottle = 50; + public int releaseUseItemThrottle = 20; public boolean disableUpdateGameProfile = false; public boolean disableFMLHandshake = false; @@ -99,6 +100,7 @@ public void loadConfig() { itemNBTThrottle = getOrWriteIntConfig("network.packetLimit.itemNBTThrottle", itemNBTThrottle); limitFastClickGUI = getOrWriteBooleanConfig("network.packetLimit.fastClickGUI", config.getBoolean("vanilla.limitFastClickGUI", limitFastClickGUI)); clickGUIThrottle = getOrWriteIntConfig("network.packetLimit.clickGUIThrottle", clickGUIThrottle); + releaseUseItemThrottle = getOrWriteIntConfig("network.packetLimit.releaseUseItemThrottle", releaseUseItemThrottle); disableFMLHandshake = getOrWriteBooleanConfig("network.fml.disableHandshake", config.getBoolean("disableFMLHandshake", disableFMLHandshake)); disableFMLStatusModInfo = getOrWriteBooleanConfig("network.fml.disableStatusModInfo", config.getBoolean("disableFMLStatusModInfo", disableFMLStatusModInfo)); // general