mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
d385af0e01
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 0a4b84d6 SPIGOT-7003: Add missing PlayerAnimationType 830db7d5 SPIGOT-5984: Add non deprecated / magic value way to set pixel in MapCanvas 20caf8ff PR-754: Add DamageCause.SONIC_BOOM CraftBukkit Changes: 576a03704 SPIGOT-7003: Add missing PlayerAnimationType 0dcc5fdd0 SPIGOT-5984: Add non deprecated / magic value way to set pixel in MapCanvas d75aacb43 Update Netty version 3b34c6bea SPIGOT-7044: Modified RandomSourceWrapper to ensure random is not null before setting seed 4b60bfd18 PR-1059: Add DamageCause.SONIC_BOOM
53 lines
3.6 KiB
Diff
53 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
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/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 4b99de786be5fbefb94a5484868b897ab0f86a27..e0215f34f5f82cbd3a67f58a8a177fc886ccc72c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -246,6 +246,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;
|
|
@@ -385,6 +386,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;
|
|
@@ -744,7 +746,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(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable
|
|
server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]))); // Paper
|
|
return;
|
|
}
|