aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/commands/GuildOfCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/commands/GuildOfCommand.java')
-rw-r--r--src/main/java/me/Danker/commands/GuildOfCommand.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/main/java/me/Danker/commands/GuildOfCommand.java b/src/main/java/me/Danker/commands/GuildOfCommand.java
index be804c1..881a9c4 100644
--- a/src/main/java/me/Danker/commands/GuildOfCommand.java
+++ b/src/main/java/me/Danker/commands/GuildOfCommand.java
@@ -6,6 +6,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import me.Danker.TheMod;
import me.Danker.handlers.APIHandler;
import me.Danker.handlers.ConfigHandler;
import me.Danker.utils.Utils;
@@ -46,14 +47,12 @@ public class GuildOfCommand 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."));
+ player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "API key not set. Use /setkey."));
}
// Get UUID for Hypixel API requests
@@ -62,20 +61,20 @@ public class GuildOfCommand extends CommandBase {
if (arg1.length == 0) {
username = player.getName();
uuid = player.getUniqueID().toString().replaceAll("[\\-]", "");
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking guild of " + EnumChatFormatting.DARK_GREEN + username));
+ player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Checking guild of " + TheMod.SECONDARY_COLOUR + username));
} else {
username = arg1[0];
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking guild of " + EnumChatFormatting.DARK_GREEN + username));
- uuid = ah.getUUID(username);
+ player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Checking guild of " + TheMod.SECONDARY_COLOUR + username));
+ uuid = APIHandler.getUUID(username);
}
// Find guild ID
System.out.println("Fetching guild...");
String guildURL = "https://api.hypixel.net/guild?player=" + uuid + "&key=" + key;
- JsonObject guildResponse = ah.getResponse(guildURL);
+ JsonObject guildResponse = APIHandler.getResponse(guildURL);
if (!guildResponse.get("success").getAsBoolean()) {
String reason = guildResponse.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;
}
@@ -99,7 +98,7 @@ public class GuildOfCommand extends CommandBase {
// Get username from UUID
String gmUUID = memberObject.get("uuid").getAsString();
String gmNameURL = "https://api.mojang.com/user/profiles/" + gmUUID + "/names";
- JsonArray gmNameResponse = ah.getArrayResponse(gmNameURL);
+ JsonArray gmNameResponse = APIHandler.getArrayResponse(gmNameURL);
guildMaster = gmNameResponse.get(gmNameResponse.size() - 1).getAsJsonObject().get("name").getAsString();
break;
@@ -107,12 +106,12 @@ public class GuildOfCommand extends CommandBase {
}
}
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" +
+ player.addChatMessage(new ChatComponentText(TheMod.DELIMITER_COLOUR + "" + EnumChatFormatting.BOLD + "-------------------\n" +
EnumChatFormatting.AQUA + " " + username + "'s Guild:\n" +
- EnumChatFormatting.GREEN + " Guild: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + guildName + "\n" +
- EnumChatFormatting.GREEN + " Guildmaster: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + guildMaster + "\n" +
- EnumChatFormatting.GREEN + " Members: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + players + "\n" +
- EnumChatFormatting.AQUA + " " + EnumChatFormatting.BOLD + "-------------------"));
+ TheMod.TYPE_COLOUR + " Guild: " + TheMod.VALUE_COLOUR + EnumChatFormatting.BOLD + guildName + "\n" +
+ TheMod.TYPE_COLOUR + " Guildmaster: " + TheMod.VALUE_COLOUR + EnumChatFormatting.BOLD + guildMaster + "\n" +
+ TheMod.TYPE_COLOUR + " Members: " + TheMod.VALUE_COLOUR + EnumChatFormatting.BOLD + players + "\n" +
+ TheMod.DELIMITER_COLOUR + " " + EnumChatFormatting.BOLD + "-------------------"));
}).start();
}