2018-07-24 02:24:44 +02:00
|
|
|
From 9f53223bbee1f9a9c355d6db7f8526b5bbb300e1 Mon Sep 17 00:00:00 2001
|
2016-09-11 21:55:02 +02:00
|
|
|
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
|
2018-07-24 02:24:44 +02:00
|
|
|
index 0e5773bae..ed9ae4df3 100644
|
2016-09-11 21:55:02 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2018-07-24 02:24:44 +02:00
|
|
|
@@ -239,4 +239,13 @@ public class PaperConfig {
|
2016-09-11 21:55:02 +02:00
|
|
|
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
|
2018-07-24 02:24:44 +02:00
|
|
|
index 47554df42..c9613bf2d 100644
|
2016-09-11 21:55:02 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2018-07-18 06:52:33 +02:00
|
|
|
@@ -1186,13 +1186,14 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
2016-09-11 21:55:02 +02:00
|
|
|
// 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) {
|
2016-11-05 04:31:37 +01:00
|
|
|
+ if (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < THRESHOLD && limitedPackets++ >= 8) { // Paper - Use threshold, raise packet limit to 8
|
2016-09-11 21:55:02 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= 30) {
|
|
|
|
+ if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= THRESHOLD) { // Paper
|
|
|
|
lastLimitedPacket = timestamp;
|
|
|
|
limitedPackets = 0;
|
|
|
|
return true;
|
|
|
|
--
|
2018-07-04 09:55:24 +02:00
|
|
|
2.18.0
|
2016-09-11 21:55:02 +02:00
|
|
|
|