From 5b3ba86c765c86961091c3c02f98fbd3efa39310 Mon Sep 17 00:00:00 2001 From: RayzsYT <51991564+RayzsYT@users.noreply.github.com> Date: Sun, 14 Jul 2024 03:30:26 +0200 Subject: [PATCH] Fix Spam Issue --- src/main/java/de/rayzs/pat/utils/CommandsCache.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/rayzs/pat/utils/CommandsCache.java b/src/main/java/de/rayzs/pat/utils/CommandsCache.java index d1ef3386..a7c27f27 100644 --- a/src/main/java/de/rayzs/pat/utils/CommandsCache.java +++ b/src/main/java/de/rayzs/pat/utils/CommandsCache.java @@ -9,6 +9,7 @@ public class CommandsCache { private List filteredCommands = null, allCommands = null; private boolean useList = true; + private boolean change = false; public CommandsCache reverse() { this.useList = !useList; @@ -16,6 +17,7 @@ public class CommandsCache { } public void handleCommands(List commands) { + if(change) return; if(!isOutdated(commands)) return; filteredCommands = new LinkedList<>(); @@ -35,9 +37,12 @@ public class CommandsCache { if (!Storage.Blacklist.isBlocked(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, false)) filteredCommands.add(command); } + + change = true; } public void handleCommands(List commands, String server) { + if(change) return; if(!isOutdated(commands)) return; server = server.toLowerCase(); @@ -58,6 +63,7 @@ public class CommandsCache { if(!Storage.Blacklist.isBlocked(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, server)) filteredCommands.add(command); + change = true; } } @@ -93,11 +99,16 @@ public class CommandsCache { return playerCommands; } + public void updateChangeState() { + change = false; + } + public void reset() { + if(change) return; filteredCommands = null; } public boolean isOutdated(List commands) { - return filteredCommands == null || allCommands == null || !Arrays.equals(commands.toArray(), allCommands.toArray()); + return filteredCommands == null || !ArrayUtils.compareStringArrays(commands, allCommands); } }