diff --git a/src/main/java/net/raphimc/minecraftauth/step/AbstractStep.java b/src/main/java/net/raphimc/minecraftauth/step/AbstractStep.java index 552464c..c631703 100644 --- a/src/main/java/net/raphimc/minecraftauth/step/AbstractStep.java +++ b/src/main/java/net/raphimc/minecraftauth/step/AbstractStep.java @@ -86,21 +86,21 @@ public abstract static class StepResult
> {
protected abstract P prevResult();
/**
- * Checks if this result is expired.
+ * Checks if this or any previous result is expired.
* Results that have no expire time returned by their API are never considered expired.
* If you want to minimize the amount of HTTP requests, you should only call {@link AbstractStep#refresh} if this method returns true.
* For certain use cases, like joining a Minecraft server, you want to make sure that the data is up-to-date, even if it is not expired yet. See {@link StepResult#isExpiredOrOutdated}.
*
- * @return true if this result is expired
+ * @return true if this or any previous result is expired
*/
public abstract boolean isExpired();
/**
- * Checks if this result is expired or potentially outdated.
+ * Checks if this or any previous result is expired or potentially outdated.
* Results that have no expire time returned by their API are always considered outdated.
* If you want the data in the result to be up-to-date, you should call {@link AbstractStep#refresh} if this method returns true.
*
- * @return true if this result is potentially outdated or expired
+ * @return true if this or any previous result is potentially outdated or expired
*/
public boolean isExpiredOrOutdated() {
return this.isExpired();
diff --git a/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepMCChain.java b/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepMCChain.java
index 3839079..a1c72fb 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepMCChain.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepMCChain.java
@@ -175,6 +175,10 @@ protected StepXblXstsToken.XblXsts> prevResult() {
@Override
public boolean isExpired() {
+ if (this.prevResult().isExpired()) {
+ return true;
+ }
+
// Cache the result for 1 second because it's expensive to check
if (System.currentTimeMillis() - this.lastExpireCheckTimeMs < 1000) {
return this.lastExpireCheckResult;
diff --git a/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepPlayFabToken.java b/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepPlayFabToken.java
index b229254..85fbef5 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepPlayFabToken.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/bedrock/StepPlayFabToken.java
@@ -129,7 +129,7 @@ protected StepXblXstsToken.XblXsts> prevResult() {
@Override
public boolean isExpired() {
- return this.expireTimeMs <= System.currentTimeMillis();
+ return this.expireTimeMs <= System.currentTimeMillis() || this.prevResult().isExpired();
}
}
diff --git a/src/main/java/net/raphimc/minecraftauth/step/java/StepMCToken.java b/src/main/java/net/raphimc/minecraftauth/step/java/StepMCToken.java
index 76cdac7..0605cef 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/java/StepMCToken.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/java/StepMCToken.java
@@ -98,7 +98,7 @@ protected StepXblXstsToken.XblXsts> prevResult() {
@Override
public boolean isExpired() {
- return this.expireTimeMs <= System.currentTimeMillis();
+ return this.expireTimeMs <= System.currentTimeMillis() || this.prevResult().isExpired();
}
}
diff --git a/src/main/java/net/raphimc/minecraftauth/step/java/StepPlayerCertificates.java b/src/main/java/net/raphimc/minecraftauth/step/java/StepPlayerCertificates.java
index 0e21c85..1f38bf6 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/java/StepPlayerCertificates.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/java/StepPlayerCertificates.java
@@ -123,7 +123,7 @@ protected StepMCToken.MCToken prevResult() {
@Override
public boolean isExpired() {
- return this.expireTimeMs <= System.currentTimeMillis();
+ return this.expireTimeMs <= System.currentTimeMillis() || this.prevResult().isExpired();
}
}
diff --git a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblSisuAuthentication.java b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblSisuAuthentication.java
index 8d4cb58..b927e62 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblSisuAuthentication.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblSisuAuthentication.java
@@ -152,12 +152,12 @@ protected StepInitialXblSession.InitialXblSession prevResult() {
@Override
public boolean isExpired() {
- return this.userToken.isExpired() || this.titleToken.isExpired() || this.xstsToken.isExpired();
+ return this.userToken.isExpired() || this.titleToken.isExpired() || this.xstsToken.isExpired() || this.prevResult().isExpired();
}
@Override
public boolean isExpiredOrOutdated() {
- return this.userToken.isExpiredOrOutdated() || this.titleToken.isExpiredOrOutdated() || this.xstsToken.isExpiredOrOutdated();
+ return this.userToken.isExpiredOrOutdated() || this.titleToken.isExpiredOrOutdated() || this.xstsToken.isExpiredOrOutdated() || this.prevResult().isExpiredOrOutdated();
}
}
diff --git a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblTitleToken.java b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblTitleToken.java
index fcfaec0..d862640 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblTitleToken.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblTitleToken.java
@@ -132,7 +132,7 @@ protected StepInitialXblSession.InitialXblSession prevResult() {
@Override
public boolean isExpired() {
- return this.expireTimeMs <= System.currentTimeMillis();
+ return this.expireTimeMs <= System.currentTimeMillis() || this.prevResult().isExpired();
}
}
diff --git a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblUserToken.java b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblUserToken.java
index b1187d7..6f71964 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblUserToken.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblUserToken.java
@@ -128,7 +128,7 @@ protected StepInitialXblSession.InitialXblSession prevResult() {
@Override
public boolean isExpired() {
- return this.expireTimeMs <= System.currentTimeMillis();
+ return this.expireTimeMs <= System.currentTimeMillis() || this.prevResult().isExpired();
}
}
diff --git a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblXstsToken.java b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblXstsToken.java
index bb85977..af1131c 100644
--- a/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblXstsToken.java
+++ b/src/main/java/net/raphimc/minecraftauth/step/xbl/StepXblXstsToken.java
@@ -152,7 +152,7 @@ protected StepFullXblSession.FullXblSession prevResult() {
@Override
public boolean isExpired() {
- return this.expireTimeMs <= System.currentTimeMillis();
+ return this.expireTimeMs <= System.currentTimeMillis() || this.prevResult().isExpired();
}
}