2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-07-26 01:11:44 +02:00
|
|
|
index 092f9f9588d3a3621d6221c397c0e64aff9067e2..a9965c54e18d714acb8fe5d40cb90efeb8f9eff0 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2021-07-26 01:11:44 +02:00
|
|
|
@@ -261,4 +261,13 @@ public class PaperConfig {
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-07-07 08:52:40 +02:00
|
|
|
index 60772b6d6fe171d7dd832cb132f7c56db9439bdb..451a2ea80c6262008be6b075c122c78a5b435c75 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2021-07-07 08:52:40 +02:00
|
|
|
@@ -1483,13 +1483,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
2021-06-11 14:02:28 +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) {
|
2021-06-12 08:02:49 +02:00
|
|
|
- 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
|
2021-06-11 14:02:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-12 08:02:49 +02:00
|
|
|
- if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= 30) {
|
|
|
|
+ if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= THRESHOLD) { // Paper
|
|
|
|
this.lastLimitedPacket = timestamp;
|
|
|
|
this.limitedPackets = 0;
|
2021-06-11 14:02:28 +02:00
|
|
|
return true;
|