further improve mojang api rate limit handling

This commit is contained in:
Jason Penilla committed 2023-03-26 11:46:33 -07:00
1 parent 914d21d1fd
commit b8e288eb41
1 file changed
+7 -1
@@ -119,7 +119,13 @@ public final class MojangProfileResolver implements ProfileResolver {
return CompletableFuture.completedFuture(this.cache.cachedName(uuid));
}
return this.pendingUsernameLookups.computeIfAbsent(uuid, $ -> {
if (!this.globalRateLimit.canSubmit() || !this.uuidToProfileRateLimit.canSubmit()) {
final boolean globalLimited = !this.globalRateLimit.canSubmit();
final boolean nameLimited = !this.uuidToProfileRateLimit.canSubmit();
if (globalLimited || nameLimited) {
if (nameLimited && !globalLimited) {
// Add back to the global limit if we didn't actually make a request due to uuidToProfileRateLimit
this.globalRateLimit.available.getAndIncrement();
}
return CompletableFuture.completedFuture(null);
}
final CompletableFuture<@Nullable BasicLookupResponse> mojangLookup = CompletableFuture.supplyAsync(() -> {