aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGodOfPro <59516901+GodOfProDev@users.noreply.github.com>2022-11-20 14:02:47 +0330
committerGitHub <noreply@github.com>2022-11-20 21:32:47 +1100
commit69b2de53866b665a5b63c08afd3d92c0d068e812 (patch)
tree0ce9cf9e6e3893a579246bd3b80f9397a2242948 /src/main
parent5b3f8b0fad77d00f8f6bbd849fecd495421c3d91 (diff)
downloadNotEnoughUpdates-69b2de53866b665a5b63c08afd3d92c0d068e812.tar.gz
NotEnoughUpdates-69b2de53866b665a5b63c08afd3d92c0d068e812.tar.bz2
NotEnoughUpdates-69b2de53866b665a5b63c08afd3d92c0d068e812.zip
Added Senither Weight Leaderboard Position (#436)
Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java31
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java54
2 files changed, 71 insertions, 14 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 97db29cf..30ac269b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
@@ -306,13 +306,12 @@ public class BasicPage extends GuiProfileViewerPage {
if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth
&& profile.getSoopyNetworthLeaderboardPosition() >= 0
- && profile.isProfileMaxSoopyNetworth(profileId)) {
+ && profile.isProfileMaxSoopyWeight(profile, 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("");
+ getInstance().tooltipToDisplay.add(lbPosStr + EnumChatFormatting.GREEN + " on soopy's networth leaderboard!");
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
@@ -809,6 +808,9 @@ public class BasicPage extends GuiProfileViewerPage {
return;
}
+ ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
+ String profileId = GuiProfileViewer.getProfileId();
+
if (Constants.WEIGHT == null || Utils.getElement(Constants.WEIGHT, "lily.skills.overall") == null ||
!Utils.getElement(Constants.WEIGHT, "lily.skills.overall").isJsonPrimitive()) {
Utils.showOutdatedRepoNotification();
@@ -822,6 +824,12 @@ public class BasicPage extends GuiProfileViewerPage {
SenitherWeight senitherWeight = new SenitherWeight(skyblockInfo);
LilyWeight lilyWeight = new LilyWeight(skyblockInfo, profileInfo);
+ long weight = -2L;
+ if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) {
+ weight = profile.getSoopyWeightLeaderboardPosition();
+ }
+
+
Utils.drawStringCentered(
EnumChatFormatting.GREEN +
"Senither Weight: " +
@@ -870,6 +878,23 @@ public class BasicPage extends GuiProfileViewerPage {
roundToNearestInt(senitherWeight.getDungeonsWeight().getWeightStruct().getRaw())
)
);
+
+ if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth
+ && profile.isProfileMaxSoopyWeight(profile, profileId)) {
+
+ String lbPosStr =
+ EnumChatFormatting.DARK_GREEN + "#" + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(
+ profile.getSoopyWeightLeaderboardPosition());
+ getInstance().tooltipToDisplay.add("");
+ String stateStr = EnumChatFormatting.RED + "An error occured";
+ if (weight == -2) {
+ stateStr = EnumChatFormatting.YELLOW + "Loading";
+ }
+ if (weight > 0)
+ getInstance().tooltipToDisplay.add(lbPosStr + EnumChatFormatting.GREEN + " on soopy's weight leaderboard!");
+ else
+ getInstance().tooltipToDisplay.add(stateStr + " soopy's weight leaderboard");
+ }
}
}
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 347ee660..a1a91a5d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -25,6 +25,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.init.Blocks;
@@ -35,6 +36,7 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
+import org.luaj.vm2.ast.Str;
import javax.annotation.Nullable;
import java.io.ByteArrayInputStream;
@@ -655,6 +657,7 @@ public class ProfileViewer {
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 long soopyWeightLeaderboardPosition = -1; //-1 = default, -2 = loading, -3 = error
private String latestProfile = null;
private JsonArray skyblockProfiles = null;
private JsonObject guildInformation = null;
@@ -784,18 +787,26 @@ public class ProfileViewer {
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;
+ public long getSoopyWeightLeaderboardPosition() {
+ if ("d0e05de76067454dbeaec6d19d886191".equals(uuid)) return 1;
+ return soopyWeightLeaderboardPosition;
+ }
- highestProfileName = pName;
- largestProfileNetworth = pNet;
+ public boolean isProfileMaxSoopyWeight(ProfileViewer.Profile profile, String profileName) {
+ String highestProfileName = "";
+ double largestProfileWeight = 0;
+
+ for (int yIndex = 0; yIndex < profileNames.size(); yIndex++) {
+ String otherProfileId = profileNames.get(yIndex);
+ Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(otherProfileId);
+ if (skyblockInfo == null) continue;
+ SenitherWeight senitherWeight = new SenitherWeight(skyblockInfo);
+ double weightValue = senitherWeight.getTotalWeight().getRaw();
+
+ if (weightValue > largestProfileWeight) {
+ largestProfileWeight = weightValue;
+ highestProfileName = otherProfileId;
+ }
}
return highestProfileName.equals(profileName);
@@ -840,6 +851,27 @@ public class ProfileViewer {
return null;
});
+ soopyWeightLeaderboardPosition = -2; //loading
+ manager.apiUtils
+ .request()
+ .url("https://soopy.dev/api/v2/leaderboard/weight/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
+ soopyWeightLeaderboardPosition = -3; //error
+ return null;
+ }
+ soopyWeightLeaderboardPosition = 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)