Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
36f34f01c0
Upstream has released updates that appears 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: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
76 Zeilen
4.6 KiB
Diff
76 Zeilen
4.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/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
index 26ab855dcf38446a3d8577108bd16fdbb76126b2..adef07d4d521b4aaa6f3389b04aa27e29bec0229 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -287,4 +287,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/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index 8648845acb054e1e151e5376607e633b4154bbbd..6627d8402f784c16519adaabca967b8e1d365ddc 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -76,6 +76,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
// CraftBukkit start - multithreaded fields
|
|
private volatile int chatThrottle;
|
|
private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
|
|
+ private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
|
|
// CraftBukkit end
|
|
private int j;
|
|
private final Int2ShortMap k = new Int2ShortOpenHashMap();
|
|
@@ -207,6 +208,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
this.minecraftServer.getMethodProfiler().exit();
|
|
// CraftBukkit start
|
|
for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
|
|
+ if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable
|
|
/* Use thread-safe field access instead
|
|
if (this.chatThrottle > 0) {
|
|
--this.chatThrottle;
|
|
@@ -526,7 +528,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
public void a(PacketPlayInTabComplete packetplayintabcomplete) {
|
|
// PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async
|
|
// CraftBukkit start
|
|
- if (chatSpamField.addAndGet(this, 1) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
|
|
+ if (tabSpamLimiter.addAndGet(com.destroystokyo.paper.PaperConfig.tabSpamIncrement) > com.destroystokyo.paper.PaperConfig.tabSpamLimit && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { // Paper start - split and make configurable
|
|
minecraftServer.scheduleOnMain(() -> this.disconnect(new ChatMessage("disconnect.spam", new Object[0]))); // Paper
|
|
return;
|
|
}
|