diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index c3b6da8..4d3b11a 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -176,7 +176,7 @@ public class HytilsConfig extends Config { name = "Auto GG Second Message", description = "Send a secondary message sent after the first GG message.", category = "Chat", subcategory = "Automatic", - options = {"Have a good day!", "<3", "AutoGG By Hytils!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"} + options = {"Have a good day!", "<3", "AutoGG By Hytils Reborn!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"} ) public static int autoGGMessage2 = 0; @@ -400,7 +400,7 @@ public class HytilsConfig extends Config { public static boolean preventShoutingOnCooldown = true; @Switch( - name = "Hide Karma Messages", + name = "Remove Karma Messages", description = "Remove Karma messages from the chat.", category = "Chat", subcategory = "Toggles" ) diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java index fe995a8..80af2b7 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGG.java @@ -18,8 +18,6 @@ package org.polyfrost.hytils.handlers.chat.modules.blockers; -import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; -import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; @@ -29,8 +27,7 @@ public class AntiGG implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().toLowerCase()); - if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase())) || (LocrawUtil.INSTANCE.getLocrawInfo() != null && !LocrawUtil.INSTANCE.isInGame())) return; + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); if (getLanguage().cancelGgMessagesRegex.matcher(message).matches()) { event.setCanceled(true); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java index f2ff72f..b314858 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java @@ -32,7 +32,7 @@ public class AutoGG implements ChatReceiveModule { private static final String[] ggMessagesOne = {"gg", "GG", "gf", "Good Game", "Good Fight", "Good Round! :D"}; - private static final String[] ggMessagesTwo = {"Have a good day!", "<3", "AutoGG By Hytils!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"}; + private static final String[] ggMessagesTwo = {"Have a good day!", "<3", "AutoGG By Hytils Reborn!", "gf", "Good Fight", "Good Round", ":D", "Well played!", "wp"}; private static String getGGMessageOne() { return ggMessagesOne[HytilsConfig.autoGGMessage]; @@ -43,7 +43,7 @@ private static String getGGMessageTwo() { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()).trim(); + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); if (!hasGameEnded(message)) return; Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageOne()), HytilsConfig.autoGGFirstPhraseDelay, TimeUnit.SECONDS); if (HytilsConfig.autoGGSecondMessage) @@ -58,7 +58,9 @@ private boolean hasGameEnded(String message) { } } } - return false; + + // TODO: UNTESTED! + return getLanguage().casualGameEndRegex.matcher(message).matches(); } @Override 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 079acca..54a1c0a 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -34,6 +34,8 @@ 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 (\\[.+?] )?(.+?): .+$"; @@ -98,7 +100,7 @@ public class LanguageData { private String hypixelLevelUp = "You are now Hypixel Level (?\\d+)!"; - 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|gf|Good Fight|Good Round|:D|Well Played!|wp)$"; + 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)"; @@ -116,6 +118,8 @@ public class LanguageData { */ public Pattern autoQueuePrefixGlobalRegex; + public Pattern casualGameEndRegex; + public Pattern autoFriendPatternRegex; public Pattern autoAfkReplyPatternRegex; @@ -181,6 +185,8 @@ public void initialize() { autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal); + casualGameEndRegex = Pattern.compile(casualGameEnd); + autoFriendPatternRegex = Pattern.compile(autoFriendPattern); autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern);