mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Make UseItem rate limiting stricter, configurable
This commit is contained in:
parent
5ba385dd4c
commit
4bf0ca21fe
@ -4,6 +4,20 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayInUseItem.java
|
||||
@ -43,6 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // 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());
|
||||
@ -53,9 +68,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
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
Block a user