diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ConfirmationPromptHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ConfirmationPromptHelper.java index 5ad6d9381f..00eb41f80a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ConfirmationPromptHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ConfirmationPromptHelper.java @@ -25,11 +25,13 @@ public class ConfirmationPromptHelper { public static void init() { ClientReceiveMessageEvents.GAME.register(ConfirmationPromptHelper::onMessage); ScreenEvents.AFTER_INIT.register((_client, screen, _scaledWidth, _scaledHeight) -> { - if (Utils.isOnSkyblock() && screen instanceof ChatScreen && SkyblockerConfigManager.get().chat.confirmationPromptHelper && command != null && commandFoundAt + 60_000 > System.currentTimeMillis()) { + if (Utils.isOnSkyblock() && screen instanceof ChatScreen && SkyblockerConfigManager.get().chat.confirmationPromptHelper && hasCommand()) { ScreenMouseEvents.beforeMouseClick(screen).register((_screen1, _mouseX, _mouseY, _button) -> { - MessageScheduler.INSTANCE.sendMessageAfterCooldown(command); - command = null; - commandFoundAt = 0; + if (hasCommand()) { + MessageScheduler.INSTANCE.sendMessageAfterCooldown(command); + command = null; + commandFoundAt = 0; + } }); } }); @@ -39,6 +41,10 @@ public static void init() { }); } + private static boolean hasCommand() { + return command != null && commandFoundAt + 60_000 > System.currentTimeMillis(); + } + private static void onMessage(Text message, boolean overlay) { if (Utils.isOnSkyblock() && !overlay && SkyblockerConfigManager.get().chat.confirmationPromptHelper && message.getString().contains("[YES]")) { Optional confirmationCommand = message.visit((style, asString) -> {