0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/spigot.git synced 2024-11-24 12:56:24 +00:00
spigot/CraftBukkit-Patches/0035-Spam-Filter-Exclusions.patch

81 lines
3.3 KiB
Diff

From 101c3080f395c69eab1ae6d93cc18b0497ad709a Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 8 Feb 2014 08:13:40 +0000
Subject: [PATCH] Spam Filter Exclusions
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index b217dc0529..824ad99cb2 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -1813,7 +1813,7 @@ public class PlayerConnection extends ServerCommonPacketListenerImpl implements
}
// CraftBukkit end
this.performUnsignedChatCommand(serverboundchatcommandpacket.command());
- this.detectRateSpam();
+ this.detectRateSpam("/" + serverboundchatcommandpacket.command()); // Spigot
}, true); // CraftBukkit - sync commands
}
@@ -1852,7 +1852,7 @@ public class PlayerConnection extends ServerCommonPacketListenerImpl implements
}
// CraftBukkit end
this.performSignedChatCommand(serverboundchatcommandsignedpacket, (LastSeenMessages) optional.get());
- this.detectRateSpam();
+ this.detectRateSpam("/" + serverboundchatcommandsignedpacket.command()); // Spigot
}, true); // CraftBukkit - sync commands
}
}
@@ -2146,11 +2146,20 @@ public class PlayerConnection extends ServerCommonPacketListenerImpl implements
}
// this.server.getPlayerList().broadcastChatMessage(playerchatmessage, this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) this.player));
// CraftBukkit end
- this.detectRateSpam();
+ this.detectRateSpam(s); // Spigot
}
- private void detectRateSpam() {
+ // Spigot start - spam exclusions
+ private void detectRateSpam(String s) {
// CraftBukkit start - replaced with thread safe throttle
+ for ( String exclude : org.spigotmc.SpigotConfig.spamExclusions )
+ {
+ if ( exclude != null && s.startsWith( exclude ) )
+ {
+ return;
+ }
+ }
+ // Spigot end
// this.chatSpamThrottler.increment();
if (!this.chatSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
// CraftBukkit end
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 5b7e17ee03..5565f1dd05 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -6,6 +6,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -284,4 +285,13 @@ public class SpigotConfig
{
playerShuffle = getInt( "settings.player-shuffle", 0 );
}
+
+ public static List<String> spamExclusions;
+ private static void spamExclusions()
+ {
+ spamExclusions = getList( "commands.spam-exclusions", Arrays.asList( new String[]
+ {
+ "/skill"
+ } ) );
+ }
}
--
2.47.0