2019-05-28 07:01:45 +08:00
|
|
|
From cb713b852dbd0b6765dc4c9276b466f8113329a2 Mon Sep 17 00:00:00 2001
|
2016-09-12 03:55:02 +08: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
|
2019-05-28 07:01:45 +08:00
|
|
|
index 3d9dba7696..5c7f170907 100644
|
2016-09-12 03:55:02 +08:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2019-05-06 15:20:16 +08:00
|
|
|
@@ -243,4 +243,13 @@ public class PaperConfig {
|
2018-10-19 08:44:59 +08:00
|
|
|
public static boolean isProxyOnlineMode() {
|
|
|
|
return Bukkit.getOnlineMode() || (SpigotConfig.bungee && bungeeOnlineMode);
|
2016-09-12 03:55:02 +08:00
|
|
|
}
|
2018-10-19 08:44:59 +08:00
|
|
|
+
|
2016-09-12 03:55:02 +08:00
|
|
|
+ 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
|
2019-05-28 07:01:45 +08:00
|
|
|
index 630059246f..fd990e703c 100644
|
2016-09-12 03:55:02 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2019-05-28 07:01:45 +08:00
|
|
|
@@ -1220,13 +1220,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2016-09-12 03:55:02 +08: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 11:31:37 +08:00
|
|
|
+ if (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < THRESHOLD && limitedPackets++ >= 8) { // Paper - Use threshold, raise packet limit to 8
|
2016-09-12 03:55:02 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= 30) {
|
|
|
|
+ if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= THRESHOLD) { // Paper
|
|
|
|
lastLimitedPacket = timestamp;
|
|
|
|
limitedPackets = 0;
|
|
|
|
return true;
|
|
|
|
--
|
2019-03-20 09:46:00 +08:00
|
|
|
2.21.0
|
2016-09-12 03:55:02 +08:00
|
|
|
|