aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
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/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
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/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java54
1 files changed, 43 insertions, 11 deletions
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)