aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-07-01 13:47:19 +0300
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-07-06 16:18:35 +0800
commit3d75f5b7db5145952fb9bfa1e1a705e48a28296a (patch)
treeddf4157eb5a4f77984d5e6d5921d1085d31272e8 /src/main/java/de/hysky
parent1d5752ed624184cf226a495dc441719cc7716d94 (diff)
downloadSkyblocker-3d75f5b7db5145952fb9bfa1e1a705e48a28296a.tar.gz
Skyblocker-3d75f5b7db5145952fb9bfa1e1a705e48a28296a.tar.bz2
Skyblocker-3d75f5b7db5145952fb9bfa1e1a705e48a28296a.zip
Clean up code after rebase
Diffstat (limited to 'src/main/java/de/hysky')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/Http.java19
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/Utils.java2
2 files changed, 8 insertions, 13 deletions
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<InputStream> 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);
}
diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java
index 4ec951b7..9ebd8bbb 100644
--- a/src/main/java/de/hysky/skyblocker/utils/Utils.java
+++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java
@@ -494,7 +494,7 @@ public class Utils {
private static void tickMayorCache() {
CompletableFuture.supplyAsync(() -> {
try {
- Http.ApiResponse response = Http.sendCacheableGetRequest("https://api.hypixel.net/v2/resources/skyblock/election");
+ Http.ApiResponse response = Http.sendCacheableGetRequest("https://api.hypixel.net/v2/resources/skyblock/election", null); //Authentication is not required for this endpoint
if (!response.ok()) throw new HttpResponseException(response.statusCode(), response.content());
JsonObject json = JsonParser.parseString(response.content()).getAsJsonObject();
if (!json.get("success").getAsBoolean()) throw new RuntimeException("Request failed!"); //Can't find a more appropriate exception to throw here.