From c60466a90443d2e4a6d48d45bcfc57dee2f5dd89 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Tue, 18 Jun 2024 15:37:07 -0700 Subject: [PATCH] group new regexes better --- .../chat/modules/blockers/KarmaRemover.java | 2 +- .../hytils/handlers/language/LanguageData.java | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java index 5229d77..2119447 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java @@ -28,7 +28,7 @@ public class KarmaRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if (getLanguage().cancelKarmaMessagesRegex.matcher(message).matches()) { + if (getLanguage().chatCleanerKarmaMessagesRegex.matcher(message).matches()) { event.setCanceled(true); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java index 54a1c0a..c15501b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -34,11 +34,10 @@ public class LanguageData { */ private String autoQueuePrefixGlobal = "^(?:You died! .+|YOU DIED! .+|You have been eliminated!|You won! .+|YOU WON! .+)$"; - private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$"; - private String autoFriendPattern = "Friend request from (?.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*"; private String autoAfkReplyPattern = "^From (\\[.+?] )?(.+?): .+$"; + private String chatCleanerKarmaMessages = "^\\+(?\\d)+ Karma!$"; private String chatCleanerJoin = "(?:sled into|slid into|joined|spooked into) the lobby"; private String chatCleanerTicketAnnouncer = "^(?(?!You )\\w{1,16} )has found an? .+$"; private String chatCleanerSoulWellFind = "^.+ has found .+ in the Soul Well!$"; @@ -100,8 +99,8 @@ public class LanguageData { private String hypixelLevelUp = "You are now Hypixel Level (?\\d+)!"; + private String casualGameEnd = "^(?:MINOR EVENT! .+ in .+ ended|DRAGON EGG OVER! Earned [\\d,]+XP [\\d,]g clicking the egg \\d+ times|GIANT CAKE! Event ended! Cake's gone!|PIT EVENT ENDED: .+ \\[INFO\\])$"; private String cancelGgMessages = "^(?:.* )?(?:\\[.+] )?\\w{1,16}(?: .+)?: (?:❤|gg|GG|gf|Good Game|Good Fight|Good Round! :D|Have a good day!|<3|AutoGG By Sk1er!|AutoGG By Hytils Reborn!|gf|Good Fight|Good Round|:D|Well Played!|wp)$"; - private String cancelKarmaMessages = "^\\+(?\\d)+ Karma!$"; private String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)"; public String autoChatReportConfirm = "Please type /report confirm to log your report for staff review."; @@ -118,11 +117,10 @@ public class LanguageData { */ public Pattern autoQueuePrefixGlobalRegex; - public Pattern casualGameEndRegex; - public Pattern autoFriendPatternRegex; public Pattern autoAfkReplyPatternRegex; + public Pattern chatCleanerKarmaMessagesRegex; public Pattern chatCleanerJoinRegex; public Pattern chatCleanerTicketAnnouncerRegex; public Pattern chatCleanerSoulWellFindRegex; @@ -170,8 +168,8 @@ public class LanguageData { public Pattern hypixelLevelUpRegex; + public Pattern casualGameEndRegex; public Pattern cancelGgMessagesRegex; - public Pattern cancelKarmaMessagesRegex; public Pattern cancelGlMessagesRegex; public Pattern gameBossbarAdvertisementRegex; @@ -185,11 +183,10 @@ public void initialize() { autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal); - casualGameEndRegex = Pattern.compile(casualGameEnd); - autoFriendPatternRegex = Pattern.compile(autoFriendPattern); autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern); + chatCleanerKarmaMessagesRegex = Pattern.compile(chatCleanerKarmaMessages); chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin); chatCleanerTicketAnnouncerRegex = Pattern.compile(chatCleanerTicketAnnouncer); chatCleanerSoulWellFindRegex = Pattern.compile(chatCleanerSoulWellFind); @@ -237,8 +234,8 @@ public void initialize() { hypixelLevelUpRegex = Pattern.compile(hypixelLevelUp); + casualGameEndRegex = Pattern.compile(casualGameEnd); cancelGgMessagesRegex = Pattern.compile(cancelGgMessages); - cancelKarmaMessagesRegex = Pattern.compile(cancelKarmaMessages); cancelGlMessagesRegex = Pattern.compile(cancelGlMessages, Pattern.CASE_INSENSITIVE); gameBossbarAdvertisementRegex = Pattern.compile(gameBossbarAdvertisement);