diff --git a/Spigot-Server-Patches/Configurable-packet-in-spam-threshold.patch b/Spigot-Server-Patches/Configurable-packet-in-spam-threshold.patch new file mode 100644 index 0000000000..49bdbd3971 --- /dev/null +++ b/Spigot-Server-Patches/Configurable-packet-in-spam-threshold.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Zach Brown <1254957+zachbr@users.noreply.github.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 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 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 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + // 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; +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/Paper-config-files.patch b/Spigot-Server-Patches/Paper-config-files.patch index 5326c53302..0ba8c5678d 100644 --- a/Spigot-Server-Patches/Paper-config-files.patch +++ b/Spigot-Server-Patches/Paper-config-files.patch @@ -66,8 +66,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + commands = new HashMap(); + -+ version = getInt("config-version", 10); -+ set("config-version", 10); ++ version = getInt("config-version", 11); ++ set("config-version", 11); + readConfig(PaperConfig.class, null); + } + diff --git a/Spigot-Server-Patches/Rate-limit-PacketPlayInUseItem.patch b/Spigot-Server-Patches/Rate-limit-PacketPlayInUseItem.patch deleted file mode 100644 index 5a98d6fd15..0000000000 --- a/Spigot-Server-Patches/Rate-limit-PacketPlayInUseItem.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zach Brown <1254957+zachbr@users.noreply.github.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 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 -+++ b/src/main/java/net/minecraft/server/PacketPlayInUseItem.java -@@ -0,0 +0,0 @@ public class PacketPlayInUseItem implements Packet { - private float d; - private float e; - private float f; -+ public long timestamp; // Paper - Used for rate limiting - - public PacketPlayInUseItem() {} - -@@ -0,0 +0,0 @@ public class PacketPlayInUseItem implements Packet { - this.d = (float) packetdataserializer.readUnsignedByte() / 16.0F; - this.e = (float) packetdataserializer.readUnsignedByte() / 16.0F; - this.f = (float) packetdataserializer.readUnsignedByte() / 16.0F; -+ this.timestamp = System.currentTimeMillis(); // Paper - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { -@@ -0,0 +0,0 @@ public class PacketPlayInUseItem implements Packet { - packetdataserializer.writeByte((int) (this.d * 16.0F)); - packetdataserializer.writeByte((int) (this.e * 16.0F)); - packetdataserializer.writeByte((int) (this.f * 16.0F)); -+ this.timestamp = System.currentTimeMillis(); // Paper - } - - 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/PlayerConnection.java -+++ b/src/main/java/net/minecraft/server/PlayerConnection.java -@@ -0,0 +0,0 @@ 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 -@@ -0,0 +0,0 @@ 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 < THRESHOLD && packetsUse++ >= 4) { -+ return; -+ } else if (packetplayinuseitem.timestamp - lastPlaceUse >= THRESHOLD || lastPlaceUse == -1) { -+ lastPlaceUse = packetplayinuseitem.timestamp; -+ packetsUse = 0; -+ } -+ // Paper end -+ - if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) { - ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())}); - --- \ No newline at end of file diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 2c07a45038..c4d6dd50de 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -68,7 +68,6 @@ import NBTTagCompound import NBTTagList import PersistentScoreboard import PacketPlayInUseEntity -import PacketPlayInUseItem import PacketPlayOutPlayerListHeaderFooter import PacketPlayOutScoreboardTeam import PacketPlayOutTitle diff --git a/work/CraftBukkit b/work/CraftBukkit index 8788b79a48..75a8885d1f 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 8788b79a48a324130c400658c13f8176787d742a +Subproject commit 75a8885d1fbb8f1bb38ef3d6a0f03598893c01ed diff --git a/work/Spigot b/work/Spigot index 80fccb7271..570526c2b4 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 80fccb72715ba063c2ec0e038bf7ddb2599849ad +Subproject commit 570526c2b4840753183aa81995ea81008238eeb2