Paper/patches/server/0103-Configurable-packet-in-spam-threshold.patch
2021-06-12 09:26:16 +02:00

46 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sun, 11 Sep 2016 14:30:57 -0500
Subject: [PATCH] Configurable packet in spam threshold
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index c52dc0346f93527965ef29a0ccdc4bf3debe302e..64d7c9058ee757a6d3cf3b648596092a810e105c 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -252,4 +252,13 @@ public class PaperConfig {
public static boolean isProxyOnlineMode() {
return Bukkit.getOnlineMode() || (SpigotConfig.bungee && bungeeOnlineMode);
}
+
+ public static int packetInSpamThreshold = 300;
+ private static void packetInSpamThreshold() {
+ if (version < 11) {
+ int oldValue = getInt("settings.play-in-use-item-spam-threshold", 300);
+ set("settings.incoming-packet-spam-threshold", oldValue);
+ }
+ packetInSpamThreshold = getInt("settings.incoming-packet-spam-threshold", 300);
+ }
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 6cd0fd57503723a58b30a7c33b1c863afc2401e2..37a25af3697e06a7f8aeaf462fbf50f8bc250dd3 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1495,13 +1495,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
// Spigot start - limit place/interactions
private int limitedPackets;
private long lastLimitedPacket = -1;
+ private static final int THRESHOLD = com.destroystokyo.paper.PaperConfig.packetInSpamThreshold; // Paper - Configurable threshold
private boolean checkLimit(long timestamp) {
- if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < 30 && this.limitedPackets++ >= 4) {
+ if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < THRESHOLD && this.limitedPackets++ >= 8) { // Paper - Use threshold, raise packet limit to 8
return false;
}
- if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= 30) {
+ if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= THRESHOLD) { // Paper
this.lastLimitedPacket = timestamp;
this.limitedPackets = 0;
return true;