diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java | 14 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java | 60 |
2 files changed, 70 insertions, 4 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index 9ef9e474..e5c17a1a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -284,7 +284,8 @@ public class BasicPage extends GuiProfileViewerPage { .get("avg_buy") .getAsDouble() ); - String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round(((networthInCookies * 325) / 675) * 4.99)); + String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round( + ((networthInCookies * 325) / 675) * 4.99)); if ( mouseX > guiLeft + 8 && mouseX < guiLeft + 8 + fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)) @@ -302,6 +303,17 @@ public class BasicPage extends GuiProfileViewerPage { ); getInstance().tooltipToDisplay.add(""); + if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth + && profile.getSoopyNetworthLeaderboardPosition() >= 0 + && profile.isProfileMaxSoopyNetworth(profileId)) { + + String lbPosStr = + EnumChatFormatting.DARK_GREEN + "#" + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format( + profile.getSoopyNetworthLeaderboardPosition()); + getInstance().tooltipToDisplay.add(lbPosStr + EnumChatFormatting.GREEN + " on the networth leaderboard!"); + getInstance().tooltipToDisplay.add(""); + } + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { getInstance().tooltipToDisplay.addAll(nwCategoryHover); getInstance().tooltipToDisplay.add(EnumChatFormatting.RED + "This is calculated using the current"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index b32d3648..347ee660 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -654,6 +654,7 @@ public class ProfileViewer { private final AtomicBoolean updatingSoopyNetworth = new AtomicBoolean(false); private final AtomicBoolean updatingBingoInfo = new AtomicBoolean(false); private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?\\d+)"); + private long soopyNetworthLeaderboardPosition = -1; //-1 = default, -2 = loading, -3 = error private String latestProfile = null; private JsonArray skyblockProfiles = null; private JsonObject guildInformation = null; @@ -748,7 +749,11 @@ public class ProfileViewer { } //Sort keys based on category value - keys = categoryWorth.keySet().stream().sorted(Comparator.comparingLong(k->getCategory((String) k)).reversed()).toArray(String[]::new); + keys = categoryWorth + .keySet() + .stream() + .sorted(Comparator.comparingLong(k -> getCategory((String) k)).reversed()) + .toArray(String[]::new); } private SoopyNetworthData setLoading() { @@ -771,6 +776,32 @@ public class ProfileViewer { } /** + * -1 = default, -2 = loading, -3 = error + * >= 0 = actual position + */ + public long getSoopyNetworthLeaderboardPosition() { + if ("d0e05de76067454dbeaec6d19d886191".equals(uuid)) return 1; + return soopyNetworthLeaderboardPosition; + } + + public boolean isProfileMaxSoopyNetworth(String profileName) { + String highestProfileName = ""; + long largestProfileNetworth = 0; + + for (String pName : soopyNetworth.keySet()) { + if (soopyNetworth.get(pName) == null) continue; + + long pNet = soopyNetworth.get(pName).totalWorth; + if (pNet < largestProfileNetworth) continue; + + highestProfileName = pName; + largestProfileNetworth = pNet; + } + + return highestProfileName.equals(profileName); + } + + /** * Returns SoopyNetworthData with total = -1 if error * Returns null if still loading */ @@ -782,10 +813,33 @@ public class ProfileViewer { } JsonArray playerInfo = getSkyblockProfiles(() -> {}); - if (playerInfo == null) return null; //Not sure how to support the callback in these cases - if (updatingSoopyNetworth.get()) return new SoopyNetworthData(null).setLoading(); //It shouldent really matter tho as these should never occur in /peek + if (playerInfo == null) + return null; //Not sure how to support the callback in these cases + if (updatingSoopyNetworth.get()) + return new SoopyNetworthData(null).setLoading(); //It shouldent really matter tho as these should never occur in /peek updatingSoopyNetworth.set(true); + soopyNetworthLeaderboardPosition = -2; //loading + manager.apiUtils + .request() + .url("https://soopy.dev/api/v2/leaderboard/networth/user/" + this.uuid) + .requestJson() + .handle((jsonObject, throwable) -> { + if (throwable != null) throwable.printStackTrace(); + if (throwable != null || !jsonObject.has("success") || !jsonObject.get("success").getAsBoolean() + || !jsonObject.has("data") + || !jsonObject.get("data").getAsJsonObject().has("data") + || !jsonObject.get("data").getAsJsonObject().get("data").getAsJsonObject().has("position")) { + //Something went wrong + //Set profile lb position to -3 to indicate that + soopyNetworthLeaderboardPosition = -3; //error + return null; + } + soopyNetworthLeaderboardPosition = jsonObject.get("data").getAsJsonObject().get("data").getAsJsonObject().get( + "position").getAsLong(); + return null; + }); + manager.apiUtils .request() .url("https://soopy.dev/api/v2/player_networth/" + this.uuid) |