From e8388437b616f27f5bd8c55dfe9a4719e4e83227 Mon Sep 17 00:00:00 2001 From: Cheese Date: Tue, 13 Oct 2015 11:58:14 +1100 Subject: [PATCH] botspam now checks for chat as well --- .../mineplex/core/botspam/BotSpamManager.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java index a977b3685..15896b339 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java @@ -5,6 +5,8 @@ import java.util.List; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -53,6 +55,24 @@ public class BotSpamManager extends MiniPlugin } } } + + @EventHandler(priority = EventPriority.LOWEST) + public void onChat(AsyncPlayerChatEvent event) + { + // Ignore messages sent to staff members + if (_clientManager.hasRank(event.getPlayer(), Rank.HELPER)) + return; + + for (SpamText spamText : _spam) + { + if (spamText.isEnabled() && spamText.isSpam(event.getMessage())) + { + punishBot(event.getPlayer(), spamText); + event.setCancelled(true); + return; + } + } + } public void punishBot(Player player, final SpamText botText) {