aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0154-Configurable-packet-in-spam-threshold.patch
diff options
context:
space:
mode:
Diffstat (limited to 'Spigot-Server-Patches/0154-Configurable-packet-in-spam-threshold.patch')
-rw-r--r--Spigot-Server-Patches/0154-Configurable-packet-in-spam-threshold.patch48
1 files changed, 48 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0154-Configurable-packet-in-spam-threshold.patch b/Spigot-Server-Patches/0154-Configurable-packet-in-spam-threshold.patch
new file mode 100644
index 0000000000..c997561f3b
--- /dev/null
+++ b/Spigot-Server-Patches/0154-Configurable-packet-in-spam-threshold.patch
@@ -0,0 +1,48 @@
+From b81c66363a4118495a786c69be2c447d6c0c24d7 Mon Sep 17 00:00:00 2001
+From: Zach Brown <[email protected]>
+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 c758bde3f..d765607c0 100644
+--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
++++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
+@@ -235,4 +235,13 @@ public class PaperConfig {
+ private static void bungeeOnlineMode() {
+ bungeeOnlineMode = getBoolean("settings.bungee-online-mode", true);
+ }
++
++ 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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
+index 060434f32..6281fe4d5 100644
+--- a/src/main/java/net/minecraft/server/PlayerConnection.java
++++ b/src/main/java/net/minecraft/server/PlayerConnection.java
+@@ -871,13 +871,14 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+ // 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 (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < 30 && limitedPackets++ >= 4) {
++ if (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < THRESHOLD && limitedPackets++ >= 8) { // Paper - Use threshold, raise packet limit to 8
+ return false;
+ }
+
+- if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= 30) {
++ if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= THRESHOLD) { // Paper
+ lastLimitedPacket = timestamp;
+ limitedPackets = 0;
+ return true;
+--
+2.12.2
+