diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 59bb780..07165a2 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -171,6 +171,20 @@ public class HytilsConfig extends Config { ) public static boolean autoPartyWarpConfirm; + @Switch( + name = "Auto Reply when AFK", + description = "Automatically sends a reply of your choosing when you are AFK in Limbo.", + category = "Chat", subcategory = "Automatic" + ) + public static boolean autoReplyAfk; + + @Text( + name = "Auto Reply Message", + category = "Chat", subcategory = "Automatic", + size = 2 + ) + public static String autoReplyAfkMessage = "Hey, I am currently AFK!"; + @Switch( name = "Game Status Restyle", description = "Replace common game status messages with a new style.\n§eExamples:\n§a§l+ §bSteve §e(§b1§e/§b12§e)\n§c§l- §bSteve§r\n§e§l* §aGame starts in §b§l5 §aseconds.", diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java index 3b6b270..e4dde47 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java @@ -94,6 +94,7 @@ public ChatHandler() { this.registerModule(new WhitePrivateMessages()); // Triggers + this.registerModule(new AutoAfkReply()); this.registerModule(new AutoChatReportConfirm()); this.registerModule(new AutoChatReportConfirm()); this.registerModule(new AutoChatSwapper()); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java new file mode 100644 index 0000000..e226d8f --- /dev/null +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java @@ -0,0 +1,50 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.polyfrost.hytils.handlers.chat.modules.triggers; + +import cc.polyfrost.oneconfig.libs.universal.UChat; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import org.jetbrains.annotations.NotNull; +import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; + +import java.util.regex.Matcher; + +public class AutoAfkReply implements ChatReceiveModule { + @Override + public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { + if (getLocraw() != null && !getLocraw().getServerId().equals("limbo")) return; + String message = event.message.getFormattedText(); + Matcher matcher = getLanguage().autoAfkReplyPatternRegex.matcher(message); + if (matcher.find(0)) { + UChat.say("/r " + HytilsConfig.autoReplyAfkMessage); + } + } + + @Override + public boolean isEnabled() { + return HytilsConfig.autoReplyAfk; + } + + @Override + public int getPriority() { + return -1; + } + +} 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 986df72..05a2072 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -35,6 +35,7 @@ public class LanguageData { private String autoQueuePrefixGlobal = "^(?:You died! .+|YOU DIED! .+|You have been eliminated!|You won! .+|YOU WON! .+)$"; private String autoFriendPattern = "Friend request from (?.+)\\[ACCEPT] - \\[DENY] - \\[IGNORE].*"; + private String autoAfkReplyPattern = "^§dFrom (?.+): §r(?§7.*)(?:§r)?$"; private String chatCleanerJoin = "(?:sled into|slid into|joined|spooked into) the lobby"; private String chatCleanerTicketAnnouncer = "^(?(?!You )\\w{1,16} )has found an? .+$"; @@ -114,6 +115,7 @@ public class LanguageData { public Pattern autoQueuePrefixGlobalRegex; public Pattern autoFriendPatternRegex; + public Pattern autoAfkReplyPatternRegex; public Pattern chatCleanerJoinRegex; public Pattern chatCleanerTicketAnnouncerRegex; @@ -176,6 +178,7 @@ public void initialize() { autoQueuePrefixGlobalRegex = Pattern.compile(autoQueuePrefixGlobal); autoFriendPatternRegex = Pattern.compile(autoFriendPattern); + autoAfkReplyPatternRegex = Pattern.compile(autoAfkReplyPattern); chatCleanerJoinRegex = Pattern.compile(chatCleanerJoin); chatCleanerTicketAnnouncerRegex = Pattern.compile(chatCleanerTicketAnnouncer);