diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-11-22 10:59:12 -0500 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-11-22 10:59:12 -0500 |
commit | a63cb87198b563edd4ac88b226fd004d0c616360 (patch) | |
tree | 73cff7a960d133d7af4e3c0a8afae9b22965972f /src/main | |
parent | 69d505b5b1d215a7bba3f1aecd31b187d1705d08 (diff) | |
download | SkyblockMod-a63cb87198b563edd4ac88b226fd004d0c616360.tar.gz SkyblockMod-a63cb87198b563edd4ac88b226fd004d0c616360.tar.bz2 SkyblockMod-a63cb87198b563edd4ac88b226fd004d0c616360.zip |
Fix /hotmof error when missing API values
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/me/Danker/commands/HOTMCommand.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/me/Danker/commands/HOTMCommand.java b/src/main/java/me/Danker/commands/HOTMCommand.java index bfb10f5..35c0b28 100644 --- a/src/main/java/me/Danker/commands/HOTMCommand.java +++ b/src/main/java/me/Danker/commands/HOTMCommand.java @@ -88,9 +88,23 @@ public class HOTMCommand extends CommandBase { System.out.println("Fetching mining stats..."); JsonObject miningCore = profileResponse.get("profile").getAsJsonObject().get("members").getAsJsonObject().get(uuid).getAsJsonObject().get("mining_core").getAsJsonObject(); - int mithril = miningCore.get("powder_mithril").getAsInt() + miningCore.get("powder_spent_mithril").getAsInt(); - int gemstone = miningCore.get("powder_gemstone").getAsInt() + miningCore.get("powder_spent_gemstone").getAsInt(); - String ability = Node.valueOf(miningCore.get("selected_pickaxe_ability").getAsString()).name; + + int mithril = 0; + if (miningCore.has("powder_mithril")) { + mithril = miningCore.get("powder_mithril").getAsInt(); + if (miningCore.has("powder_spent_mithril")) mithril += miningCore.get("powder_spent_mithril").getAsInt(); + } + + int gemstone = 0; + if (miningCore.has("powder_gemstone")) { + gemstone = miningCore.get("powder_gemstone").getAsInt(); + if (miningCore.has("powder_spent_gemstone")) gemstone += miningCore.get("powder_spent_gemstone").getAsInt(); + } + + String ability = EnumChatFormatting.RED + "None"; + if (miningCore.has("selected_pickaxe_ability")) { + ability = Node.valueOf(miningCore.get("selected_pickaxe_ability").getAsString()).name; + } ChatComponentText tree = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + "[CLICK]"); tree.setChatStyle(tree.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/hotmtree " + username + " " + latestProfile))); |