Skip to content

Commit

Permalink
Change: Get head gallery category should be async
Browse files Browse the repository at this point in the history
  • Loading branch information
Zailer43 committed Sep 12, 2024
1 parent 03ceaa2 commit 23fe1ca
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.gson.JsonParser;
import fzmm.zailer.me.client.FzmmClient;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.util.Util;
import org.apache.http.client.HttpResponseException;

import java.io.BufferedReader;
Expand Down Expand Up @@ -52,11 +53,13 @@ public static CompletableFuture<ObjectArrayList<MinecraftHeadsData>> getCategory

String url = getUrl(category);

try {
future.complete(fetchUrl(url, category, cacheCategories));
} catch (Exception e) {
future.completeExceptionally(e);
}
future.completeAsync(() -> {
try {
return fetchUrl(url, category, cacheCategories);
} catch (Exception e) {
throw new RuntimeException(e);
}
}, Util.getDownloadWorkerExecutor());

return future;
}
Expand Down

0 comments on commit 23fe1ca

Please sign in to comment.