Skip to content

Commit

Permalink
fix autogg, casual autogg, and antigg
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jun 18, 2024
1 parent e10b829 commit 688b7f3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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)
Expand All @@ -58,7 +58,9 @@ private boolean hasGameEnded(String message) {
}
}
}
return false;

// TODO: UNTESTED!
return getLanguage().casualGameEndRegex.matcher(message).matches();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (?<name>.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*";
private String autoAfkReplyPattern = "^From (\\[.+?] )?(.+?): .+$";

Expand Down Expand Up @@ -98,7 +100,7 @@ public class LanguageData {

private String hypixelLevelUp = "You are now Hypixel Level (?<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 = "^\\+(?<karma>\\d)+ Karma!$";
private String cancelGlMessages = "(?!.+: )(gl|glhf|good luck|have a good game|autogl by sk1er)";

Expand All @@ -116,6 +118,8 @@ public class LanguageData {
*/
public Pattern autoQueuePrefixGlobalRegex;

public Pattern casualGameEndRegex;

public Pattern autoFriendPatternRegex;
public Pattern autoAfkReplyPatternRegex;

Expand Down Expand Up @@ -181,6 +185,8 @@ public void initialize() {

autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal);

casualGameEndRegex = Pattern.compile(casualGameEnd);

autoFriendPatternRegex = Pattern.compile(autoFriendPattern);
autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern);

Expand Down

0 comments on commit 688b7f3

Please sign in to comment.