aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch
diff options
context:
space:
mode:
authorOwen <[email protected]>2022-03-11 15:13:46 -0500
committerGitHub <[email protected]>2022-03-11 21:13:46 +0100
commitea1efef1164aa7653119eb4be000749930e5b4da (patch)
tree104968ec407cf897e14388b14d2bf397844c8279 /patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch
parent1790528a6104c7c801e02a6f6d2ec0dda70e2af9 (diff)
downloadPaper-ea1efef1164aa7653119eb4be000749930e5b4da.tar.gz
Paper-ea1efef1164aa7653119eb4be000749930e5b4da.zip
Remove Patches (#7541)
Diffstat (limited to 'patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch')
-rw-r--r--patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch b/patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch
new file mode 100644
index 0000000000..ce1508b012
--- /dev/null
+++ b/patches/server/0235-Break-up-and-make-tab-spam-limits-configurable.patch
@@ -0,0 +1,75 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Shane Freeder <[email protected]>
+Date: Sun, 29 Jul 2018 05:02:15 +0100
+Subject: [PATCH] Break up and make tab spam limits configurable
+
+Due to the changes in 1.13, clients will send a tab completion request
+for all bukkit commands in order to factor in the lack of support for
+brigadier and provide backwards support in the API.
+
+Craftbukkit, however; has moved the chat spam limiter to also interact
+with the tab completion request, which while good for avoiding abuse,
+causes 1.13 clients to easilly be kicked from a server in bukkit due
+to this. Removing the spam limit could cause issues for servers, however,
+there is no way for servers to manipulate this without blindly cancelling
+kick events, which only causes additional complications. This also causes
+issues in that the tab spam limit and chat share the same field but different
+limits, meaning that a player having typed a long command may be kicked from
+the server.
+
+Splitting the field up and making it configurable allows for server owners
+to take the burden of this into their own hand without having to rely on
+plugins doing unsafe things.
+
+diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
+index 114a65963b65597ff915ec3a0d75bb78f33bd774..d654affc5565622cfabde9b838aa2b40e4e122bb 100644
+--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
++++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
+@@ -318,4 +318,18 @@ public class PaperConfig {
+ Bukkit.getLogger().log(Level.INFO, "Using Aikar's Alternative Luck Formula to apply Luck attribute to all loot pool calculations. See https://luckformula.emc.gs");
+ }
+ }
++
++ public static int tabSpamIncrement = 1;
++ public static int tabSpamLimit = 500;
++ private static void tabSpamLimiters() {
++ tabSpamIncrement = getInt("settings.spam-limiter.tab-spam-increment", tabSpamIncrement);
++ // Older versions used a smaller limit, which is too low for 1.13, we'll bump this up if default
++ if (version < 14) {
++ if (tabSpamIncrement == 10) {
++ set("settings.spam-limiter.tab-spam-increment", 2);
++ tabSpamIncrement = 2;
++ }
++ }
++ tabSpamLimit = getInt("settings.spam-limiter.tab-spam-limit", tabSpamLimit);
++ }
+ }
+diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index dced761b1f74de28a784dfcffed1bbc002e5a586..8a1da2b1e667420df97e432b5a5fd9563cadda91 100644
+--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -227,6 +227,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
+ private long keepAliveChallenge;
+ // CraftBukkit start - multithreaded fields
+ private final AtomicInteger chatSpamTickCount = new AtomicInteger();
++ private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
+ // CraftBukkit end
+ private int dropSpamTickCount;
+ private double firstGoodX;
+@@ -358,6 +359,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
+ this.server.getProfiler().pop();
+ // CraftBukkit start
+ for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ;
++ if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable
+ /* Use thread-safe field access instead
+ if (this.chatSpamTickCount > 0) {
+ --this.chatSpamTickCount;
+@@ -710,7 +712,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
+ public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) {
+ // PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async
+ // CraftBukkit start
+- if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
++ if (this.chatSpamTickCount.addAndGet(com.destroystokyo.paper.PaperConfig.tabSpamIncrement) > com.destroystokyo.paper.PaperConfig.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable
+ server.scheduleOnMain(() -> this.disconnect(new TranslatableComponent("disconnect.spam", new Object[0]))); // Paper
+ return;
+ }