diff options
author | Fluboxer <36457056+Fluboxer@users.noreply.github.com> | 2024-02-22 14:58:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-22 14:58:43 +0300 |
commit | b15c407a0afb72185b02ba8a1a40a42b5a4f0c0e (patch) | |
tree | a63be63ec9c3ae54154e04530a16ff444a7510cf /src/main/java/de/hysky/skyblocker/utils | |
parent | 66d352114f5c318d8415e607856bf17d8163f1f3 (diff) | |
parent | c0f134392958edf0b507a479dac7e85efa0cab80 (diff) | |
download | Skyblocker-b15c407a0afb72185b02ba8a1a40a42b5a4f0c0e.tar.gz Skyblocker-b15c407a0afb72185b02ba8a1a40a42b5a4f0c0e.tar.bz2 Skyblocker-b15c407a0afb72185b02ba8a1a40a42b5a4f0c0e.zip |
Merge branch 'SkyblockerMod:master' into Croesus-chest-highlight
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/Http.java | 14 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/Http.java b/src/main/java/de/hysky/skyblocker/utils/Http.java index 17079d15..58deced2 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Http.java +++ b/src/main/java/de/hysky/skyblocker/utils/Http.java @@ -53,7 +53,7 @@ public class Http { String body = new String(decodedInputStream.readAllBytes()); HttpHeaders headers = response.headers(); - return new ApiResponse(body, response.statusCode(), getCacheStatus(headers), getAge(headers)); + return new ApiResponse(body, response.statusCode(), getCacheStatuses(headers), getAge(headers)); } public static HttpHeaders sendHeadRequest(String url) throws IOException, InterruptedException { @@ -115,12 +115,12 @@ public class Http { } /** - * Returns the cache status of the resource + * Returns the cache statuses of the resource. All possible cache status values conform to Cloudflare's. * - * @see <a href="https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#cloudflare-cache-responses">Cloudflare Cache Docs</a> + * @see <a href="https://developers.cloudflare.com/cache/concepts/cache-responses/">Cloudflare Cache Docs</a> */ - private static String getCacheStatus(HttpHeaders headers) { - return headers.firstValue("CF-Cache-Status").orElse("UNKNOWN"); + private static String[] getCacheStatuses(HttpHeaders headers) { + return new String[] { headers.firstValue("CF-Cache-Status").orElse("UNKNOWN"), headers.firstValue("Local-Cache-Status").orElse("UNKNOWN") }; } private static int getAge(HttpHeaders headers) { @@ -128,7 +128,7 @@ public class Http { } //TODO If ever needed, we could just replace cache status with the response headers and go from there - public record ApiResponse(String content, int statusCode, String cacheStatus, int age) implements AutoCloseable { + public record ApiResponse(String content, int statusCode, String[] cacheStatuses, int age) implements AutoCloseable { public boolean ok() { return statusCode == 200; @@ -139,7 +139,7 @@ public class Http { } public boolean cached() { - return cacheStatus.equals("HIT"); + return cacheStatuses[0].equals("HIT") || cacheStatuses[1].equals("HIT"); } @Override diff --git a/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java b/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java index a81c25f7..460f34dd 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/gui/ContainerSolverManager.java @@ -44,7 +44,7 @@ public class ContainerSolverManager { new CroesusProfit(), new ChronomatronSolver(), new SuperpairsSolver(), - new UltrasequencerSolver() + UltrasequencerSolver.INSTANCE }; } |