diff options
Diffstat (limited to 'src/main/java/me/Danker/commands/ArmourCommand.java')
-rw-r--r-- | src/main/java/me/Danker/commands/ArmourCommand.java | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/main/java/me/Danker/commands/ArmourCommand.java b/src/main/java/me/Danker/commands/ArmourCommand.java index 4fcd282..a10d75f 100644 --- a/src/main/java/me/Danker/commands/ArmourCommand.java +++ b/src/main/java/me/Danker/commands/ArmourCommand.java @@ -9,6 +9,7 @@ import java.util.List; import com.google.gson.JsonObject; +import me.Danker.TheMod; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; import me.Danker.utils.Utils; @@ -31,8 +32,7 @@ public class ArmourCommand extends CommandBase { } @Override - public List<String> getCommandAliases() - { + public List<String> getCommandAliases() { return Collections.singletonList("armour"); } @@ -58,12 +58,10 @@ public class ArmourCommand extends CommandBase { public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { // MULTI THREAD DRIFTING new Thread(() -> { - APIHandler ah = new APIHandler(); - ConfigHandler cf = new ConfigHandler(); EntityPlayer player = (EntityPlayer) arg0; // Check key - String key = cf.getString("api", "APIKey"); + String key = ConfigHandler.getString("api", "APIKey"); if (key.equals("")) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "API key not set. Use /setkey.")); } @@ -74,23 +72,23 @@ public class ArmourCommand extends CommandBase { if (arg1.length == 0) { username = player.getName(); uuid = player.getUniqueID().toString().replaceAll("[\\-]", ""); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking armour of " + EnumChatFormatting.DARK_GREEN + username)); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Checking armour of " + TheMod.SECONDARY_COLOUR + username)); } else { username = arg1[0]; - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking armour of " + EnumChatFormatting.DARK_GREEN + username)); - uuid = ah.getUUID(username); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Checking armour of " + TheMod.SECONDARY_COLOUR + username)); + uuid = APIHandler.getUUID(username); } // Find stats of latest profile - String latestProfile = ah.getLatestProfileID(uuid, key); + String latestProfile = APIHandler.getLatestProfileID(uuid, key); if (latestProfile == null) return; String profileURL = "https://api.hypixel.net/skyblock/profile?profile=" + latestProfile + "&key=" + key; System.out.println("Fetching profile..."); - JsonObject profileResponse = ah.getResponse(profileURL); + JsonObject profileResponse = APIHandler.getResponse(profileURL); if (!profileResponse.get("success").getAsBoolean()) { String reason = profileResponse.get("cause").getAsString(); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed with reason: " + reason)); + player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Failed with reason: " + reason)); return; } @@ -133,15 +131,15 @@ public class ArmourCommand extends CommandBase { } armourStream.close(); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" + + player.addChatMessage(new ChatComponentText(TheMod.DELIMITER_COLOUR + "" + EnumChatFormatting.BOLD + "-------------------\n" + EnumChatFormatting.AQUA + " " + username + "'s Armour:\n" + - EnumChatFormatting.GREEN + " Helmet: " + helmet + "\n" + - EnumChatFormatting.GREEN + " Chestplate: " + chest + "\n" + - EnumChatFormatting.GREEN + " Leggings: " + legs + "\n" + - EnumChatFormatting.GREEN + " Boots: " + boots + "\n" + - EnumChatFormatting.AQUA + " " + EnumChatFormatting.BOLD + "-------------------")); + TheMod.TYPE_COLOUR + " Helmet: " + helmet + "\n" + + TheMod.TYPE_COLOUR + " Chestplate: " + chest + "\n" + + TheMod.TYPE_COLOUR + " Leggings: " + legs + "\n" + + TheMod.TYPE_COLOUR + " Boots: " + boots + "\n" + + TheMod.DELIMITER_COLOUR + " " + EnumChatFormatting.BOLD + "-------------------")); } catch (IOException ex) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "An error has occurred while reading inventory data. See logs for more info.")); + player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "An error has occurred while reading inventory data. See logs for more info.")); System.err.println(ex); } }).start(); |