aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/handlers/APIHandler.java
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-09-05 18:35:43 -0400
committerGitHub <noreply@github.com>2020-09-05 18:35:43 -0400
commit20b405f59dcd92df1b4c3cd5b9ac353652ef4405 (patch)
treef387a1ca10387c77381a22568b486984da5b38a6 /src/main/java/me/Danker/handlers/APIHandler.java
parent3ed5e14d43c6f3ff3cdce7598d01254e9465c33d (diff)
parenta29cfb42db5da544f8445f56acb3742e396d8dee (diff)
downloadSkyblockMod-20b405f59dcd92df1b4c3cd5b9ac353652ef4405.tar.gz
SkyblockMod-20b405f59dcd92df1b4c3cd5b9ac353652ef4405.tar.bz2
SkyblockMod-20b405f59dcd92df1b4c3cd5b9ac353652ef4405.zip
v1.7v1.7
Merge pull request #13 from bowser0000/development
Diffstat (limited to 'src/main/java/me/Danker/handlers/APIHandler.java')
-rw-r--r--src/main/java/me/Danker/handlers/APIHandler.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/handlers/APIHandler.java b/src/main/java/me/Danker/handlers/APIHandler.java
index 783ca92..34a73ff 100644
--- a/src/main/java/me/Danker/handlers/APIHandler.java
+++ b/src/main/java/me/Danker/handlers/APIHandler.java
@@ -2,10 +2,12 @@ package me.Danker.handlers;
import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Scanner;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -41,6 +43,17 @@ public class APIHandler {
return object;
} else {
+ if (urlString.startsWith("https://api.hypixel.net/")) {
+ InputStream errorStream = conn.getErrorStream();
+ try (Scanner scanner = new Scanner(errorStream)) {
+ scanner.useDelimiter("\\Z");
+ String error = scanner.next();
+
+ Gson gson = new Gson();
+ JsonObject object = gson.fromJson(error, JsonObject.class);
+ return object;
+ }
+ }
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Request failed. HTTP Error Code: " + conn.getResponseCode()));
}
} catch (MalformedURLException ex) {