Skip to content

Commit

Permalink
remove autochatreportconfirm and fix double autogg
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jul 27, 2024
1 parent b41e365 commit db95461
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 58 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/polyfrost/hytils/HytilsReborn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
}
}
Expand All @@ -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.
Expand Down

0 comments on commit db95461

Please sign in to comment.