diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-08-06 20:45:44 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-08-06 20:45:44 -0400 |
commit | 4ef36d87f423c021891075e8015b5f20760510fd (patch) | |
tree | 44471340a0575881c78ff02eafaad37d3c2710fa /src/main/java/me/Danker/handlers/APIHandler.java | |
parent | a40b6338955f469f4a476b0d9b0ff61952289bcb (diff) | |
download | SkyblockMod-4ef36d87f423c021891075e8015b5f20760510fd.tar.gz SkyblockMod-4ef36d87f423c021891075e8015b5f20760510fd.tar.bz2 SkyblockMod-4ef36d87f423c021891075e8015b5f20760510fd.zip |
Add option to use lily weight in /weight
Diffstat (limited to 'src/main/java/me/Danker/handlers/APIHandler.java')
-rw-r--r-- | src/main/java/me/Danker/handlers/APIHandler.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/me/Danker/handlers/APIHandler.java b/src/main/java/me/Danker/handlers/APIHandler.java index 66001a3..4417973 100644 --- a/src/main/java/me/Danker/handlers/APIHandler.java +++ b/src/main/java/me/Danker/handlers/APIHandler.java @@ -18,7 +18,7 @@ import java.net.URL; import java.util.Scanner; public class APIHandler { - public static JsonObject getResponse(String urlString) { + public static JsonObject getResponse(String urlString, boolean hasError) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; try { @@ -41,7 +41,7 @@ public class APIHandler { return gson.fromJson(response.toString(), JsonObject.class); } else { - if (urlString.startsWith("https://api.hypixel.net/") || urlString.startsWith("https://hypixel-api.senither.com")) { + if (hasError) { InputStream errorStream = conn.getErrorStream(); try (Scanner scanner = new Scanner(errorStream)) { scanner.useDelimiter("\\Z"); @@ -98,7 +98,7 @@ public class APIHandler { } public static String getUUID(String username) { - JsonObject uuidResponse = getResponse("https://api.mojang.com/users/profiles/minecraft/" + username); + JsonObject uuidResponse = getResponse("https://api.mojang.com/users/profiles/minecraft/" + username, false); return uuidResponse.get("id").getAsString(); } @@ -108,7 +108,7 @@ public class APIHandler { // Get profiles System.out.println("Fetching profiles..."); - JsonObject profilesResponse = getResponse("https://api.hypixel.net/skyblock/profiles?uuid=" + UUID + "&key=" + key); + JsonObject profilesResponse = getResponse("https://api.hypixel.net/skyblock/profiles?uuid=" + UUID + "&key=" + key, true); if (!profilesResponse.get("success").getAsBoolean()) { String reason = profilesResponse.get("cause").getAsString(); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Failed with reason: " + reason)); |