From 1d5752ed624184cf226a495dc441719cc7716d94 Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Wed, 12 Jun 2024 01:03:01 +0300 Subject: Fix scheduled time being early spring 1st rather than late spring 27th Also adds more robust handling of get request failures --- src/main/java/de/hysky/skyblocker/utils/Http.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/de/hysky/skyblocker/utils/Http.java') diff --git a/src/main/java/de/hysky/skyblocker/utils/Http.java b/src/main/java/de/hysky/skyblocker/utils/Http.java index 1adf75d3..043ab97f 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Http.java +++ b/src/main/java/de/hysky/skyblocker/utils/Http.java @@ -33,7 +33,7 @@ public class Http { .followRedirects(Redirect.NORMAL) .build(); - private static ApiResponse sendCacheableGetRequest(String url, @Nullable String token) throws IOException, InterruptedException { + public static ApiResponse sendCacheableGetRequest(String url, @Nullable String token) throws IOException, InterruptedException { HttpRequest.Builder requestBuilder = HttpRequest.newBuilder() .GET() .header("Accept", "application/json") -- cgit From 3d75f5b7db5145952fb9bfa1e1a705e48a28296a Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:47:19 +0300 Subject: Clean up code after rebase --- src/main/java/de/hysky/skyblocker/utils/Http.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/utils/Http.java') diff --git a/src/main/java/de/hysky/skyblocker/utils/Http.java b/src/main/java/de/hysky/skyblocker/utils/Http.java index 043ab97f..051bd52e 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Http.java +++ b/src/main/java/de/hysky/skyblocker/utils/Http.java @@ -66,9 +66,8 @@ public class Http { .build(); HttpResponse response = HTTP_CLIENT.send(request, BodyHandlers.ofInputStream()); - InputStream decodedInputStream = getDecodedInputStream(response); - return decodedInputStream; + return getDecodedInputStream(response); } public static String sendGetRequest(String url) throws IOException, InterruptedException { @@ -125,16 +124,12 @@ public class Http { String encoding = getContentEncoding(response.headers()); try { - switch (encoding) { - case "": - return response.body(); - case "gzip": - return new GZIPInputStream(response.body()); - case "deflate": - return new InflaterInputStream(response.body()); - default: - throw new UnsupportedOperationException("The server sent content in an unexpected encoding: " + encoding); - } + return switch (encoding) { + case "" -> response.body(); + case "gzip" -> new GZIPInputStream(response.body()); + case "deflate" -> new InflaterInputStream(response.body()); + default -> throw new UnsupportedOperationException("The server sent content in an unexpected encoding: " + encoding); + }; } catch (IOException e) { throw new UncheckedIOException(e); } -- cgit