aboutsummaryrefslogtreecommitdiff
path: root/me/Danker/commands/SlayerCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'me/Danker/commands/SlayerCommand.java')
-rw-r--r--me/Danker/commands/SlayerCommand.java44
1 files changed, 7 insertions, 37 deletions
diff --git a/me/Danker/commands/SlayerCommand.java b/me/Danker/commands/SlayerCommand.java
index ec23606..9fae3ef 100644
--- a/me/Danker/commands/SlayerCommand.java
+++ b/me/Danker/commands/SlayerCommand.java
@@ -55,51 +55,21 @@ public class SlayerCommand extends CommandBase {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking slayer of " + username));
} else {
username = arg1[0];
- String uuidURL = "https://api.mojang.com/users/profiles/minecraft/" + username;
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking slayer of " + username));
-
- JsonObject uuidResponse = ah.getResponse(uuidURL, player);
- uuid = uuidResponse.get("id").getAsString();
+ uuid = ah.getUUID(username);
}
- // Get profiles
- System.out.println("Fetching profiles...");
- String profilesURL = "https://api.hypixel.net/skyblock/profiles?uuid=" + uuid + "&key=" + key;
-
- JsonObject profilesResponse = ah.getResponse(profilesURL, player);
- if (!profilesResponse.get("success").getAsBoolean()) {
- String reason = profilesResponse.get("cause").getAsString();
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed with reason: " + reason));
- return;
- }
- if (profilesResponse.get("profiles").isJsonNull()) {
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This player doesn't appear to have played SkyBlock."));
+ // Find stats of latest profile
+ String latestProfile = ah.getLatestProfileID(uuid, key);
+ if (latestProfile == null) {
return;
}
- // Loop through profiles to find latest
- System.out.println("Looping through profiles...");
- String latestProfile = "";
- int latestSave = 0;
- JsonArray profilesArray = profilesResponse.get("profiles").getAsJsonArray();
-
- for (JsonElement profile : profilesArray) {
- JsonObject profileJSON = profile.getAsJsonObject();
- int profileLastSave = profileJSON.get("members").getAsJsonObject().get(uuid).getAsJsonObject().get("last_save").getAsInt();
-
- if (profileLastSave > latestSave) {
- latestProfile = profileJSON.get("profile_id").getAsString();
- latestSave = profileLastSave;
- }
- }
-
- // Find stats of latest profile
- System.out.println("Fetching profile...");
String profileURL = "https://api.hypixel.net/skyblock/profile?profile=" + latestProfile + "&key=" + key;
-
- JsonObject profileResponse = ah.getResponse(profileURL, player);
+ System.out.println("Fetching profile...");
+ JsonObject profileResponse = ah.getResponse(profileURL);
if (!profileResponse.get("success").getAsBoolean()) {
- String reason = profilesResponse.get("cause").getAsString();
+ String reason = profileResponse.get("cause").getAsString();
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed with reason: " + reason));
return;
}