Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
AzureAaron committed Dec 21, 2024
1 parent 50ca3b0 commit 20644ca
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}
});
Expand All @@ -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<String> confirmationCommand = message.visit((style, asString) -> {
Expand Down

0 comments on commit 20644ca

Please sign in to comment.