3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-Server-Patches/0167-Configurable-packet-in-spam-threshold.patch

49 Zeilen
2.3 KiB
Diff

2016-10-23 08:32:04 +02:00
From 0e7be255474cb7e18c4eecdfd729cb55428bd0d7 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
index 91546b6..211b88a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -225,4 +225,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
2016-10-23 08:32:04 +02:00
index 5cbced0..d82eec9 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
2016-10-23 08:32:04 +02:00
@@ -868,13 +868,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) {
+ if (lastLimitedPacket != -1 && timestamp - lastLimitedPacket < THRESHOLD && limitedPackets++ >= 4) { // Paper
return false;
}
- if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= 30) {
+ if (lastLimitedPacket == -1 || timestamp - lastLimitedPacket >= THRESHOLD) { // Paper
lastLimitedPacket = timestamp;
limitedPackets = 0;
return true;
--
2016-10-21 22:28:44 +02:00
2.9.3
2016-09-11 21:55:02 +02:00