diff --git a/src/main/java/org/polyfrost/hytils/HytilsReborn.java b/src/main/java/org/polyfrost/hytils/HytilsReborn.java index a393fd4..30acba3 100644 --- a/src/main/java/org/polyfrost/hytils/HytilsReborn.java +++ b/src/main/java/org/polyfrost/hytils/HytilsReborn.java @@ -30,6 +30,7 @@ import org.polyfrost.hytils.handlers.chat.ChatHandler; import org.polyfrost.hytils.handlers.chat.modules.events.AchievementEvent; import org.polyfrost.hytils.handlers.chat.modules.events.LevelupEvent; +import org.polyfrost.hytils.handlers.chat.modules.triggers.AutoGG; import org.polyfrost.hytils.handlers.chat.modules.triggers.AutoQueue; import org.polyfrost.hytils.handlers.chat.modules.triggers.SilentRemoval; import org.polyfrost.hytils.handlers.game.dropper.DropperHurtSound; @@ -172,6 +173,7 @@ private void registerHandlers() { eventBus.register(hardcoreStatus); eventBus.register(new AchievementEvent()); eventBus.register(new LevelupEvent()); + EventManager.INSTANCE.register(AutoGG.INSTANCE); // lobby eventBus.register(new ArmorStandHider()); diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 4338751..096f0a3 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -221,13 +221,6 @@ public class HytilsConfig extends Config { ) public static boolean autoFriend; - @Switch( - name = "Auto Chat Report Confirm", - description = "Automatically confirms chat reports.", - category = "Chat", subcategory = "Automatic" - ) - public static boolean autoChatReportConfirm; - @Switch( name = "Auto Party Warp Confirm", description = "Automatically confirms party warps.", 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 065212b..cc7d9d4 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java @@ -96,8 +96,6 @@ public ChatHandler() { this.registerModule(new WhitePrivateMessages()); // Triggers - this.registerModule(new AutoChatReportConfirm()); - this.registerModule(new AutoChatReportConfirm()); this.registerModule(new AutoChatSwapper()); this.registerModule(new AutoFriend()); this.registerModule(new AutoGG()); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java deleted file mode 100644 index 0260e6e..0000000 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.utils.Multithreading; -import org.polyfrost.hytils.config.HytilsConfig; -import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; -import net.minecraft.client.Minecraft; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.TimeUnit; - -public class AutoChatReportConfirm implements ChatReceiveModule { - @Override - public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - if (event.message.getUnformattedText().equals(getLanguage().autoChatReportConfirm)) { - event.setCanceled(true); - Multithreading.schedule(() -> Minecraft.getMinecraft().thePlayer.sendChatMessage("/report confirm"), 1, TimeUnit.SECONDS); - } - } - - @Override - public boolean isEnabled() { - return HytilsConfig.autoChatReportConfirm; - } - - @Override - public int getPriority() { - return 3; - } -} 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 d40b541..a9a5c55 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 @@ -18,6 +18,8 @@ package org.polyfrost.hytils.handlers.chat.modules.triggers; +import cc.polyfrost.oneconfig.events.event.WorldLoadEvent; +import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import cc.polyfrost.oneconfig.libs.universal.UChat; import cc.polyfrost.oneconfig.utils.Multithreading; import net.minecraft.util.EnumChatFormatting; @@ -32,10 +34,13 @@ import java.util.regex.Pattern; public class AutoGG implements ChatReceiveModule { + public static AutoGG INSTANCE = new AutoGG(); + private int matchesFound = 0; + @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if (!hasGameEnded(message)) return; + if (!hasGameEnded(message) || matchesFound > 1) return; Multithreading.schedule(() -> UChat.say("/ac " + HytilsConfig.ggMessage), (long) (HytilsConfig.autoGGFirstPhraseDelay * 1000), TimeUnit.MILLISECONDS); if (HytilsConfig.autoGGSecondMessage) Multithreading.schedule(() -> UChat.say("/ac " + HytilsConfig.ggMessage2), (long) ((HytilsConfig.autoGGSecondPhraseDelay + HytilsConfig.autoGGFirstPhraseDelay) * 1000), TimeUnit.MILLISECONDS); @@ -45,6 +50,7 @@ private boolean hasGameEnded(String message) { if (!PatternHandler.INSTANCE.gameEnd.isEmpty()) { for (Pattern triggers : PatternHandler.INSTANCE.gameEnd) { if (triggers.matcher(message).matches()) { + matchesFound++; return true; } } @@ -54,6 +60,11 @@ private boolean hasGameEnded(String message) { return getLanguage().casualGameEndRegex.matcher(message).matches(); } + @Subscribe + public void onWorldLoad(WorldLoadEvent event) { + matchesFound = 0; + } + @Override public boolean isEnabled() { return HytilsConfig.autoGG && (!HytilsReborn.INSTANCE.isSk1erAutoGG || !club.sk1er.mods.autogg.AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()); // If Sk1er's AutoGG is enabled, we don't want to interfere with it.