Make UseItem rate limiting stricter, configurable
This commit is contained in:
parent
5626ad5f58
commit
2e880e7676
|
@ -1,4 +1,4 @@
|
|||
From 3dabbf24d9e169631ff0f11df707e0623c4d2cc4 Mon Sep 17 00:00:00 2001
|
||||
From f41fd8808accbe9c7771647d3beddc54fc5e7036 Mon Sep 17 00:00:00 2001
|
||||
From: Steve Anton <anxuiz.nx@gmail.com>
|
||||
Date: Mon, 29 Feb 2016 18:13:58 -0600
|
||||
Subject: [PATCH] Add PlayerInitialSpawnEvent
|
||||
|
@ -55,5 +55,5 @@ index 0000000..d1d6f33
|
|||
+ }
|
||||
+}
|
||||
--
|
||||
2.8.0
|
||||
2.10.0.windows.1
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From aca5c5298ce7fca0a9b6d8c8240f94d1a09de085 Mon Sep 17 00:00:00 2001
|
||||
From 90e6868ac669e61bc3b0e176b452181dcf078c2c Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 29 Feb 2016 19:45:21 -0600
|
||||
Subject: [PATCH] Automatically disable plugins that fail to load
|
||||
|
@ -20,5 +20,5 @@ index 759c461..d8b9c24 100644
|
|||
|
||||
// Perhaps abort here, rather than continue going, but as it stands,
|
||||
--
|
||||
2.9.3
|
||||
2.10.0.windows.1
|
||||
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
From 7d5d1e68148e2a526c03aeadffcda93ff8787394 Mon Sep 17 00:00:00 2001
|
||||
From 49a2546fd62526b61f8dc3b7e88093a5cbcb709a Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Sat, 10 Sep 2016 21:40:51 -0500
|
||||
Subject: [PATCH] Rate limit PacketPlayInUseItem
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index f40440f..f1973e3 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -225,4 +225,9 @@ public class PaperConfig {
|
||||
private static void bungeeOnlineMode() {
|
||||
bungeeOnlineMode = getBoolean("settings.bungee-online-mode", true);
|
||||
}
|
||||
+
|
||||
+ public static int playInUseItemThreshold = 300;
|
||||
+ private static void playInUseItemThreshold() {
|
||||
+ playInUseItemThreshold = getInt("settings.play-in-use-item-spam-threshold", 300);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayInUseItem.java b/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
|
||||
index 82e09c1..88ac278 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
|
||||
|
@ -33,29 +47,30 @@ index 82e09c1..88ac278 100644
|
|||
|
||||
public void a(PacketListenerPlayIn packetlistenerplayin) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 3d04119..a299f4f 100644
|
||||
index 3d04119..ab30d39 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -865,6 +865,10 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
@@ -865,6 +865,11 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
+ // Paper start - Rate limit UseItem as well, copied from Spigot implementation below in BlockPlace
|
||||
+ private long lastPlaceUse = -1;
|
||||
+ private int packetsUse = 0;
|
||||
+ private static final int THRESHOLD = com.destroystokyo.paper.PaperConfig.playInUseItemThreshold;
|
||||
+ // Paper end
|
||||
public void a(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
|
||||
if (this.player.cj()) return; // CraftBukkit
|
||||
@@ -875,6 +879,16 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
@@ -875,6 +880,16 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
EnumDirection enumdirection = packetplayinuseitem.b();
|
||||
|
||||
this.player.resetIdleTimer();
|
||||
+
|
||||
+ // Paper start - Rate limit UseItem as well, copied from Spigot implementation below in BlockPlace
|
||||
+ if (lastPlaceUse != -1 && packetplayinuseitem.timestamp - lastPlaceUse < 30 && packetsUse++ >= 4) {
|
||||
+ if (lastPlaceUse != -1 && packetplayinuseitem.timestamp - lastPlaceUse < THRESHOLD && packetsUse++ >= 4) {
|
||||
+ return;
|
||||
+ } else if (packetplayinuseitem.timestamp - lastPlaceUse >= 30 || lastPlaceUse == -1) {
|
||||
+ } else if (packetplayinuseitem.timestamp - lastPlaceUse >= THRESHOLD || lastPlaceUse == -1) {
|
||||
+ lastPlaceUse = packetplayinuseitem.timestamp;
|
||||
+ packetsUse = 0;
|
||||
+ }
|
||||
|
|
Loading…
Reference in New Issue