aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0105-Configurable-packet-in-spam-threshold.patch
blob: de9749ed924978053283059dedc8e68cc740693a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 728835cddd413d778e9628360989724f65335b46..6c13fe725ca2b2a6f0f375b80f6c2cb643b9913d 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -264,4 +264,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 60772b6d6fe171d7dd832cb132f7c56db9439bdb..451a2ea80c6262008be6b075c122c78a5b435c75 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1483,13 +1483,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;