aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/cowtipper/cowlection/command/MooCommand.java8
-rw-r--r--src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java25
-rw-r--r--src/main/java/de/cowtipper/cowlection/util/ApiUtils.java10
3 files changed, 20 insertions, 23 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java
index 978e687..8d6b3e7 100644
--- a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java
+++ b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java
@@ -423,7 +423,7 @@ public class MooCommand extends CommandBase {
}
String gameModeIcon = activeProfile.getGameModeIcon();
- MooChatComponent sbStats = new MooChatComponent("SkyBlock stats of " + stalkedPlayer.getName() + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " (" + (gameModeIcon.isEmpty() ? "" : EnumChatFormatting.getTextWithoutFormattingCodes(gameModeIcon) + ", ") + activeProfile.getCuteName() + ")").gold().bold().setUrl("https://sky.shiiyu.moe/stats/" + stalkedPlayer.getName() + "/" + activeProfile.getCuteName(), "Click to view SkyBlock stats on sky.shiiyu.moe")
+ MooChatComponent sbStats = new MooChatComponent("SkyBlock stats of " + stalkedPlayer.getName() + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " (" + (gameModeIcon.isEmpty() ? "" : gameModeIcon + EnumChatFormatting.GRAY + ", ") + activeProfile.getCuteName() + ")").gold().bold().setUrl("https://sky.shiiyu.moe/stats/" + stalkedPlayer.getName() + "/" + activeProfile.getCuteName(), "Click to view SkyBlock stats on sky.shiiyu.moe")
.appendFreshSibling(new MooChatComponent.KeyValueChatComponent("Coins", coinsBankAndPurse).setHover(wealthHover));
// highest skill + skill average:
if (highestSkill != null) {
@@ -625,9 +625,9 @@ public class MooCommand extends CommandBase {
// profile age:
sbStats.appendFreshSibling(new MooChatComponent.KeyValueChatComponent("Profile age", fancyFirstJoined.first()).setHover(new MooChatComponent.KeyValueTooltipComponent("Join date", (fancyFirstJoined.second() == null ? "today" : fancyFirstJoined.second()))));
// last save:
- Pair<String, String> fancyLastSave = member.getFancyLastSave();
- sbStats.appendFreshSibling(new MooChatComponent.KeyValueChatComponent("Last save", fancyLastSave.first() + " ago").setHover(new MooChatComponent.KeyValueTooltipComponent("Last save", (fancyLastSave.second() == null ? "today" : fancyLastSave.second()))
- .appendFreshSibling(new MooChatComponent("= last time " + stalkedPlayer.getName() + " has played SkyBlock.").white())));
+ Pair<String, String> fancyLastSave = activeProfile.getFancyLastSave();
+ sbStats.appendFreshSibling(new MooChatComponent.KeyValueChatComponent("Last profile save", fancyLastSave != null ? fancyLastSave.first() + " ago" : "unknown").setHover(new MooChatComponent.KeyValueTooltipComponent("Last profile save", fancyLastSave != null ? (fancyLastSave.second() == null ? "today" : fancyLastSave.second()) : "unknown")
+ .appendFreshSibling(new MooChatComponent("= last time " + (activeProfile.coopCount() == 0 ? stalkedPlayer.getName() : "someone " + EnumChatFormatting.RED + "from " + stalkedPlayer.getName() + "'s profile" + EnumChatFormatting.WHITE) + " has played SkyBlock.").white())));
main.getChatHelper().sendMessage(sbStats);
} else {
diff --git a/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java b/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java
index 9b51f02..fb38fe7 100644
--- a/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java
+++ b/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java
@@ -49,19 +49,18 @@ public class HySkyBlockStats {
if (profiles == null) {
return null;
}
- Profile lastSavedProfile = null;
- long latestSave = -1;
for (Profile profile : profiles) {
- long lastProfileSave = profile.getMember(uuid).last_save;
- if (latestSave < lastProfileSave) {
- lastSavedProfile = profile;
- latestSave = lastProfileSave;
+ if (profile.selected) {
+ return profile;
}
}
- return lastSavedProfile;
+ // no selected profile
+ return null;
}
public static class Profile {
+ public boolean selected;
+ private long last_save;
private String cute_name;
private Map<String, Member> members;
private String game_mode;
@@ -87,7 +86,10 @@ public class HySkyBlockStats {
} else if ("ironman".equals(game_mode)) {
return EnumChatFormatting.GRAY + "♲";
}
- return "";
+ }
+
+ public Pair<String, String> getFancyLastSave() {
+ return (last_save > 0) ? Utils.getDurationAsWords(last_save) : null;
}
public double getCoinBank() {
@@ -127,7 +129,6 @@ public class HySkyBlockStats {
}
public static class Member {
- private long last_save;
private long first_join;
private double coin_purse;
private NbtData inv_armor;
@@ -158,10 +159,6 @@ public class HySkyBlockStats {
return Utils.getDurationAsWords(first_join);
}
- public Pair<String, String> getFancyLastSave() {
- return Utils.getDurationAsWords(last_save);
- }
-
public double getCoinPurse() {
return coin_purse;
}
@@ -477,7 +474,7 @@ public class HySkyBlockStats {
*/
public String getSummary(boolean isMasterFloor) {
String floorCompletion;
- if (tier_completions != null) {
+ if (tier_completions != null && tier_completions.size() > 0) {
int highestTierCompletions = tier_completions.get(String.valueOf(highest_tier_completed));
floorCompletion = "" + highestTierCompletions + EnumChatFormatting.GRAY + "x " + EnumChatFormatting.YELLOW + "Floor " + (MooConfig.useRomanNumerals() ? Utils.convertArabicToRoman(highest_tier_completed) : highest_tier_completed);
} else {
diff --git a/src/main/java/de/cowtipper/cowlection/util/ApiUtils.java b/src/main/java/de/cowtipper/cowlection/util/ApiUtils.java
index 3a303e5..0695c1e 100644
--- a/src/main/java/de/cowtipper/cowlection/util/ApiUtils.java
+++ b/src/main/java/de/cowtipper/cowlection/util/ApiUtils.java
@@ -1,6 +1,6 @@
package de.cowtipper.cowlection.util;
-import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.mojang.util.UUIDTypeAdapter;
@@ -28,7 +28,7 @@ import java.util.concurrent.Executors;
public class ApiUtils {
public static final String UUID_NOT_FOUND = "UUID-NOT-FOUND";
private static final String NAME_TO_UUID_URL = "https://api.mojang.com/users/profiles/minecraft/";
- private static final String UUID_TO_NAME_URL = "https://api.mojang.com/user/profiles/%s/names";
+ private static final String UUID_TO_NAME_URL = "https://api.mojang.com/user/profile/%s";
private static final String ONLINE_STATUS_URL = "https://api.hypixel.net/status?key=%s&uuid=%s";
private static final String SKYBLOCK_STATS_URL = "https://api.hypixel.net/skyblock/profiles?key=%s&uuid=%s";
private static final String BAZAAR_URL = "https://api.hypixel.net/skyblock/bazaar";
@@ -66,9 +66,9 @@ public class ApiUtils {
if (reader == null) {
return UUID_NOT_FOUND;
} else {
- JsonArray nameHistoryData = new JsonParser().parse(reader).getAsJsonArray();
- if (nameHistoryData.size() > 0) {
- return nameHistoryData.get(nameHistoryData.size() - 1).getAsJsonObject().get("name").getAsString();
+ JsonObject profile = new JsonParser().parse(reader).getAsJsonObject();
+ if (profile.has("name")) {
+ return profile.get("name").getAsString();
}
}
} catch (IOException | JsonSyntaxException e) {