aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2025-02-12 23:06:09 -0500
committerAaron <51387595+AzureAaron@users.noreply.github.com>2025-02-12 23:06:09 -0500
commit20645264c5d0ccbb0fcf856068b89edb20746d79 (patch)
tree574c4df5a73d79e73fded975a08c17169c53bf6a /src/main/java/de
parentd9f44d203ab5cbeee548eefa4570ade9fcc90f7d (diff)
downloadSkyblocker-20645264c5d0ccbb0fcf856068b89edb20746d79.tar.gz
Skyblocker-20645264c5d0ccbb0fcf856068b89edb20746d79.tar.bz2
Skyblocker-20645264c5d0ccbb0fcf856068b89edb20746d79.zip
Ignore expired key pairs
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/ApiAuthentication.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/ApiAuthentication.java b/src/main/java/de/hysky/skyblocker/utils/ApiAuthentication.java
index ca16bd4e..197a5954 100644
--- a/src/main/java/de/hysky/skyblocker/utils/ApiAuthentication.java
+++ b/src/main/java/de/hysky/skyblocker/utils/ApiAuthentication.java
@@ -75,7 +75,9 @@ public class ApiAuthentication {
ProfileKeys profileKeys = ((MinecraftClientAccessor) CLIENT).getProfileKeys();
//The fetching runs async in ProfileKeysImpl#getKeyPair
profileKeys.fetchKeyPair().thenAcceptAsync(playerKeypairOpt -> {
- if (playerKeypairOpt.isPresent()) {
+ boolean expired = playerKeypairOpt.map(keyPair -> keyPair.publicKey().data().isExpired()).orElse(false);
+
+ if (playerKeypairOpt.isPresent() && !expired) {
PlayerKeyPair playerKeyPair = playerKeypairOpt.get();
//The key header and footer can be sent but that doesn't matter to the server
@@ -99,8 +101,8 @@ public class ApiAuthentication {
logErrorAndScheduleRetry(Text.translatable("skyblocker.api.token.authFailure"), 60 * 20, "[Skyblocker Api Auth] Failed to refresh the api token! Some features might not work :(", e);
}
} else {
- //The Minecraft Services API is probably down so we will retry in 5 minutes, either that or your access token has expired (game open for 24h) and you need to restart.
- logErrorAndScheduleRetry(Text.translatable("skyblocker.api.token.noProfileKeys"), 300 * 20, "[Skyblocker Api Auth] Failed to fetch profile keys! Some features may not work temporarily :( (Has your game been open for more than 24 hours? If so restart.)");
+ //The Minecraft Services API is probably down so we will retry in 5 minutes, either that or if your access token has expired (game open for 24h) you will need to restart.
+ logErrorAndScheduleRetry(Text.translatable("skyblocker.api.token.noProfileKeys"), expired ? -1 : 300 * 20, "[Skyblocker Api Auth] Failed to fetch profile keys! Some features may not work temporarily :( (Has your game been open for more than 24 hours? If so restart.)");
}
}).exceptionally(throwable -> {
//Try again in 1 minute
@@ -140,7 +142,7 @@ public class ApiAuthentication {
private static void logErrorAndScheduleRetry(Text warningMessage, int retryAfter, String logMessage, Object... logArgs) {
LOGGER.error(logMessage, logArgs);
- Scheduler.INSTANCE.schedule(ApiAuthentication::updateToken, retryAfter, true);
+ if (retryAfter != -1) Scheduler.INSTANCE.schedule(ApiAuthentication::updateToken, retryAfter, true);
if (CLIENT.player != null && !sentWarningOnce) {
CLIENT.player.sendMessage(Constants.PREFIX.get().append(warningMessage), false);