aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorkr45732 <52721908+kr45732@users.noreply.github.com>2023-06-08 10:00:04 -0400
committerGitHub <noreply@github.com>2023-06-08 16:00:04 +0200
commit8115922b37e375285c2a72dbdbb5d83fd942e27c (patch)
treee0d6cb5228493e8bb032465cbb2dfd95b4946e43 /src/main/java/io
parenta6fb7bfb97d313b665085a52a660150f1da26065 (diff)
downloadNotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.gz
NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.bz2
NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.zip
PV Overhaul (#708)
Co-authored-by: Lulonaut <lulonaut@tutanota.de>
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java68
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java56
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java159
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java42
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java45
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java184
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java81
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java269
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewerPage.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java72
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java461
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java54
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java1275
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java65
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java974
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java91
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java27
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java37
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/GuiTaskLevel.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java27
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/lily/LilySkillsWeight.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/senither/SenitherSkillsWeight.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/Weight.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java5
48 files changed, 1898 insertions, 2504 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index a5bea05d..6b68fccf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -39,7 +39,6 @@ import io.github.moulberry.notenoughupdates.util.ApiUtil;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery;
import io.github.moulberry.notenoughupdates.util.ItemUtils;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
@@ -49,7 +48,6 @@ import net.minecraft.inventory.ContainerChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
@@ -63,7 +61,6 @@ import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -143,7 +140,6 @@ public class NEUManager {
public File configLocation;
public File repoLocation;
- public File configFile;
public KatSitterOverlay katSitterOverlay;
@@ -162,24 +158,6 @@ public class NEUManager {
repoLocation.mkdir();
}
- public String getCurrentProfile() {
- return SBInfo.getInstance().currentProfile;
- }
-
- public <T> T getJsonFromFile(File file, Class<T> clazz) {
- try (
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- new FileInputStream(file),
- StandardCharsets.UTF_8
- ))
- ) {
- T obj = gson.fromJson(reader, clazz);
- return obj;
- } catch (Exception e) {
- return null;
- }
- }
-
/**
* Parses a file in to a JsonObject.
*/
@@ -738,17 +716,6 @@ public class NEUManager {
return inputWithoutLastChar + incrementedLastChar;
}
- public JsonObject getJsonFromItemBytes(String item_bytes) {
- try {
- NBTTagCompound tag =
- CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
- //System.out.println(tag.toString());
- return getJsonFromNBT(tag);
- } catch (IOException e) {
- return null;
- }
- }
-
public static String getUUIDFromNBT(NBTTagCompound tag) {
String uuid = null;
if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
@@ -778,16 +745,6 @@ public class NEUManager {
return null;
}
- /**
- * Replaced with {@link #createItemResolutionQuery()}
- */
- @Deprecated
- public String getInternalnameFromNBT(NBTTagCompound tag) {
- return createItemResolutionQuery()
- .withItemNBT(tag)
- .resolveInternalName();
- }
-
public String[] getLoreFromNBT(NBTTagCompound tag) {
return ItemUtils.getLore(tag).toArray(new String[0]);
}
@@ -806,7 +763,9 @@ public class NEUManager {
if (id == 141) id = 391; //for some reason hypixel thinks carrots have id 141
- String internalname = getInternalnameFromNBT(tag);
+ String internalname = createItemResolutionQuery()
+ .withItemNBT(tag)
+ .resolveInternalName();
if (internalname == null) return null;
NBTTagCompound display = tag.getCompoundTag("display");
@@ -818,8 +777,6 @@ public class NEUManager {
itemid = itemMc.getRegistryName();
}
String displayName = display.getString("Name");
- String[] info = new String[0];
- String clickcommand = "";
JsonObject item = new JsonObject();
item.addProperty("internalname", internalname);
@@ -1232,25 +1189,6 @@ public class NEUManager {
}
public boolean writeItemJson(
- String internalname, String itemid, String displayName, String[] lore, String crafttext,
- String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag
- ) {
- return writeItemJson(
- new JsonObject(),
- internalname,
- itemid,
- displayName,
- lore,
- crafttext,
- infoType,
- info,
- clickcommand,
- damage,
- nbttag
- );
- }
-
- public boolean writeItemJson(
JsonObject base, String internalname, String itemid, String displayName, String[] lore,
String crafttext, String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag
) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java
index ec50633f..e59a6a14 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java
@@ -19,18 +19,14 @@
package io.github.moulberry.notenoughupdates.core.util;
-import com.google.common.collect.Sets;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-
-import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.Set;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Locale;
public class StringUtils {
- public static final Set<String> PROTOCOLS = Sets.newHashSet("http", "https");
+ private final static DecimalFormat TENTHS_DECIMAL_FORMAT = new DecimalFormat("#.#");
+ public static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);
public static String cleanColour(String in) {
return in.replaceAll("(?i)\\u00A7.", "");
@@ -40,24 +36,6 @@ public class StringUtils {
return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r");
}
- public static String trimToWidth(String str, int len) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- String trim = fr.trimStringToWidth(str, len);
-
- if (str.length() != trim.length() && !trim.endsWith(" ")) {
- char next = str.charAt(trim.length());
- if (next != ' ') {
- String[] split = trim.split(" ");
- String last = split[split.length - 1];
- if (last.length() < 8) {
- trim = trim.substring(0, trim.length() - last.length());
- }
- }
- }
-
- return trim;
- }
-
public static String substringBetween(String str, String open, String close) {
return org.apache.commons.lang3.StringUtils.substringBetween(str, open, close);
}
@@ -99,22 +77,6 @@ public class StringUtils {
return d < 1000 ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + sizeSuffix[iteration] : shortNumberFormat(d, iteration + 1);
}
- public static String urlEncode(String something) {
- try {
- return URLEncoder.encode(something, StandardCharsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e); // UTF 8 should always be present
- }
- }
-
- /**
- * taken and modified from https://stackoverflow.com/a/23326014/5507634
- */
- public static String replaceLast(String string, String toReplace, String replacement) {
- int start = string.lastIndexOf(toReplace);
- return string.substring(0, start) + replacement + string.substring(start + toReplace.length());
- }
-
public static String removeLastWord(String string, String splitString) {
try {
String[] split = string.split(splitString);
@@ -143,4 +105,12 @@ public class StringUtils {
}
return true;
}
+
+ public static String formatToTenths(Number num) {
+ return TENTHS_DECIMAL_FORMAT.format(num);
+ }
+
+ public static String formatNumber(Number num) {
+ return NUMBER_FORMAT.format(num);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java
index cacae83b..3dbd52a5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java
@@ -49,11 +49,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Random;
+import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_bg;
+import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_dropdown;
+import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_elements;
+
public class GuiCosmetics extends GuiScreen {
- public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
- public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png");
public static final ResourceLocation cosmetics_fg = new ResourceLocation("notenoughupdates:cosmetics_fg.png");
- public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
private final GuiElementTextField unlockTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
@@ -301,7 +302,6 @@ public class GuiCosmetics extends GuiScreen {
}
}
- int index = 0;
int displayingCapes = 0;
for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
@@ -315,7 +315,6 @@ public class GuiCosmetics extends GuiScreen {
float totalAvail = sizeX - 20;
float xOffset = scroll * (totalNeeded - totalAvail);
- index = 0;
int displayIndex = 0;
for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
@@ -447,7 +446,6 @@ public class GuiCosmetics extends GuiScreen {
Minecraft.getMinecraft().displayWidth * (sizeX - 6) / width, Minecraft.getMinecraft().displayHeight
);
- int index = 0;
int displayingCapes = 0;
for (CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) {
boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
@@ -461,7 +459,6 @@ public class GuiCosmetics extends GuiScreen {
float totalAvail = sizeX - 20;
float xOffset = scroll * (totalNeeded - totalAvail);
- index = 0;
int displayIndex = 0;
for (CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) {
boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java
index 1e3dd7e0..01a173d3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java
@@ -30,7 +30,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.MiscUtils;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
-import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.PetLeveling;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -57,7 +56,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -164,7 +162,6 @@ public class ItemTooltipListener {
for (int k = 0; k < event.toolTip.size(); k++) {
String line = event.toolTip.get(k);
- boolean thisLineHasEnchants = false;
if (line.endsWith(EnumChatFormatting.DARK_GRAY + "Reforge Stone") &&
NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) {
@@ -299,7 +296,7 @@ public class ItemTooltipListener {
if (reforgeCost >= 0) {
String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD +
- NumberFormat.getNumberInstance().format(reforgeCost) + " coins";
+ StringUtils.formatNumber(reforgeCost) + " coins";
newTooltip.add("");
newTooltip.add(text);
}
@@ -495,12 +492,11 @@ public class ItemTooltipListener {
}
}
- NumberFormat format = NumberFormat.getInstance(Locale.US);
String valueStringBIN1;
String valueStringBIN2;
if (totalValue >= 0) {
valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): ";
- valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
+ valueStringBIN2 = EnumChatFormatting.GOLD + StringUtils.formatNumber(totalValue) + " coins";
} else {
valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: ";
valueStringBIN2 = missingItem;
@@ -513,9 +509,9 @@ public class ItemTooltipListener {
String plStringBIN;
if (profitLossBIN >= 0) {
- plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins";
+ plStringBIN = prefix + "+" + StringUtils.formatNumber(profitLossBIN) + " coins";
} else {
- plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins";
+ plStringBIN = prefix + "-" + StringUtils.formatNumber(-profitLossBIN) + " coins";
}
String neu = EnumChatFormatting.YELLOW + "[NEU] ";
@@ -526,7 +522,7 @@ public class ItemTooltipListener {
}
for (Map.Entry<String, Double> entry : itemValues.entrySet()) {
- newTooltip.add(neu + entry.getKey() + prefix + "+" + format.format(entry.getValue().intValue()));
+ newTooltip.add(neu + entry.getKey() + prefix + "+" + StringUtils.formatNumber(entry.getValue().intValue()));
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java
index 06d294a3..10882b9b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java
@@ -169,17 +169,17 @@ public class ItemTooltipRngListener {
if (matcher.matches()) {
String odds = matcher.group(1);
int baseChance = calculateChance(matcher.group(2));
- String baseFormat = GuiProfileViewer.numberFormat.format(baseChance);
+ String baseFormat = StringUtils.formatNumber(baseChance);
String fractionFormat = "§7(1/" + baseFormat + ")";
result = odds + " " + fractionFormat;
} else if (matcherSelected.matches()) {
String odds = matcherSelected.group(1);
int baseChance = calculateChance(matcherSelected.group(2));
- String baseFormat = GuiProfileViewer.numberFormat.format(baseChance);
+ String baseFormat = StringUtils.formatNumber(baseChance);
int increasedChance = calculateChance(matcherSelected.group(3));
- String increased = GuiProfileViewer.numberFormat.format(increasedChance);
+ String increased = StringUtils.formatNumber(increasedChance);
String fractionFormat = "§7(§8§m1/" + baseFormat + "§r §71/" + increased + ")";
result = odds + " " + fractionFormat;
@@ -304,8 +304,8 @@ public class ItemTooltipRngListener {
int runsNeeded = (int) Math.floor((double) needed / (double) gainPerRun);
int runsHaving = having / gainPerRun;
- String runsNeededFormat = GuiProfileViewer.numberFormat.format(runsNeeded);
- String runsHavingFormat = GuiProfileViewer.numberFormat.format(runsHaving);
+ String runsNeededFormat = StringUtils.formatNumber(runsNeeded);
+ String runsHavingFormat = StringUtils.formatNumber(runsHaving);
String progressString = null;
if (nextLineProgress) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
index 9b88a094..a31e54c4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
@@ -940,7 +940,7 @@ public class RenderListener {
if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) {
String username = tag.getCompoundTag("SkullOwner").getString("Name");
Utils.playPressSound();
- NotEnoughUpdates.profileViewer.getProfileByName(username, profile -> {
+ NotEnoughUpdates.profileViewer.loadPlayerByName(username, profile -> {
if (profile == null) {
Utils.addChatMessage("${RED}Invalid player name/API key. Maybe the API is down? Try /api new.");
} else {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index 55dedadf..72431697 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -715,7 +715,9 @@ public class CustomItemEffects {
NBTTagCompound buildersItem = items.getCompoundTagAt(j);
if (buildersItem.getKeySet().size() > 0) {
String internalname =
- NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(buildersItem.getCompoundTag("tag"));
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery()
+ .withItemNBT(buildersItem.getCompoundTag("tag"))
+ .resolveInternalName();
if (internalname != null && internalname.equals("INFINIDIRT_WAND")) {
return true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index 693bb3e3..fadf8b1b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
@@ -36,6 +37,7 @@ import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.PetLeveling;
import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
@@ -66,15 +68,11 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -283,15 +281,15 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- private static void getAndSetPet(ProfileViewer.Profile profile) {
- Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(profile.getLatestProfile());
- JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
- JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
+ private static void getAndSetPet(SkyblockProfiles profile) {
+ Map<String, ProfileViewer.Level> skyblockInfo = profile.getLatestProfile().getLevelingInfo();
+ Map<String, JsonArray> invInfo = profile.getLatestProfile().getInventoryInfo();
+ JsonObject profileInfo = profile.getLatestProfile().getProfileJson();
if (invInfo != null && profileInfo != null) {
JsonObject stats = profileInfo.get("stats").getAsJsonObject();
boolean hasBeastmasterCrest = false;
Rarity currentBeastRarity = Rarity.COMMON;
- for (JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
+ for (JsonElement talisman : invInfo.get("talisman_bag")) {
if (talisman.isJsonNull()) continue;
String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
if (internalName.startsWith("BEASTMASTER_CREST")) {
@@ -323,7 +321,9 @@ public class PetInfoOverlay extends TextOverlay {
}
}
}
- if (skyblockInfo != null) config.tamingLevel = (int) skyblockInfo.get("taming").level;
+ if (skyblockInfo != null && profile.getLatestProfile().skillsApiEnabled()) {
+ config.tamingLevel = (int) skyblockInfo.get("taming").level;
+ }
//JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
/*JsonObject petsJson = Constants.PETS;
@@ -515,10 +515,9 @@ public class PetInfoOverlay extends TextOverlay {
}
public float getLevelPercent(Pet pet) {
- DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
if (pet == null) return 0;
try {
- return Float.parseFloat(df.format(Math.min(pet.petLevel.getPercentageToNextLevel() * 100f, 100f)));
+ return Float.parseFloat(StringUtils.formatToTenths(Math.min(pet.petLevel.getPercentageToNextLevel() * 100f, 100f)));
} catch (Exception ignored) {
return 0;
}
@@ -1085,13 +1084,13 @@ public class PetInfoOverlay extends TextOverlay {
public String roundFloat(float f) {
if (f % 1 < 0.05f) {
- return NumberFormat.getNumberInstance().format((int) f);
+ return StringUtils.formatNumber((int) f);
} else {
String s = Utils.floatToString(f, 1);
if (s.contains(".")) {
- return NumberFormat.getNumberInstance().format((int) f) + '.' + s.split("\\.")[1];
+ return StringUtils.formatNumber((int) f) + '.' + s.split("\\.")[1];
} else if (s.contains(",")) {
- return NumberFormat.getNumberInstance().format((int) f) + ',' + s.split(",")[1];
+ return StringUtils.formatNumber((int) f) + ',' + s.split(",")[1];
} else {
return s;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
index 907f0f0d..fd9b2938 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PowerStoneStatsDisplay.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
@@ -38,15 +39,12 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
-import java.text.NumberFormat;
import java.util.LinkedList;
import java.util.List;
-import java.util.Locale;
@NEUAutoSubscribe
public class PowerStoneStatsDisplay {
private static PowerStoneStatsDisplay instance = null;
- private final NumberFormat format = NumberFormat.getInstance(Locale.US);
private boolean dirty = true;
public static PowerStoneStatsDisplay getInstance() {
@@ -59,16 +57,14 @@ public class PowerStoneStatsDisplay {
@SubscribeEvent
public void onProfileDataLoaded(ProfileDataLoadedEvent event) {
JsonObject profileInfo = event.getProfileInfo();
-
if (profileInfo == null) return;
- JsonObject inventoryInfo = ProfileViewerUtils.readInventoryInfo(profileInfo, "talisman_bag");
+ JsonArray inventoryInfo = ProfileViewerUtils.readInventoryInfo(profileInfo, "talisman_bag");
if (inventoryInfo == null) return;
NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
if (configProfileSpecific == null) return;
- int powerAmount = ProfileViewerUtils.getMagicalPower(inventoryInfo, profileInfo);
- configProfileSpecific.magicalPower = powerAmount;
+ configProfileSpecific.magicalPower = ProfileViewerUtils.getMagicalPower(inventoryInfo, profileInfo);
}
@SubscribeEvent
@@ -92,8 +88,7 @@ public class PowerStoneStatsDisplay {
String rawNumber = line.split("§6")[1].replace(",", "");
NEUConfig.HiddenProfileSpecific configProfileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
if (configProfileSpecific == null) return;
- int magicalPower = Integer.parseInt(rawNumber);
- configProfileSpecific.magicalPower = magicalPower;
+ configProfileSpecific.magicalPower = Integer.parseInt(rawNumber);
}
}
}
@@ -153,7 +148,7 @@ public class PowerStoneStatsDisplay {
return;
}
- event.toolTip.set(index, "§7At §6" + format.format((double) magicalPower) + " Magical Power§7:");
+ event.toolTip.set(index, "§7At §6" + StringUtils.formatNumber((double) magicalPower) + " Magical Power§7:");
foundMagicalPower = true;
continue;
}
@@ -177,7 +172,7 @@ public class PowerStoneStatsDisplay {
}
double realStat = (currentStat / scaledCurrentPower) * scaledMagicalPower;
- String format = this.format.format((double) Math.round(realStat));
+ String format = StringUtils.formatNumber((double) Math.round(realStat));
format += rawStat.substring(rawStat.length() - 1);
event.toolTip.set(index, line.replace(rawStat, format));
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
index 6d565bb3..4d88ef07 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
@@ -23,6 +23,7 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -46,12 +47,10 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.ByteArrayInputStream;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -75,10 +74,6 @@ public class TradeWindow {
private static String[] theirTradeOld = new String[16];
private static Long[] theirTradeChangesMillis = new Long[16];
- private static ItemStack lastBackpack;
- private static int lastBackpackX;
- private static int lastBackpackY;
-
public static boolean hypixelTradeWindowActive(String containerName) {
return containerName != null && containerName.trim().startsWith("You ");
}
@@ -129,9 +124,8 @@ public class TradeWindow {
JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalName);
if (info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(internalName) &&
info.has("price") && info.has("count")) {
- long auctionPricePer = (long) (info.get("price").getAsDouble() / info.get("count").getAsDouble());
- pricePer = auctionPricePer;
+ pricePer = (long) (info.get("price").getAsDouble() / info.get("count").getAsDouble());
}
}
if (pricePer == -1) {
@@ -293,7 +287,9 @@ public class TradeWindow {
for (int k = 0; k < items.tagCount(); k++) {
if (items.getCompoundTagAt(k).getKeySet().size() > 0) {
NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag");
- String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(nbt);
+ String internalname2 = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery()
+ .withItemNBT(nbt)
+ .resolveInternalName();
if (internalname2 != null) {
long pricePer2 = getPrice(internalname2);
if (pricePer2 > 0) {
@@ -412,7 +408,7 @@ public class TradeWindow {
if (stack == null) continue;
NBTTagCompound tag = stack.getTagCompound();
- String uuid = null;
+ String uuid;
if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
@@ -533,7 +529,7 @@ public class TradeWindow {
if (stack == null) continue;
NBTTagCompound tag = stack.getTagCompound();
- String uuid = null;
+ String uuid;
if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
@@ -820,8 +816,6 @@ public class TradeWindow {
theirPrice += processTopItems(stack, theirTopItems, theirTopItemsStack, theirTopItemsCount);
}
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
GlStateManager.disableLighting();
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
@@ -831,7 +825,7 @@ public class TradeWindow {
drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "Total Value",
guiLeft - 40 - 3, guiTop + 11, 72
);
- drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(ourPrice),
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(ourPrice),
guiLeft - 40 - 3, guiTop + 21, 72
);
@@ -861,7 +855,7 @@ public class TradeWindow {
GlStateManager.disableBlend();
GlStateManager.color(1, 1, 1, 1);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft - 29 - 3,
guiTop + 57 + 18 * ourTopIndex,
52
@@ -875,7 +869,7 @@ public class TradeWindow {
72
);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft - 40 - 3,
guiTop + 56 + 20 * ourTopIndex,
72
@@ -894,7 +888,7 @@ public class TradeWindow {
drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "Total Value",
guiLeft + xSize + 3 + 40, guiTop + 11, 72
);
- drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(theirPrice),
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(theirPrice),
guiLeft + xSize + 3 + 40, guiTop + 21, 72
);
@@ -924,7 +918,7 @@ public class TradeWindow {
GlStateManager.disableBlend();
GlStateManager.color(1, 1, 1, 1);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft + xSize + 3 + 51,
guiTop + 57 + 18 * theirTopIndex,
52
@@ -935,7 +929,7 @@ public class TradeWindow {
guiLeft + xSize + 3 + 40, guiTop + 46 + 20 * theirTopIndex, 72
);
drawStringShadow(
- EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + StringUtils.formatNumber(entry.getKey()),
guiLeft + xSize + 3 + 40,
guiTop + 56 + 20 * theirTopIndex,
72
@@ -1099,15 +1093,12 @@ public class TradeWindow {
if (mouseY >= guiTop + ySize - 19 && mouseY <= guiTop + ySize - 19 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade;
- return;
} else if (mouseY >= guiTop + ySize - 38 && mouseY <= guiTop + ySize - 38 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices;
- return;
} else if (mouseY >= guiTop + ySize - 57 && mouseY <= guiTop + ySize - 57 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
- return;
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java
index deef7bdc..fb936a4d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java
@@ -25,6 +25,7 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GlScissorStack;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
@@ -63,13 +64,11 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Objects;
import java.util.Random;
import java.util.regex.Matcher;
@@ -82,14 +81,10 @@ public class GuiCustomHex extends Gui {
"textures/entity/enchanting_table_book.png");
private static final ModelBook MODEL_BOOK = new ModelBook();
- private static final int EXPERIENCE_ORB_COUNT = 30;
-
private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels");
private static final Pattern ENCHANT_LEVEL_PATTERN = Pattern.compile("(.*)_(.*)");
private static final Pattern ENCHANT_NAME_PATTERN = Pattern.compile("([^IVX]*) ([IVX]*)");
- public static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
-
public class Enchantment {
public int slotIndex;
public String enchantName;
@@ -112,8 +107,10 @@ public class GuiCustomHex extends Gui {
this.level = level;
boolean isUlt = false;
for (String lore : displayLore) {
- if (lore.contains("§l")) isUlt = true;
- break;
+ if (lore.contains("§l")) {
+ isUlt = true;
+ break;
+ }
}
JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(
(isUlt ? "ULTIMATE_" : "") + enchId.toUpperCase() + ";" + level);
@@ -502,7 +499,7 @@ public class GuiCustomHex extends Gui {
int index = 0;
for (String lore : enchantment.displayLore) {
if (lore.contains("N/A") && enchantment.price > 0) {
- String price = numberFormat.format(enchantment.price);
+ String price = StringUtils.formatNumber(enchantment.price);
enchantment.displayLore.set(index, "\u00a76" + price + ".0 Coins");
}
if (lore.contains("Loading...")) {
@@ -1532,7 +1529,7 @@ public class GuiCustomHex extends Gui {
fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false);
fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false);
- String priceStr = "" + numberFormat.format(enchanterCurrentEnch.price) + " Coins";
+ String priceStr = StringUtils.formatNumber(enchanterCurrentEnch.price) + " Coins";
if (enchanterCurrentEnch.price < 0) priceStr = "";
int priceWidth = fr.getStringWidth(priceStr);
int priceTop = guiTop + 16;
@@ -2076,7 +2073,7 @@ public class GuiCustomHex extends Gui {
}
}
- String priceStr = "" + numberFormat.format(enchanterCurrentItem.getPrice()) + " Coins";
+ String priceStr = StringUtils.formatNumber(enchanterCurrentItem.getPrice()) + " Coins";
if (enchanterCurrentItem.price < 0) priceStr = "";
int priceWidth = fr.getStringWidth(priceStr);
int priceTop = guiTop + 10;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java
index 852a2742..1bc08744 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java
@@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.overlays;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.SBInfo;
@@ -34,7 +35,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.util.vector.Vector2f;
-import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -213,11 +213,10 @@ public class CrystalHollowOverlay extends TextOverlay {
if (crystalCheck()) {
int count = getCountCrystal(hidden.crystals);
float percent = (float) count / hidden.crystals.size() * 100;
- DecimalFormat df = new DecimalFormat("#.#");
overlayStrings.add(
EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] +
"Crystals: " + getColor(percent) +
- df.format(percent) + "%");
+ StringUtils.formatToTenths(percent) + "%");
}
break;
case 3:
@@ -334,11 +333,10 @@ public class CrystalHollowOverlay extends TextOverlay {
) {
int count = getCount(parts, inventoryData, storageData);
float percent = (float) count / parts.size() * 100;
- DecimalFormat df = new DecimalFormat("#.#");
overlayStrings.add(
EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " +
getColor(percent) +
- df.format(percent) + "%");
+ StringUtils.formatToTenths(percent) + "%");
}
private EnumChatFormatting getColor(float percent) {
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 266722e5..d6740c0c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
@@ -28,6 +28,7 @@ import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
import io.github.moulberry.notenoughupdates.profileviewer.weight.lily.LilyWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.PronounDB;
import io.github.moulberry.notenoughupdates.util.SBInfo;
@@ -67,7 +68,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
-import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.DECIMAL_FORMAT;
import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt;
public class BasicPage extends GuiProfileViewerPage {
@@ -130,13 +130,12 @@ public class BasicPage extends GuiProfileViewerPage {
@Override
public void drawPage(int mouseX, int mouseY, float partialTicks) {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
+ SkyblockProfiles profile = GuiProfileViewer.getProfile();
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
if (onSecondPage) {
- levelPage.drawPage(mouseX, mouseY);
+ levelPage.drawPage(mouseX, mouseY, partialTicks);
return;
}
@@ -202,8 +201,11 @@ public class BasicPage extends GuiProfileViewerPage {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_basic);
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if (profileInfo == null) return;
+ String profileName = GuiProfileViewer.getProfileName();
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
if (entityPlayer != null && profile.getHypixelProfile() != null) {
String playerName = null;
@@ -251,11 +253,10 @@ public class BasicPage extends GuiProfileViewerPage {
playerName = EnumChatFormatting.GRAY + name;
if (rankName != null) {
- String icon = getIcon(getGameModeType(profileInfo));
+ String icon = selectedProfile.getGamemode() == null ? "" : getIcon(selectedProfile.getGamemode());
playerName =
"\u00A7" + rankColor + "[" + rankName + rankPlusColor + rankPlus + "\u00A7" + rankColor + "] " + name +
(icon.equals("") ? "" : " " + icon);
- ;
}
}
}
@@ -279,50 +280,45 @@ public class BasicPage extends GuiProfileViewerPage {
}
}
- long networth;
+ String stateStr = EnumChatFormatting.RED + "An error occurred";
+ long networth = -2;
ArrayList<String> nwCategoryHover = new ArrayList<>();
if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) {
- ProfileViewer.Profile.SoopyNetworthData nwData = profile.getSoopyNetworth(profileId, () -> {});
- if (nwData == null) {
- networth = -2l;
- } else {
- networth = nwData.getTotal();
-
- for (String category : nwData.getCategories()) {
- if (nwData.getCategory(category) == 0) continue;
-
- nwCategoryHover.add(EnumChatFormatting.GREEN +
- WordUtils.capitalizeFully(category.replace("_", " ")) +
+ SkyblockProfiles.SoopyNetworth nwData = selectedProfile.getSoopyNetworth(() -> {});
+ networth = nwData.getNetworth();
+
+ if (networth == -1) {
+ stateStr = EnumChatFormatting.YELLOW + "Loading...";
+ } else if (networth != -2) { // -2 indicates error
+ for (Map.Entry<String, Long> entry : nwData.getCategoryToTotal().entrySet()) {
+ nwCategoryHover.add(
+ EnumChatFormatting.GREEN +
+ WordUtils.capitalizeFully(entry.getKey().replace("_", " ")) +
": " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(nwData.getCategory(category)));
+ StringUtils.formatNumber(entry.getValue())
+ );
}
-
nwCategoryHover.add("");
}
- } else {
- networth = profile.getNetWorth(profileId);
}
- //Networth is under 0
- //If = -1 -> an error occurred
- //If = -2 -> still loading networth
- String stateStr = EnumChatFormatting.RED + "An error occurred";
+ // Calculate using NEU networth if not using soopy networth or soopy networth errored
if (networth == -2) {
- stateStr = EnumChatFormatting.YELLOW + "Loading...";
- } else if (networth == -1) {
- networth = profile.getNetWorth(profileId);
+ networth = selectedProfile.getNetworth();
}
- int fontWidth = fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth));
- int offset = (fontWidth >= 117 ? 63 + (fontWidth - 117) : 63);
+
if (networth > 0) {
+ int fontWidth = fr.getStringWidth("Net Worth: " + StringUtils.formatNumber(networth));
+ int offset = (fontWidth >= 117 ? 63 + (fontWidth - 117) : 63);
+
if (fontWidth >= 117) {
fr.drawString(EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(networth), guiLeft + 8, guiTop + 38 - fr.FONT_HEIGHT / 2f, 0, true);
+ StringUtils.formatNumber(networth), guiLeft + 8, guiTop + 38 - fr.FONT_HEIGHT / 2f, 0, true);
} else {
Utils.drawStringCentered(
EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(networth),
+ StringUtils.formatNumber(networth),
guiLeft + 68, guiTop + 38, true, 0
);
}
@@ -336,7 +332,7 @@ public class BasicPage extends GuiProfileViewerPage {
.get("avg_buy")
.getAsDouble()
);
- String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round(
+ String networthIRLMoney = StringUtils.formatNumber(Math.round(
((networthInCookies * 325) / 675) * 4.99));
@@ -355,10 +351,10 @@ public class BasicPage extends GuiProfileViewerPage {
if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth
&& profile.getSoopyNetworthLeaderboardPosition() >= 0
- && profile.isProfileMaxSoopyWeight(profile, profileId)) {
+ && profile.isProfileMaxSoopyWeight(profileName)) {
getInstance().tooltipToDisplay.add("");
String lbPosStr =
- EnumChatFormatting.DARK_GREEN + "#" + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(
+ EnumChatFormatting.DARK_GREEN + "#" + EnumChatFormatting.GOLD + StringUtils.formatNumber(
profile.getSoopyNetworthLeaderboardPosition());
getInstance().tooltipToDisplay.add(
lbPosStr + EnumChatFormatting.GREEN + " on soopy's networth leaderboard!");
@@ -472,15 +468,15 @@ public class BasicPage extends GuiProfileViewerPage {
entityPlayer.getDataWatcher().updateObject(10, b);
}
- Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(profileId);
- JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
+ Map<String, ProfileViewer.Level> skyblockInfo = getSelectedProfile().getLevelingInfo();
+ Map<String, JsonArray> inventoryInfo = getSelectedProfile().getInventoryInfo();
if (entityPlayer != null) {
if (backgroundClickedX != -1 && Mouse.isButtonDown(1)) {
Arrays.fill(entityPlayer.inventory.armorInventory, null);
} else {
- if (inventoryInfo != null && inventoryInfo.has("inv_armor")) {
- JsonArray items = inventoryInfo.get("inv_armor").getAsJsonArray();
+ if (inventoryInfo != null && inventoryInfo.containsKey("inv_armor")) {
+ JsonArray items = inventoryInfo.get("inv_armor");
if (items != null && items.size() == 4) {
for (int i = 0; i < entityPlayer.inventory.armorInventory.length; i++) {
JsonElement itemElement = items.get(i);
@@ -531,7 +527,7 @@ public class BasicPage extends GuiProfileViewerPage {
}
GlStateManager.color(1, 1, 1, 1);
- JsonObject petsInfo = profile.getPetsInfo(profileId);
+ JsonObject petsInfo = profile.getProfile(profileName).getPetsInfo();
if (petsInfo != null) {
JsonElement activePetElement = petsInfo.get("active_pet");
if (activePetElement != null && activePetElement.isJsonObject()) {
@@ -582,8 +578,8 @@ public class BasicPage extends GuiProfileViewerPage {
int sbLevelX = guiLeft + 162;
int sbLevelY = guiTop + 90;
- double skyblockLevel = profile.getSkyblockLevel(profileId);
- EnumChatFormatting skyblockLevelColour = profile.getSkyblockLevelColour(profileId);
+ double skyblockLevel = profile.getProfile(profileName).getSkyblockLevel();
+ EnumChatFormatting skyblockLevelColour = profile.getProfile(profileName).getSkyblockLevelColour();
GlStateManager.pushMatrix();
GlStateManager.translate(sbLevelX, sbLevelY, 0);
@@ -607,7 +603,7 @@ public class BasicPage extends GuiProfileViewerPage {
}
}
- if (skyblockInfo != null) {
+ if (skyblockInfo != null && selectedProfile.skillsApiEnabled()) {
int position = 0;
for (Map.Entry<String, ItemStack> entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) {
if (entry.getValue() == null || entry.getKey() == null) {
@@ -653,15 +649,15 @@ public class BasicPage extends GuiProfileViewerPage {
"/" +
StringUtils.shortNumberFormat(maxXp));
}
- String totalXpS = GuiProfileViewer.numberFormat.format((long) level.totalXp);
+ String totalXpS = StringUtils.formatNumber((long) level.totalXp);
tooltipToDisplay.add(EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + totalXpS +
EnumChatFormatting.DARK_GRAY + " (" +
- DECIMAL_FORMAT.format(guiProfileViewer.getPercentage(entry.getKey().toLowerCase(), level)) +
+ StringUtils.formatToTenths(guiProfileViewer.getPercentage(entry.getKey().toLowerCase(), level)) +
"% to " + level.maxLevel + ")");
if (entry.getKey().equals("farming")) {
// double drops + pelts
- int doubleDrops = Utils.getElementAsInt(Utils.getElement(profileInfo, "jacob2.perks.double_drops"), 0);
- int peltCount = Utils.getElementAsInt(Utils.getElement(profileInfo, "trapper_quest.pelt_count"), 0);
+ int doubleDrops = Utils.getElementAsInt(Utils.getElement(selectedProfile.getProfileJson(), "jacob2.perks.double_drops"), 0);
+ int peltCount = Utils.getElementAsInt(Utils.getElement(selectedProfile.getProfileJson(), "trapper_quest.pelt_count"), 0);
if (doubleDrops == 15) {
tooltipToDisplay.add("§7Double Drops: §6" + (doubleDrops * 2) + "%");
@@ -670,7 +666,7 @@ public class BasicPage extends GuiProfileViewerPage {
tooltipToDisplay.add("§7Pelts: §e" + peltCount);
// medals
- JsonObject medals_inv = Utils.getElement(profileInfo, "jacob2.medals_inv").getAsJsonObject();
+ JsonObject medals_inv = Utils.getElement(selectedProfile.getProfileJson(), "jacob2.medals_inv").getAsJsonObject();
tooltipToDisplay.add(" ");
for (String medalName : medalNames) {
String textWithoutFormattingCodes =
@@ -687,12 +683,18 @@ public class BasicPage extends GuiProfileViewerPage {
}
String slayerNameLower = entry.getKey().toLowerCase();
- if (ExtraPage.slayers.containsKey(slayerNameLower)) {
- int maxLevel = ExtraPage.slayers.get(slayerNameLower);
+ if (Weight.SLAYER_NAMES.contains(slayerNameLower)) {
+ JsonObject slayerToTier = Constants.LEVELING.getAsJsonObject("slayer_to_highest_tier");
+ if (slayerToTier == null) {
+ Utils.showOutdatedRepoNotification();
+ return;
+ }
+
+ int maxLevel = slayerToTier.get(slayerNameLower).getAsInt();
for (int i = 0; i < 5; i++) {
if (i >= maxLevel) break;
float tier = Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "slayer_bosses." + slayerNameLower + ".boss_kills_tier_" + i),
+ Utils.getElement(selectedProfile.getProfileJson(), "slayer_bosses." + slayerNameLower + ".boss_kills_tier_" + i),
0
);
tooltipToDisplay.add(EnumChatFormatting.GRAY + "T" + (i + 1) + " Kills: " +
@@ -718,7 +720,9 @@ public class BasicPage extends GuiProfileViewerPage {
}
drawSideButtons();
- if (NotEnoughUpdates.INSTANCE.config.profileViewer.displayWeight) renderWeight(mouseX, mouseY, skyblockInfo, profileInfo);
+ if (NotEnoughUpdates.INSTANCE.config.profileViewer.displayWeight) {
+ renderWeight(mouseX, mouseY, selectedProfile);
+ }
}
private String getIcon(String gameModeType) {
@@ -761,15 +765,19 @@ public class BasicPage extends GuiProfileViewerPage {
private void renderWeight(
int mouseX,
int mouseY,
- Map<String, ProfileViewer.Level> skyblockInfo,
- JsonObject profileInfo
+ SkyblockProfiles.SkyblockProfile selectedProfile
) {
+ if (!selectedProfile.skillsApiEnabled()) {
+ return;
+ }
+
+ Map<String, ProfileViewer.Level> skyblockInfo = selectedProfile.getLevelingInfo();
if (skyblockInfo == null) {
return;
}
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
+ SkyblockProfiles profile = GuiProfileViewer.getProfile();
+ String profileName = GuiProfileViewer.getProfileName();
if (Constants.WEIGHT == null || Utils.getElement(Constants.WEIGHT, "lily.skills.overall") == null ||
!Utils.getElement(Constants.WEIGHT, "lily.skills.overall").isJsonPrimitive()) {
@@ -782,7 +790,7 @@ public class BasicPage extends GuiProfileViewerPage {
int guiTop = GuiProfileViewer.getGuiTop();
SenitherWeight senitherWeight = new SenitherWeight(skyblockInfo);
- LilyWeight lilyWeight = new LilyWeight(skyblockInfo, profileInfo);
+ LilyWeight lilyWeight = new LilyWeight(skyblockInfo, selectedProfile.getProfileJson());
long weight = -2L;
if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) {
@@ -793,13 +801,13 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Senither Weight: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())),
+ StringUtils.formatNumber(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())),
guiLeft + 63, guiTop + 18, true, 0
);
int textWidth = fr.getStringWidth(
"Senither Weight: " +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw()))
+ StringUtils.formatNumber(roundToNearestInt(senitherWeight.getTotalWeight().getRaw()))
);
if (mouseX > guiLeft + 63 - textWidth / 2 && mouseX < guiLeft + 63 + textWidth / 2) {
if (mouseY > guiTop + 12 && mouseY < guiTop + 12 + fr.FONT_HEIGHT) {
@@ -809,7 +817,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Skills: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight
+ StringUtils.formatNumber(roundToNearestInt(senitherWeight
.getSkillsWeight()
.getWeightStruct()
.getRaw()))
@@ -819,7 +827,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Slayer: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight
+ StringUtils.formatNumber(roundToNearestInt(senitherWeight
.getSlayerWeight()
.getWeightStruct()
.getRaw()))
@@ -829,16 +837,16 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Dungeons: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(
+ StringUtils.formatNumber(
roundToNearestInt(senitherWeight.getDungeonsWeight().getWeightStruct().getRaw())
)
);
if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth
- && profile.isProfileMaxSoopyWeight(profile, profileId)) {
+ && profile.isProfileMaxSoopyWeight(profileName)) {
String lbPosStr =
- EnumChatFormatting.DARK_GREEN + "#" + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(
+ EnumChatFormatting.DARK_GREEN + "#" + EnumChatFormatting.GOLD + StringUtils.formatNumber(
profile.getSoopyWeightLeaderboardPosition());
getInstance().tooltipToDisplay.add("");
String stateStr = EnumChatFormatting.RED + "An error occurred";
@@ -856,12 +864,12 @@ public class BasicPage extends GuiProfileViewerPage {
Utils.drawStringCentered(
EnumChatFormatting.GREEN +
"Lily Weight: " + EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())),
+ StringUtils.formatNumber(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())),
guiLeft + 63, guiTop + 28, true, 0
);
int fontWidth = fr.getStringWidth(
- "Lily Weight: " + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw()))
+ "Lily Weight: " + StringUtils.formatNumber(roundToNearestInt(lilyWeight.getTotalWeight().getRaw()))
);
if (mouseX > guiLeft + 63 - fontWidth / 2 && mouseX < guiLeft + 63 + fontWidth / 2) {
if (mouseY > guiTop + 22 && mouseY < guiTop + 22 + fr.FONT_HEIGHT) {
@@ -871,7 +879,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Skills: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight
+ StringUtils.formatNumber(roundToNearestInt(lilyWeight
.getSkillsWeight()
.getWeightStruct()
.getRaw()))
@@ -881,7 +889,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Slayer: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight
+ StringUtils.formatNumber(roundToNearestInt(lilyWeight
.getSlayerWeight()
.getWeightStruct()
.getRaw()))
@@ -891,7 +899,7 @@ public class BasicPage extends GuiProfileViewerPage {
EnumChatFormatting.GREEN +
"Dungeons: " +
EnumChatFormatting.GOLD +
- GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight
+ StringUtils.formatNumber(roundToNearestInt(lilyWeight
.getDungeonsWeight()
.getWeightStruct()
.getRaw()))
@@ -974,13 +982,6 @@ public class BasicPage extends GuiProfileViewerPage {
return 0;
}
- public String getGameModeType(JsonObject profileInfo) {
- if (profileInfo != null && profileInfo.has("game_mode")) {
- return profileInfo.get("game_mode").getAsString();
- }
- return "";
- }
-
public void drawSideButtons() {
GlStateManager.enableDepth();
GlStateManager.translate(0, 0, 5);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java
index cc5fc92f..fa14ad52 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java
@@ -52,8 +52,7 @@ public class BingoPage extends GuiProfileViewerPage {
@Override
public void drawPage(int mouseX, int mouseY, float partialTicks) {
- processBingoResources();
- JsonObject bingoInfo = GuiProfileViewer.getProfile().getBingoInformation();
+ loadBingoResources();
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledResolution.getScaledWidth();
@@ -61,12 +60,19 @@ public class BingoPage extends GuiProfileViewerPage {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
- //check if the player has created a bingo profile for the current event
+
+ JsonObject bingoInfo = GuiProfileViewer.getProfile().getBingoInformation();
+ // Check if the player has created a bingo profile for the current event
if (bingoInfo == null) {
showMissingDataMessage(guiLeft, guiTop);
return;
}
+ // Bingo goals data not loaded yet
+ if (bingoGoals == null) {
+ return;
+ }
+
JsonArray events = bingoInfo.get("events").getAsJsonArray();
JsonObject lastEvent = events.get(events.size() - 1).getAsJsonObject();
int lastParticipatedId = lastEvent.get("key").getAsInt();
@@ -304,7 +310,7 @@ public class BingoPage extends GuiProfileViewerPage {
return list;
}
- private void processBingoResources() {
+ private void loadBingoResources() {
long currentTime = System.currentTimeMillis();
//renew every 2 minutes
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java
index 03be7cf1..da90843a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java
@@ -37,16 +37,15 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
import java.math.BigInteger;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
+
+import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_elements;
public class CollectionsPage extends GuiProfileViewerPage {
- public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png");
- public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
+ private static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png");
private static final int COLLS_XCOUNT = 5;
private static final int COLLS_YCOUNT = 4;
private static final float COLLS_XPADDING = (190 - COLLS_XCOUNT * 20) / (float) (COLLS_XCOUNT + 1);
@@ -72,7 +71,6 @@ public class CollectionsPage extends GuiProfileViewerPage {
"XIX",
"XX",
};
- private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
private static List<String> tooltipToDisplay = null;
private static ItemStack selectedCollectionCategory = null;
private int page = 0;
@@ -89,8 +87,17 @@ public class CollectionsPage extends GuiProfileViewerPage {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_cols);
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
- ProfileCollectionInfo collectionInfo =
- GuiProfileViewer.getProfile().getCollectionInfo(GuiProfileViewer.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ JsonObject resourceCollectionInfo = ProfileViewer.getOrLoadCollectionsResource();
+ if (resourceCollectionInfo == null) {
+ return;
+ }
+
+ ProfileCollectionInfo collectionInfo = selectedProfile.getCollectionInfo();
if (collectionInfo == null) {
Utils.drawStringCentered(
EnumChatFormatting.RED + "Collection API not enabled!",
@@ -99,9 +106,6 @@ public class CollectionsPage extends GuiProfileViewerPage {
return;
}
- JsonObject resourceCollectionInfo = ProfileViewer.getResourceCollectionInformation();
- if (resourceCollectionInfo == null) return;
-
int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f));
{
@@ -274,19 +278,17 @@ public class CollectionsPage extends GuiProfileViewerPage {
tierString
);
tooltipToDisplay.add(
- "Collected: " + numberFormat.format(thisCollection.getPersonalCollectionCount())
+ "Collected: " + StringUtils.formatNumber(thisCollection.getPersonalCollectionCount())
);
- tooltipToDisplay.add("Total Collected: " + numberFormat.format(amount));
+ tooltipToDisplay.add("Total Collected: " + StringUtils.formatNumber(amount));
}
}
GlStateManager.color(1, 1, 1, 1);
- if (tier >= 0) {
- Utils.drawStringCentered(tierString, guiLeft + x + 10, guiTop + y - 4, true, tierStringColour);
- }
+ Utils.drawStringCentered(tierString, guiLeft + x + 10, guiTop + y - 4, true, tierStringColour);
Utils.drawStringCentered(
- StringUtils.shortNumberFormat(amount) + "", guiLeft + x + 10, guiTop + y + 26, true, color.getRGB());
+ StringUtils.shortNumberFormat(amount), guiLeft + x + 10, guiTop + y + 26, true, color.getRGB());
}
}
@@ -402,16 +404,16 @@ public class CollectionsPage extends GuiProfileViewerPage {
switch (keyCode) {
case Keyboard.KEY_5:
case Keyboard.KEY_NUMPAD5:
- stack = items.next();
+ items.next();
case Keyboard.KEY_4:
case Keyboard.KEY_NUMPAD4:
- stack = items.next();
+ items.next();
case Keyboard.KEY_3:
case Keyboard.KEY_NUMPAD3:
- stack = items.next();
+ items.next();
case Keyboard.KEY_2:
case Keyboard.KEY_NUMPAD2:
- stack = items.next();
+ items.next();
case Keyboard.KEY_1:
case Keyboard.KEY_NUMPAD1:
stack = items.next();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java
index 454ad989..ab2f9d59 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java
@@ -104,9 +104,13 @@ public class CrimsonIslePage extends GuiProfileViewerPage {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
- JsonObject profileInfo = GuiProfileViewer.getProfile().getProfileInformation(GuiProfileViewer.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
- if (profileInfo == null || !profileInfo.has("nether_island_player_data")) {
+ JsonObject profileInfo = selectedProfile.getProfileJson();
+ if (!profileInfo.has("nether_island_player_data")) {
Utils.drawStringCentered(
EnumChatFormatting.RED + "No data found for the Crimson Isles",
guiLeft + 431 / 2f, guiTop + 101, true, 0
@@ -204,33 +208,26 @@ public class CrimsonIslePage extends GuiProfileViewerPage {
public void drawDojoStats(JsonObject data, int guiLeft, int guiTop) {
Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Dojo Stats", guiLeft + (431 * 0.49f), guiTop + 14, true, 0);
- JsonObject dojoStats = data.getAsJsonObject("dojo");
- int[] dojoScores = {0, 0, 0, 0, 0, 0, 0};
- int pointsTotal = 0;
-
- for (int i = 0; i < apiDojoTestNames.size(); i++) {
- for (Map.Entry<String, JsonElement> dojoData : dojoStats.entrySet()) {
- if (dojoData.getKey().equals("dojo_points_" + apiDojoTestNames.keySet().toArray()[i])) {
- dojoScores[i] = dojoData.getValue().getAsInt();
- pointsTotal += dojoData.getValue().getAsInt();
- }
- }
- }
- for (int i = 0; i < apiDojoTestNames.size(); i++) {
+ int totalPoints = 0;
+ int idx = 0;
+ for (Map.Entry<String, String> dojoTest : apiDojoTestNames.entrySet()) {
+ int curPoints = Utils.getElementAsInt(data.get("dojo.dojo_points_" + dojoTest.getKey()), 0);
+ totalPoints += curPoints;
Utils.renderAlignedString(
- apiDojoTestNames.get(apiDojoTestNames.keySet().toArray()[i]) + ": ",
- EnumChatFormatting.WHITE + String.valueOf(dojoScores[i]) + " (" +
- dojoGrades[(dojoScores[i] / 200) >= 6 ? 5 : (dojoScores[i] / 200)] + ")",
+ dojoTest.getValue() + ": ",
+ EnumChatFormatting.WHITE + "" + curPoints + " (" +
+ dojoGrades[(curPoints / 200) >= 6 ? 5 : (curPoints / 200)] + ")",
guiLeft + (431 * 0.49f) - 65,
- guiTop + 30 + (i * 12),
+ guiTop + 30 + (idx * 12),
130
);
+ idx ++;
}
Utils.renderAlignedString(
EnumChatFormatting.GRAY + "Points: ",
- EnumChatFormatting.GOLD + String.valueOf(pointsTotal),
+ EnumChatFormatting.GOLD + String.valueOf(totalPoints),
guiLeft + (431 * 0.49f) - 65,
guiTop + 40 + (apiDojoTestNames.size() * 12),
130
@@ -238,7 +235,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage {
Utils.renderAlignedString(
EnumChatFormatting.GRAY + "Rank: ",
- getRank(pointsTotal),
+ getRank(totalPoints),
guiLeft + (431 * 0.49f) - 65,
guiTop + 52 + (apiDojoTestNames.size() * 12),
130
@@ -246,9 +243,9 @@ public class CrimsonIslePage extends GuiProfileViewerPage {
Utils.renderAlignedString(
EnumChatFormatting.GRAY + "Points to next: ",
- getPointsToNextRank(pointsTotal) == 0
+ getPointsToNextRank(totalPoints) == 0
? EnumChatFormatting.GOLD + "MAXED!"
- : String.valueOf(getPointsToNextRank(pointsTotal)),
+ : String.valueOf(getPointsToNextRank(totalPoints)),
guiLeft + (431 * 0.49f) - 65,
guiTop + 64 + (apiDojoTestNames.size() * 12),
130
@@ -263,7 +260,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage {
}
lastRank = rank.getKey();
}
- return dojoPointsToRank.get(dojoPointsToRank.keySet().toArray()[dojoPointsToRank.size() - 1]);
+ return dojoPointsToRank.get(lastRank);
}
public int getPointsToNextRank(int pointsTotal) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java
index 4b49d053..66c7c2a1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java
@@ -27,6 +27,7 @@ import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -40,6 +41,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
+import org.apache.commons.lang3.text.WordUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -47,21 +49,21 @@ import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.UUID;
public class DungeonPage extends GuiProfileViewerPage {
private static final ResourceLocation pv_dung = new ResourceLocation("notenoughupdates:pv_dung.png");
private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush));
- private static final String[] dungSkillsName = {"Healer", "Mage", "Berserk", "Archer", "Tank"};
private static final ItemStack[] BOSS_HEADS = new ItemStack[7];
- private static final ItemStack[] dungSkillsStack = {
- new ItemStack(Items.potionitem, 1, 16389),
- new ItemStack(Items.blaze_rod),
- new ItemStack(Items.iron_sword),
- new ItemStack(Items.bow),
- new ItemStack(Items.leather_chestplate),
- };
+ private static final Map<String, ItemStack> classToIcon = new HashMap<String, ItemStack>() {{
+ put("healer", new ItemStack(Items.potionitem, 1, 16389));
+ put("mage", new ItemStack(Items.blaze_rod));
+ put("berserk", new ItemStack(Items.iron_sword));
+ put("archer", new ItemStack(Items.bow));
+ put("tank", new ItemStack(Items.leather_chestplate));
+ }};
private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"};
private static final String[] bossFloorHeads = {
"12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c",
@@ -72,7 +74,6 @@ public class DungeonPage extends GuiProfileViewerPage {
"fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc",
"a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a",
};
-
private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<String, ItemStack>() {
{
put(
@@ -99,9 +100,6 @@ public class DungeonPage extends GuiProfileViewerPage {
};
private static int floorTime = 7;
- private final HashMap<String, HashMap<String, ProfileViewer.Level>> levelObjClasseses = new HashMap<>();
-
- private final HashMap<String, ProfileViewer.Level> levelObjCatas = new HashMap<>();
private final GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
private int floorLevelTo = -1;
private long floorLevelToXP = -1;
@@ -120,17 +118,19 @@ public class DungeonPage extends GuiProfileViewerPage {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dung);
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
- JsonObject hypixelInfo = profile.getHypixelProfile();
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if (profileInfo == null) return;
-
JsonObject leveling = Constants.LEVELING;
if (leveling == null) return;
- int sectionWidth = 110;
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+ Map<String, ProfileViewer.Level> levelingInfo = selectedProfile.getLevelingInfo();
+ JsonObject profileInfo = selectedProfile.getProfileJson();
+ JsonObject hypixelInfo = GuiProfileViewer.getProfile().getHypixelProfile();
+
+ int sectionWidth = 110;
String dungeonString = onMasterMode ? "master_catacombs" : "catacombs";
Utils.renderShadowedString(
@@ -140,28 +140,14 @@ public class DungeonPage extends GuiProfileViewerPage {
sectionWidth
);
- ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId);
- //Catacombs level thingy
+ ProfileViewer.Level levelObjCata = levelingInfo.get("cosmetic_catacombs");
{
- if (levelObjCata == null) {
- float cataXp = getElementAsFloat(profileInfo, "dungeons.dungeon_types.catacombs.experience");
- levelObjCata =
- ProfileViewer.getLevel(
- Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(),
- cataXp,
- 99,
- false
- );
- levelObjCata.totalXp = cataXp;
- levelObjCatas.put(profileId, levelObjCata);
- }
-
String skillName = EnumChatFormatting.RED + "Catacombs";
float level = levelObjCata.level;
int levelFloored = (int) Math.floor(level);
if (floorLevelTo == -1 && levelFloored >= 0) {
- dungeonLevelTextField.setText("" + (levelFloored + 1));
+ dungeonLevelTextField.setText(String.valueOf(levelFloored + 1));
calculateFloorLevelXP();
}
@@ -267,56 +253,12 @@ public class DungeonPage extends GuiProfileViewerPage {
}
if (mouseX > x && mouseX < x + sectionWidth && mouseY > y + 16 && mouseY < y + 24 && onMasterMode) {
- float M3 =
- (
- Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions." + 3),
- 0
- )
- );
- float M4 =
- (
- Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions." + 4),
- 0
- )
- );
- float M5 =
- (
- Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions." + 5),
- 0
- )
- ); //this can prob be done better
- float M6 =
- (
- Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions." + 6),
- 0
- )
- );
- float M7 =
- (
- Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions." + 7),
- 0
- )
- );
- if (M3 > 50) {
- M3 = 50;
- }
- if (M4 > 50) {
- M4 = 50;
- }
- if (M5 > 50) {
- M5 = 50;
- }
- if (M6 > 50) {
- M6 = 50;
- }
- if (M7 > 50) {
- M7 = 50;
- }
+ float M3 = Math.min(getElementAsFloat(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions.3"), 50);
+ float M4 = Math.min(getElementAsFloat(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions.4"), 50);
+ float M5 = Math.min(getElementAsFloat(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions.5"), 50);
+ float M6 = Math.min(getElementAsFloat(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions.6"), 50);
+ float M7 = Math.min(getElementAsFloat(profileInfo, "dungeons.dungeon_types.master_catacombs.tier_completions.7"), 50);
+
float xpM3 = 35000 * (M3 / 100 + 1);
float xpM4 = 55000 * (M4 / 100 + 1);
float xpM5 = 70000 * (M5 / 100 + 1);
@@ -403,8 +345,7 @@ public class DungeonPage extends GuiProfileViewerPage {
100
);
- //Random stats
-
+ // Random stats
float secrets = -1;
if (hypixelInfo != null) {
secrets = Utils.getElementAsFloat(Utils.getElement(hypixelInfo, "achievements.skyblock_treasure_hunter"), 0);
@@ -484,12 +425,9 @@ public class DungeonPage extends GuiProfileViewerPage {
int y3 = y + 117;
for (int i = 1; i <= 7; i++) {
- int w = fontRendererObj.getStringWidth("" + i);
-
+ int w = fontRendererObj.getStringWidth(String.valueOf(i));
int bx = x + sectionWidth * i / 8 - w / 2;
-
GlStateManager.color(1, 1, 1, 1);
-
Utils.renderShadowedString(EnumChatFormatting.WHITE.toString() + i, bx + w / 2, y3, 10);
}
@@ -583,13 +521,11 @@ public class DungeonPage extends GuiProfileViewerPage {
}
}
- //Skills
+ // Classes
{
int x = guiLeft + 298;
int y = guiTop + 27;
- //Gui.drawRect(x, y, x+120, y+147, 0xffffffff);
-
Utils.renderShadowedString(
EnumChatFormatting.DARK_PURPLE + "Class Levels",
x + sectionWidth / 2,
@@ -603,47 +539,18 @@ public class DungeonPage extends GuiProfileViewerPage {
activeClass = activeClassElement.getAsString();
}
- ProfileViewer.Level classAverage = new ProfileViewer.Level();
-
- for (int i = 0; i < dungSkillsName.length; i++) {
- String skillName = dungSkillsName[i];
-
- HashMap<String, ProfileViewer.Level> levelObjClasses = levelObjClasseses.computeIfAbsent(
- profileId,
- k -> new HashMap<>()
- );
- if (!levelObjClasses.containsKey(skillName)) {
- float cataXp = getElementAsFloat(profileInfo, "dungeons.player_classes." + skillName.toLowerCase() + ".experience");
- ProfileViewer.Level levelObj = ProfileViewer.getLevel(
- Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(),
- cataXp,
- 50,
- false
- );
-
- if (levelObj.level == 50) {
- levelObj.level = 50 + (cataXp - 569809640) / 200000000;
- }
-
- levelObjClasses.put(skillName, levelObj);
- }
-
- classAverage.level = (float) (levelObjClasses.values().stream().mapToDouble(l -> Math.min(50, l.level)).sum() / 5);
- if (classAverage.level >= 50) {
- classAverage.maxed = true;
- }
-
- String colour = EnumChatFormatting.WHITE.toString();
- if (skillName.toLowerCase().equals(activeClass)) {
- colour = EnumChatFormatting.GREEN.toString();
- }
+ float classLevelSum = 0;
+ for (int i = 0; i < Weight.DUNGEON_CLASS_NAMES.size(); i++) {
+ String className = Weight.DUNGEON_CLASS_NAMES.get(i);
- ProfileViewer.Level levelObj = levelObjClasses.get(skillName);
+ classLevelSum += levelingInfo.get(className).level;
+ String colour = className.equalsIgnoreCase(activeClass) ? EnumChatFormatting.GREEN.toString() : EnumChatFormatting.WHITE.toString();
+ ProfileViewer.Level levelObj = levelingInfo.get("cosmetic_" + className);
getInstance()
.renderXpBar(
- colour + skillName,
- dungSkillsStack[i],
+ colour + WordUtils.capitalizeFully(className),
+ classToIcon.get(className),
x,
y + 20 + 24 * i,
sectionWidth,
@@ -653,6 +560,12 @@ public class DungeonPage extends GuiProfileViewerPage {
);
}
+ ProfileViewer.Level classAverage = new ProfileViewer.Level();
+ classAverage.level = classLevelSum / Weight.DUNGEON_CLASS_NAMES.size();
+ if (classAverage.level >= 50) {
+ classAverage.maxed = true;
+ }
+
getInstance().renderXpBar(
EnumChatFormatting.WHITE + "Class Average",
new ItemStack(Items.nether_star),
@@ -705,7 +618,7 @@ public class DungeonPage extends GuiProfileViewerPage {
if (mouseY >= y - 2 && mouseY <= y + 9) {
for (int i = 1; i <= 7; i++) {
- int w = fontRendererObj.getStringWidth("" + i);
+ int w = fontRendererObj.getStringWidth(String.valueOf(i));
int x = guiLeft + 23 + 110 * i / 8 - w / 2;
@@ -752,14 +665,15 @@ public class DungeonPage extends GuiProfileViewerPage {
private void calculateFloorLevelXP() {
JsonObject leveling = Constants.LEVELING;
if (leveling == null) return;
- ProfileViewer.Level levelObjCata = levelObjCatas.get(GuiProfileViewer.getProfileId());
- if (levelObjCata == null) return;
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) return;
+ ProfileViewer.Level levelObjCata = selectedProfile.getLevelingInfo().get("cosmetic_catacombs");
try {
dungeonLevelTextField.setCustomBorderColour(0xffffffff);
floorLevelTo = Integer.parseInt(dungeonLevelTextField.getText());
- JsonArray levelingArray = Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray();
+ JsonArray levelingArray = leveling.getAsJsonArray("catacombs");
float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
index 90ffd388..d08e96a3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
@@ -25,6 +25,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -41,7 +42,6 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -51,13 +51,23 @@ import java.util.TimeZone;
import java.util.TreeMap;
public class ExtraPage extends GuiProfileViewerPage {
-// Hehe
+
private static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png");
+ private static final List<String> skills = Arrays.asList(
+ "taming",
+ "mining",
+ "foraging",
+ "enchanting",
+ "farming",
+ "combat",
+ "fishing",
+ "alchemy",
+ "carpentry"
+ ); // TODO: why is this hardcoded
private TreeMap<Integer, Set<String>> topKills = null;
private TreeMap<Integer, Set<String>> topDeaths = null;
private int deathScroll = 0;
private int killScroll = 0;
- private int mouseDWheel = 0;
public ExtraPage(GuiProfileViewer instance) {
super(instance);
@@ -77,9 +87,8 @@ public class ExtraPage extends GuiProfileViewerPage {
@Override
public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
- //Note: don't know why it made me make it return a boolean, but it fixed the error, so I left it alone.
- //Dimensions: X: guiLeft + xStart + xOffset * 3, Y: guiTop + yStartBottom + 77, Width: 80, Height: 12
+ // Dimensions: X: guiLeft + xStart + xOffset * 3, Y: guiTop + yStartBottom + 77, Width: 80, Height: 12
if (mouseX >= GuiProfileViewer.getGuiLeft() + 22 + 103 * 3 &&
mouseX <= GuiProfileViewer.getGuiLeft() + 22 + 103 * 3 + 80 &&
mouseY >= GuiProfileViewer.getGuiTop() + 105 + 77 && mouseY <= GuiProfileViewer.getGuiTop() + 105 + 77 + 12) {
@@ -93,17 +102,6 @@ public class ExtraPage extends GuiProfileViewerPage {
return false;
}
- // pls update in the future tyvm !!!
- public final static HashMap<String, Integer> slayers = new HashMap<String, Integer>() {
- {
- put("zombie", 5);
- put("spider", 4);
- put("wolf", 4);
- put("enderman", 4);
- put("blaze", 4);
- }
- };
-
public void drawEssence(
JsonObject profileInfo,
float xStart,
@@ -113,16 +111,17 @@ public class ExtraPage extends GuiProfileViewerPage {
float mouseX,
float mouseY
) {
- int guiLeft = GuiProfileViewer.getGuiLeft();
- int guiTop = GuiProfileViewer.getGuiTop();
- yStartTop += 77;
if (Constants.PARENTS == null || !Constants.PARENTS.has("ESSENCE_WITHER")) {
Utils.showOutdatedRepoNotification();
return;
}
- JsonObject parents = Constants.PARENTS;
+
+ int guiLeft = GuiProfileViewer.getGuiLeft();
+ int guiTop = GuiProfileViewer.getGuiTop();
+ yStartTop += 77;
+
JsonArray essenceArray = new JsonArray();
- essenceArray.addAll(parents.get("ESSENCE_WITHER").getAsJsonArray());
+ essenceArray.addAll(Constants.PARENTS.get("ESSENCE_WITHER").getAsJsonArray());
//add wither essence since it's not part of the parents array
essenceArray.add(new JsonPrimitive("ESSENCE_WITHER"));
@@ -146,6 +145,7 @@ public class ExtraPage extends GuiProfileViewerPage {
guiTop + yStartTop + (yOffset - 1) * i,
76
);
+
if (Constants.ESSENCESHOPS == null) return;
JsonObject essenceShops = Constants.ESSENCESHOPS;
if (mouseX >= guiLeft + xStart + xOffset && mouseX <= guiLeft + xStart + xOffset + 76 &&
@@ -166,7 +166,6 @@ public class ExtraPage extends GuiProfileViewerPage {
String name = entry.getValue().getAsJsonObject().get("name").getAsString();
getInstance().tooltipToDisplay.add(EnumChatFormatting.GOLD + name + ": " + formatting + perkTier + "/" + max);
}
-
}
}
}
@@ -179,11 +178,13 @@ public class ExtraPage extends GuiProfileViewerPage {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_extra);
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if (profileInfo == null) return;
- Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(profileId);
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ JsonObject profileInfo = selectedProfile.getProfileJson();
+ Map<String, ProfileViewer.Level> skyblockInfo = selectedProfile.getLevelingInfo();
float xStart = 22;
float xOffset = 103;
@@ -221,7 +222,7 @@ public class ExtraPage extends GuiProfileViewerPage {
);
}
}
- JsonObject guildInfo = profile.getGuildInformation(null);
+ JsonObject guildInfo = GuiProfileViewer.getProfile().getOrLoadGuildInformation(null);
boolean shouldRenderGuild = guildInfo != null && guildInfo.has("name");
{
if (shouldRenderGuild) {
@@ -266,24 +267,12 @@ public class ExtraPage extends GuiProfileViewerPage {
float totalSlayerCount = 0;
float totalSlayerXP = 0;
- List<String> skills = Arrays.asList(
- "taming",
- "mining",
- "foraging",
- "enchanting",
- "farming",
- "combat",
- "fishing",
- "alchemy",
- "carpentry"
- );
-
for (Map.Entry<String, ProfileViewer.Level> entry : skyblockInfo.entrySet()) {
if (skills.contains(entry.getKey())) {
totalSkillLVL += entry.getValue().level;
totalTrueSkillLVL += Math.floor(entry.getValue().level);
totalSkillCount++;
- } else if (slayers.containsKey(entry.getKey())) {
+ } else if (Weight.SLAYER_NAMES.contains(entry.getKey())) {
totalSlayerLVL += entry.getValue().level;
totalSlayerCount++;
totalSlayerXP += entry.getValue().totalXp;
@@ -296,7 +285,9 @@ public class ExtraPage extends GuiProfileViewerPage {
Utils.renderAlignedString(
EnumChatFormatting.RED + "AVG Skill Level",
- EnumChatFormatting.WHITE.toString() + Math.floor(avgSkillLVL * 10) / 10,
+ selectedProfile.skillsApiEnabled() ?
+ EnumChatFormatting.WHITE.toString() + Math.floor(avgSkillLVL * 10) / 10 :
+ EnumChatFormatting.RED + "Skills API not enabled!",
guiLeft + xStart,
guiTop + yStartBottom + yOffset,
76
@@ -304,7 +295,9 @@ public class ExtraPage extends GuiProfileViewerPage {
Utils.renderAlignedString(
EnumChatFormatting.RED + "True AVG Skill Level",
- EnumChatFormatting.WHITE.toString() + Math.floor(avgTrueSkillLVL * 10) / 10,
+ selectedProfile.skillsApiEnabled() ?
+ EnumChatFormatting.WHITE.toString() + Math.floor(avgTrueSkillLVL * 10) / 10 :
+ EnumChatFormatting.RED + "Skills API not enabled!",
guiLeft + xStart,
guiTop + yStartBottom + yOffset * 2,
76
@@ -532,7 +525,7 @@ public class ExtraPage extends GuiProfileViewerPage {
}
}
- mouseDWheel = Mouse.getDWheel();
+ int mouseDWheel = Mouse.getDWheel();
if (mouseX >= killDeathX && mouseX <= killDeathX + 76) {
if (mouseY >= guiTop + yStartTop && mouseY <= guiTop + yStartTop + 65) {
if (mouseDWheel > 0) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index a5229acb..5dabdeaa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -19,8 +19,6 @@
package io.github.moulberry.notenoughupdates.profileviewer;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
@@ -29,6 +27,7 @@ import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage;
import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishPage;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.DungeonsWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.SkillsWeight;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
import io.github.moulberry.notenoughupdates.util.AsyncDependencyLoader;
import io.github.moulberry.notenoughupdates.util.PronounDB;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -53,15 +52,13 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL20;
+import javax.annotation.Nullable;
import java.awt.*;
import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
@@ -72,12 +69,12 @@ public class GuiProfileViewer extends GuiScreen {
public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png");
public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
- public static final ResourceLocation pv_ironman = new ResourceLocation("notenoughupdates:pv_ironman.png");
- public static final ResourceLocation pv_bingo = new ResourceLocation("notenoughupdates:pv_bingo.png");
-
- public final static DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.#");
- public static final ResourceLocation pv_stranded = new ResourceLocation("notenoughupdates:pv_stranded.png");
- public static final ResourceLocation pv_unknown = new ResourceLocation("notenoughupdates:pv_unknown.png");
+ private static final Map<String, ResourceLocation> gamemodeToIcon = new HashMap<String, ResourceLocation>() {{
+ put("ironman", new ResourceLocation("notenoughupdates:pv_ironman.png"));
+ put("bingo", new ResourceLocation("notenoughupdates:pv_bingo.png"));
+ put("island", new ResourceLocation("notenoughupdates:pv_stranded.png")); // Stranded
+ }};
+ private static final ResourceLocation gamemodeIconUnknown = new ResourceLocation("notenoughupdates:pv_unknown.png");
public static final ResourceLocation resource_packs =
new ResourceLocation("minecraft:textures/gui/resource_packs.png");
public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png");
@@ -140,12 +137,7 @@ public class GuiProfileViewer extends GuiScreen {
);
}
};
-
- public static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
-
- private static final char[] c = new char[]{'k', 'm', 'b', 't'};
- public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC;
- public static HashMap<String, String> MINION_RARITY_TO_NUM = new HashMap<String, String>() {
+ public static final HashMap<String, String> RARITY_TO_NUM = new HashMap<String, String>() {
{
put("COMMON", "0");
put("UNCOMMON", "1");
@@ -155,10 +147,11 @@ public class GuiProfileViewer extends GuiScreen {
put("MYTHIC", "5");
}
};
+ public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC;
private static int guiLeft;
private static int guiTop;
- private static ProfileViewer.Profile profile;
- private static String profileId = null;
+ private static SkyblockProfiles profile;
+ private static String profileName = null;
public static AsyncDependencyLoader<Optional<PronounDB.PronounChoice>> pronouns =
AsyncDependencyLoader.withEqualsInvocation(
() ->
@@ -183,23 +176,23 @@ public class GuiProfileViewer extends GuiScreen {
public long lastTime = 0;
public long startTime = 0;
public List<String> tooltipToDisplay = null;
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
+ private Shader blurShaderHorz = null;
+ private Framebuffer blurOutputHorz = null;
+ private Shader blurShaderVert = null;
+ private Framebuffer blurOutputVert = null;
private boolean profileDropdownSelected = false;
-
private double lastBgBlurFactor = -1;
private boolean showBingoPage;
- public GuiProfileViewer(ProfileViewer.Profile profile) {
+ public GuiProfileViewer(SkyblockProfiles profile) {
GuiProfileViewer.profile = profile;
- GuiProfileViewer.profileId = profile.getLatestProfile();
- String name = "";
+ GuiProfileViewer.profileName = profile.getLatestProfileName();
+
+ String playerName = "";
if (profile.getHypixelProfile() != null) {
- name = profile.getHypixelProfile().get("displayname").getAsString();
+ playerName = profile.getHypixelProfile().get("displayname").getAsString();
}
- playerNameTextField = new GuiElementTextField(name, GuiElementTextField.SCALE_TEXT);
+ playerNameTextField = new GuiElementTextField(playerName, GuiElementTextField.SCALE_TEXT);
playerNameTextField.setSize(100, 20);
if (currentPage == ProfileViewerPage.LOADING) {
@@ -219,22 +212,6 @@ public class GuiProfileViewer extends GuiScreen {
pages.put(ProfileViewerPage.CRIMSON_ISLE, new CrimsonIslePage(this));
}
- private static float getMaxLevelXp(JsonArray levels, int offset, int maxLevel) {
- float xpTotal = 0;
-
- for (int i = offset; i < offset + maxLevel - 1; i++) {
- xpTotal += levels.get(i).getAsFloat();
- }
-
- return xpTotal;
- }
-
- @Deprecated
- public static String shortNumberFormat(double n, int iteration) {
- return StringUtils.shortNumberFormat(n, iteration
- );
- }
-
public static int getGuiLeft() {
return guiLeft;
}
@@ -243,12 +220,16 @@ public class GuiProfileViewer extends GuiScreen {
return guiTop;
}
- public static ProfileViewer.Profile getProfile() {
+ public static SkyblockProfiles getProfile() {
return profile;
}
- public static String getProfileId() {
- return profileId;
+ public static String getProfileName() {
+ return profileName;
+ }
+
+ public static @Nullable SkyblockProfiles.SkyblockProfile getSelectedProfile() {
+ return profile.getProfile(profileName);
}
@Override
@@ -259,20 +240,22 @@ public class GuiProfileViewer extends GuiScreen {
ProfileViewerPage page = currentPage;
if (profile == null) {
page = ProfileViewerPage.INVALID_NAME;
- } else if (profile.getSkyblockProfiles(null) == null) {
+ } else if (profile.getOrLoadSkyblockProfiles(null) == null) {
page = ProfileViewerPage.LOADING;
- } else if (profile.getLatestProfile() == null) {
- page = ProfileViewerPage.NO_SKYBLOCK;
}
- if (profileId == null && profile != null && profile.getLatestProfile() != null) {
- profileId = profile.getLatestProfile();
+ if (profile != null && profile.getLatestProfileName() == null &&
+ !profile.getUpdatingSkyblockProfilesState().get()) {
+ page = ProfileViewerPage.NO_SKYBLOCK;
}
- {
- //this is just to cache the guild info
- if (profile != null) {
- profile.getGuildInformation(null);
+
+ if (profile != null) {
+ if (profileName == null && profile.getLatestProfileName() != null) {
+ profileName = profile.getLatestProfileName();
}
+
+ // Preload guild info
+ profile.getOrLoadGuildInformation(null);
}
this.sizeX = 431;
@@ -280,17 +263,16 @@ public class GuiProfileViewer extends GuiScreen {
guiLeft = (this.width - this.sizeX) / 2;
guiTop = (this.height - this.sizeY) / 2;
- JsonObject currProfileInfo = profile != null ? profile.getProfileInformation(profileId) : null;
+ SkyblockProfiles.SkyblockProfile selectedProfile = profile != null ? profile.getProfile(profileName) : null;
if (NotEnoughUpdates.INSTANCE.config.profileViewer.alwaysShowBingoTab) {
showBingoPage = true;
} else {
- showBingoPage =
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("bingo");
+ showBingoPage = selectedProfile != null && selectedProfile.getGamemode() != null && selectedProfile.getGamemode().equals("bingo");
}
- if (!showBingoPage && currentPage == ProfileViewerPage.BINGO) currentPage = ProfileViewerPage.BASIC;
+ if (!showBingoPage && currentPage == ProfileViewerPage.BINGO) {
+ currentPage = ProfileViewerPage.BASIC;
+ }
super.drawScreen(mouseX, mouseY, partialTicks);
drawDefaultBackground();
@@ -318,7 +300,7 @@ public class GuiProfileViewer extends GuiScreen {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
- if (!(page == ProfileViewerPage.LOADING)) {
+ if (page != ProfileViewerPage.LOADING) {
playerNameTextField.render(guiLeft + sizeX - 100, guiTop + sizeY + 5);
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -328,56 +310,22 @@ public class GuiProfileViewer extends GuiScreen {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 3, 100, 20, 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST);
Utils.drawStringCenteredScaledMaxWidth(
- profileId,
+ profileName,
guiLeft + 50,
guiTop + sizeY + 3 + 10,
true,
90,
new Color(63, 224, 208, 255).getRGB()
);
- //ironman icon
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("ironman")
- ) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
- Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
- }
- //bingo! icon
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("bingo")
- ) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bingo);
- Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
- }
- //stranded icon
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("island")
- ) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_stranded);
- Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
- }
- //icon if game mode is unknown
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- !currProfileInfo.get("game_mode").getAsString().equals("island") &&
- !currProfileInfo.get("game_mode").getAsString().equals("bingo") &&
- !currProfileInfo.get("game_mode").getAsString().equals("ironman")
- ) {
+
+ if (selectedProfile != null && selectedProfile.getGamemode() != null) {
GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_unknown);
+ ResourceLocation gamemodeIcon = gamemodeToIcon.getOrDefault(selectedProfile.getGamemode(), gamemodeIconUnknown);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodeIcon);
Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
}
- //Render Open In Skycrypt button
+
+ // Render Open In SkyCrypt button
renderBlurredBackground(width, height, guiLeft + 100 + 6 + 2, guiTop + sizeY + 3 + 2, 100 - 4, 20 - 4);
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
Utils.drawTexturedRect(
@@ -402,9 +350,7 @@ public class GuiProfileViewer extends GuiScreen {
if (profileDropdownSelected && !profile.getProfileNames().isEmpty() && scaledResolution.getScaleFactor() < 4) {
int dropdownOptionSize = scaledResolution.getScaleFactor() == 3 ? 10 : 20;
-
- int numProfiles = profile.getProfileNames().size();
- int sizeYDropdown = numProfiles * dropdownOptionSize;
+ int sizeYDropdown = profile.getProfileNames().size() * dropdownOptionSize;
renderBlurredBackground(width, height, guiLeft + 2, guiTop + sizeY + 23, 100 - 4, sizeYDropdown - 2);
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23 - 3, 100, 3, 100 / 200f, 1, 0, 3 / 185f, GL11.GL_NEAREST);
@@ -432,70 +378,22 @@ public class GuiProfileViewer extends GuiScreen {
);
for (int yIndex = 0; yIndex < profile.getProfileNames().size(); yIndex++) {
- String otherProfileId = profile.getProfileNames().get(yIndex);
+ String otherProfileName = profile.getProfileNames().get(yIndex);
+ selectedProfile = profile.getProfile(otherProfileName);
+
Utils.drawStringCenteredScaledMaxWidth(
- otherProfileId,
+ otherProfileName,
guiLeft + 50,
guiTop + sizeY + 23 + dropdownOptionSize / 2f + dropdownOptionSize * yIndex,
true,
90,
new Color(33, 112, 104, 255).getRGB()
);
- currProfileInfo = profile.getProfileInformation(otherProfileId);
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("ironman")
- ) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
- Utils.drawTexturedRect(
- guiLeft - 16 - 5,
- guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
- 16,
- 16,
- GL11.GL_NEAREST
- );
- }
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("bingo")
- ) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bingo);
- Utils.drawTexturedRect(
- guiLeft - 16 - 5,
- guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
- 16,
- 16,
- GL11.GL_NEAREST
- );
- }
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- currProfileInfo.get("game_mode").getAsString().equals("island")
- ) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_stranded);
- Utils.drawTexturedRect(
- guiLeft - 16 - 5,
- guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
- 16,
- 16,
- GL11.GL_NEAREST
- );
- }
- if (
- currProfileInfo != null &&
- currProfileInfo.has("game_mode") &&
- !currProfileInfo.get("game_mode").getAsString().equals("island") &&
- !currProfileInfo.get("game_mode").getAsString().equals("bingo") &&
- !currProfileInfo.get("game_mode").getAsString().equals("ironman")
- ) {
+
+ if (selectedProfile != null && selectedProfile.getGamemode() != null) {
GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_unknown);
+ ResourceLocation gamemodeIcon = gamemodeToIcon.getOrDefault(selectedProfile.getGamemode(), gamemodeIconUnknown);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodeIcon);
Utils.drawTexturedRect(
guiLeft - 16 - 5,
guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
@@ -562,35 +460,34 @@ public class GuiProfileViewer extends GuiScreen {
guiLeft + sizeX / 2f, guiTop + 151, true, 0
);
Utils.drawStringCentered(
- EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "What are you doing with your life?",
+ EnumChatFormatting.YELLOW + String.valueOf(EnumChatFormatting.BOLD) + "What are you doing with your life?",
guiLeft + sizeX / 2f, guiTop + 161, true, 0
);
if (timeDiff > 600000) {
Utils.drawStringCentered(
- EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "Maniac",
+ EnumChatFormatting.RED + String.valueOf(EnumChatFormatting.BOLD) + "Maniac",
guiLeft + sizeX / 2f, guiTop + 171, true, 0
);
if (timeDiff > 1200000) {
Utils.drawStringCentered(
- EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You're a menace to society",
+ EnumChatFormatting.RED + String.valueOf(EnumChatFormatting.BOLD) + "You're a menace to society",
guiLeft + sizeX / 2f, guiTop + 181, true, 0
);
if (timeDiff > 1800000) {
Utils.drawStringCentered(
- EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD +
+ EnumChatFormatting.RED + String.valueOf(EnumChatFormatting.BOLD) +
"You don't know what's gonna happen to you",
guiLeft + sizeX / 2f, guiTop + 191, true, 0
);
if (timeDiff > 3000000) {
Utils.drawStringCentered(
- EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You really want this?",
+ EnumChatFormatting.RED + String.valueOf(EnumChatFormatting.BOLD) + "You really want this?",
guiLeft + sizeX / 2f, guiTop + 91, true, 0
);
if (timeDiff > 3300000) {
Utils.drawStringCentered(
EnumChatFormatting.DARK_RED +
- "" +
- EnumChatFormatting.BOLD +
+ String.valueOf(EnumChatFormatting.BOLD) +
"OW LORD FORGIVE ME FOR THIS",
guiLeft + sizeX / 2f, guiTop + 71, true, 0
);
@@ -774,12 +671,12 @@ public class GuiProfileViewer extends GuiScreen {
mouseX < guiLeft + 106 + 100 &&
profile != null &&
!profile.getProfileNames().isEmpty() &&
- profileId != null
+ profileName != null
) {
if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) {
String url =
"https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" +
- profileId;
+ profileName;
Utils.openUrl(url);
Utils.playPressSound();
return;
@@ -793,7 +690,7 @@ public class GuiProfileViewer extends GuiScreen {
profileDropdownSelected = false;
int profileNum = 0;
for (int index = 0; index < profile.getProfileNames().size(); index++) {
- if (profile.getProfileNames().get(index).equals(profileId)) {
+ if (profile.getProfileNames().get(index).equals(profileName)) {
profileNum = index;
break;
}
@@ -806,11 +703,11 @@ public class GuiProfileViewer extends GuiScreen {
if (profileNum >= profile.getProfileNames().size()) profileNum = 0;
if (profileNum < 0) profileNum = profile.getProfileNames().size() - 1;
- String newProfileId = profile.getProfileNames().get(profileNum);
- if (profileId != null && !profileId.equals(newProfileId)) {
+ String newProfileName = profile.getProfileNames().get(profileNum);
+ if (profileName != null && !profileName.equals(newProfileName)) {
resetCache();
}
- profileId = newProfileId;
+ profileName = newProfileName;
} else {
profileDropdownSelected = !profileDropdownSelected;
}
@@ -819,11 +716,11 @@ public class GuiProfileViewer extends GuiScreen {
int extraY = mouseY - (guiTop + sizeY + 23);
int index = extraY / dropdownOptionSize;
if (index >= 0 && index < profile.getProfileNames().size()) {
- String newProfileId = profile.getProfileNames().get(index);
- if (profileId != null && !profileId.equals(newProfileId)) {
+ String newProfileName = profile.getProfileNames().get(index);
+ if (profileName != null && !profileName.equals(newProfileName)) {
resetCache();
}
- profileId = newProfileId;
+ profileName = newProfileName;
}
}
playerNameTextField.otherComponentClick();
@@ -848,7 +745,7 @@ public class GuiProfileViewer extends GuiScreen {
if (playerNameTextField.getFocus()) {
if (keyCode == Keyboard.KEY_RETURN) {
currentPage = ProfileViewerPage.LOADING;
- NotEnoughUpdates.profileViewer.getProfileByName(
+ NotEnoughUpdates.profileViewer.loadPlayerByName(
playerNameTextField.getText(),
profile -> { //todo: invalid name
if (profile != null) profile.resetCache();
@@ -900,8 +797,8 @@ public class GuiProfileViewer extends GuiScreen {
String totalXpStr = null;
if (skillName.contains("Catacombs")) {
totalXpStr = EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE +
- numberFormat.format(levelObj.totalXp) + EnumChatFormatting.DARK_GRAY + " (" +
- DECIMAL_FORMAT.format(getPercentage(skillName.toLowerCase(), levelObj)) + "% to 50)";
+ StringUtils.formatNumber(levelObj.totalXp) + EnumChatFormatting.DARK_GRAY + " (" +
+ StringUtils.formatToTenths(getPercentage(skillName.toLowerCase(), levelObj)) + "% to 50)";
}
// Adds overflow level to each level object that is maxed, avoids hotm level as there is no overflow xp for it
if (levelObj.maxed) {
@@ -924,7 +821,7 @@ public class GuiProfileViewer extends GuiScreen {
StringUtils.shortNumberFormat(maxXp) +
// Since catacombs isn't considered 'maxed' at level 50 (since the cap is '99'), we can add
// a conditional here to add the overflow level rather than above
- ((skillName.contains("Catacombs") && levelObj.level >= 50) ?
+ (skillName.contains("Catacombs") && levelObj.level >= 50 ?
EnumChatFormatting.GRAY + " (Overflow level: " + String.format("%.2f", levelObj.level) + ")" : "");
}
}
@@ -1135,7 +1032,7 @@ public class GuiProfileViewer extends GuiScreen {
}
if (skillName.contains("catacombs")) {
return (level.totalXp / DungeonsWeight.CATACOMBS_LEVEL_50_XP) * 100;
- } else if (ExtraPage.slayers.containsKey(skillName)) {
+ } else if (Weight.SLAYER_NAMES.contains(skillName)) {
return (level.totalXp / 1000000) * 100;
} else if (skillName.equalsIgnoreCase("social")) {
return (level.totalXp / 272800) * 100;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewerPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewerPage.java
index 2c7fd9f4..bb6baa41 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewerPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewerPage.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.profileviewer;
+import javax.annotation.Nullable;
import java.io.IOException;
public abstract class GuiProfileViewerPage {
@@ -36,6 +37,13 @@ public abstract class GuiProfileViewerPage {
return instance;
}
+ /**
+ * @see GuiProfileViewer#getSelectedProfile()
+ */
+ public @Nullable SkyblockProfiles.SkyblockProfile getSelectedProfile() {
+ return GuiProfileViewer.getSelectedProfile();
+ }
+
public abstract void drawPage(int mouseX, int mouseY, float partialTicks);
/**
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java
index 29f84a5b..5b38a050 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java
@@ -57,7 +57,7 @@ import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewe
public class InventoriesPage extends GuiProfileViewerPage {
- public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png");
+ private static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png");
private static final ResourceLocation CHEST_GUI_TEXTURE =
new ResourceLocation("textures/gui/container/generic_54.png");
private static final Pattern FISHING_SPEED_PATTERN = Pattern.compile("^Fishing Speed: \\+(\\d+)");
@@ -71,7 +71,6 @@ public class InventoriesPage extends GuiProfileViewerPage {
"ender_chest_contents",
Utils.createItemStack(Item.getItemFromBlock(Blocks.ender_chest), EnumChatFormatting.GRAY + "Ender Chest")
);
- // put("backpack_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.dropper), EnumChatFormatting.GRAY+"Backpacks"));
put(
"backpack_contents",
Utils.editItemStackInfo(
@@ -100,7 +99,6 @@ public class InventoriesPage extends GuiProfileViewerPage {
};
private final ItemStack fillerStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15);
private HashMap<String, ItemStack[][][]> inventoryItems = new HashMap<>();
-
private ItemStack[] bestWeapons = null;
private ItemStack[] bestRods = null;
private ItemStack[] armorItems = null;
@@ -124,11 +122,12 @@ public class InventoriesPage extends GuiProfileViewerPage {
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
getInstance().inventoryTextField.setSize(88, 20);
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
- JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
- JsonObject profileInformation = profile.getProfileInformation(profileId);
- if (inventoryInfo == null) return;
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ Map<String, JsonArray> inventoryInfo = selectedProfile.getInventoryInfo();
int invNameIndex = 0;
for (Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
@@ -147,26 +146,26 @@ public class InventoriesPage extends GuiProfileViewerPage {
Utils.drawTexturedRect(guiLeft + x - 2, guiTop + y - 2, 20, 20, 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST);
}
- Utils.drawItemStackWithText(entry.getValue(), guiLeft + x, guiTop + y, "" + (invNameIndex + 1), true);
+ Utils.drawItemStackWithText(entry.getValue(), guiLeft + x, guiTop + y, String.valueOf(invNameIndex + 1), true);
if (mouseX >= guiLeft + x && mouseX <= guiLeft + x + 16) {
if (mouseY >= guiTop + y && mouseY <= guiTop + y + 16) {
getInstance().tooltipToDisplay = entry.getValue().getTooltip(Minecraft.getMinecraft().thePlayer, false);
if (Objects.equals(entry.getKey(), "talisman_bag")) {
StringBuilder magicalPowerString = new StringBuilder(EnumChatFormatting.DARK_GRAY + "Magical Power: ");
- int magicalPower = profile.getMagicalPower(profileId);
+ int magicalPower = getSelectedProfile().getMagicalPower();
getInstance()
.tooltipToDisplay.add(
magicalPower == -1
? magicalPowerString.append(EnumChatFormatting.RED).append("Error while calculating!").toString()
: magicalPowerString
.append(EnumChatFormatting.GOLD)
- .append(GuiProfileViewer.numberFormat.format(magicalPower))
+ .append(StringUtils.formatNumber(magicalPower))
.toString()
);
StringBuilder selectedPowerString = new StringBuilder(EnumChatFormatting.DARK_GRAY + "Selected Power: ");
- String selectedPower = PlayerStats.getSelectedMagicalPower(profile.getProfileInformation(profileId));
+ String selectedPower = PlayerStats.getSelectedMagicalPower(getSelectedProfile().getProfileJson());
getInstance()
.tooltipToDisplay.add(
selectedPower == null
@@ -184,10 +183,11 @@ public class InventoriesPage extends GuiProfileViewerPage {
if (armorItems == null) {
armorItems = new ItemStack[4];
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ JsonArray armor = inventoryInfo.get("inv_armor");
for (int i = 0; i < armor.size(); i++) {
- if (armor.get(i) == null || !armor.get(i).isJsonObject()) continue;
- armorItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(armor.get(i).getAsJsonObject(), false);
+ if (armor.get(i) != null && armor.get(i).isJsonObject()) {
+ armorItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(armor.get(i).getAsJsonObject(), false);
+ }
}
}
@@ -211,10 +211,11 @@ public class InventoriesPage extends GuiProfileViewerPage {
if (equipmentItems == null) {
equipmentItems = new ItemStack[4];
- JsonArray equippment = Utils.getElement(inventoryInfo, "equippment_contents").getAsJsonArray();
+ JsonArray equippment = inventoryInfo.get("equippment_contents");
for (int i = 0; i < equippment.size(); i++) {
- if (equippment.get(i) == null || !equippment.get(i).isJsonObject()) continue;
- equipmentItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(equippment.get(i).getAsJsonObject(), false);
+ if (equippment.get(i) != null && equippment.get(i).isJsonObject()) {
+ equipmentItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(equippment.get(i).getAsJsonObject(), false);
+ }
}
}
@@ -236,6 +237,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
}
}
+ // TODO: 3D arrays...
ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
if (currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length - 1;
if (currentInventoryIndex < 0) currentInventoryIndex = 0;
@@ -299,7 +301,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
.get("ARROW")),
guiLeft + 173,
guiTop + 101,
- "" + (arrowCount > 999 ? StringUtils.shortNumberFormat(arrowCount) : arrowCount),
+ String.valueOf(arrowCount > 999 ? StringUtils.shortNumberFormat(arrowCount) : arrowCount),
true
);
Utils.drawItemStackWithText(
@@ -308,7 +310,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
.get("GREEN_CANDY")),
guiLeft + 173,
guiTop + 119,
- "" + greenCandyCount,
+ String.valueOf(greenCandyCount),
true
);
Utils.drawItemStackWithText(
@@ -317,13 +319,13 @@ public class InventoriesPage extends GuiProfileViewerPage {
.get("PURPLE_CANDY")),
guiLeft + 173,
guiTop + 137,
- "" + purpleCandyCount,
+ String.valueOf(purpleCandyCount),
true
);
if (mouseX > guiLeft + 173 && mouseX < guiLeft + 173 + 16) {
if (mouseY > guiTop + 101 && mouseY < guiTop + 137 + 16) {
if (mouseY < guiTop + 101 + 17) {
- QuiverInfo quiverInfo = PlayerStats.getQuiverInfo(inventoryInfo, profile.getProfileInformation(profileId));
+ QuiverInfo quiverInfo = PlayerStats.getQuiverInfo(inventoryInfo, getSelectedProfile().getProfileJson());
if (quiverInfo == null) {
getInstance().tooltipToDisplay = Utils.createList(EnumChatFormatting.RED + "Error checking Quiver");
} else {
@@ -509,7 +511,12 @@ public class InventoriesPage extends GuiProfileViewerPage {
i++;
}
- JsonObject inventoryInfo = GuiProfileViewer.getProfile().getInventoryInfo(GuiProfileViewer.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ Map<String, JsonArray> inventoryInfo = selectedProfile.getInventoryInfo();
if (inventoryInfo == null) return;
ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
@@ -519,8 +526,6 @@ public class InventoriesPage extends GuiProfileViewerPage {
ItemStack[][] inventory = inventories[currentInventoryIndex];
if (inventory == null) return;
- int inventoryRows = inventory.length;
-
int staticSelectorHeight = guiTop + 177;
if (mouseY > staticSelectorHeight && mouseY < staticSelectorHeight + 16) {
@@ -593,7 +598,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
private int countItemsInInventory(
String internalname,
- JsonObject inventoryInfo,
+ Map<String, JsonArray> inventoryInfo,
boolean specific,
String... invsToSearch
) {
@@ -619,7 +624,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
}
private ItemStack[] findBestItems(
- JsonObject inventoryInfo,
+ Map<String, JsonArray> inventoryInfo,
int numItems,
String[] invsToSearch,
String[] typeMatches,
@@ -671,10 +676,10 @@ public class InventoriesPage extends GuiProfileViewerPage {
return bestItems;
}
- private ItemStack[][][] getItemsForInventory(JsonObject inventoryInfo, String invName) {
+ private ItemStack[][][] getItemsForInventory(Map<String, JsonArray> inventoryInfo, String invName) {
if (inventoryItems.containsKey(invName)) return inventoryItems.get(invName);
- JsonArray jsonInv = Utils.getElement(inventoryInfo, invName).getAsJsonArray();
+ JsonArray jsonInv = inventoryInfo.get(invName);
if (jsonInv.size() == 0) return new ItemStack[1][][];
@@ -701,14 +706,13 @@ public class InventoriesPage extends GuiProfileViewerPage {
int maxInvSize = rowSize * maxRowsPerPage;
int numInventories = (jsonInvSize - 1) / maxInvSize + 1;
- JsonArray backPackSizes = (JsonArray) inventoryInfo.get("backpack_sizes");
+ JsonArray backpackSizes = inventoryInfo.get("backpack_sizes");
if (invName.equals("backpack_contents")) {
- numInventories = backPackSizes.size();
+ numInventories = backpackSizes.size();
}
ItemStack[][][] inventories = new ItemStack[numInventories][][];
- //int availableSlots = getAvailableSlotsForInventory(inventoryInfo, collectionInfo, invName);
int startNumberJ = 0;
for (int i = 0; i < numInventories; i++) {
@@ -716,7 +720,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
int invSize;
if (invName.equals("backpack_contents")) {
- thisRows = backPackSizes.get(i).getAsInt() / 9;
+ thisRows = backpackSizes.get(i).getAsInt() / 9;
invSize = startNumberJ + (thisRows * 9);
maxInvSize = thisRows * 9;
} else {
@@ -773,7 +777,7 @@ public class InventoriesPage extends GuiProfileViewerPage {
}
inventories[i] = items;
if (invName.equals("backpack_contents")) {
- startNumberJ = startNumberJ + backPackSizes.get(i).getAsInt();
+ startNumberJ = startNumberJ + backpackSizes.get(i).getAsInt();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java
index 6c042a39..84f0622b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java
@@ -20,10 +20,8 @@
package io.github.moulberry.notenoughupdates.profileviewer;
import com.google.common.collect.Lists;
-import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
-import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
@@ -34,18 +32,27 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
+import org.apache.commons.lang3.text.WordUtils;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Objects;
+import java.util.Map;
import java.util.function.Supplier;
public class MiningPage extends GuiProfileViewerPage {
- public static final ResourceLocation pv_mining = new ResourceLocation("notenoughupdates:pv_mining.png");
- private static final ItemStack iron_pick = new ItemStack(Items.iron_pickaxe);
- private final HashMap<String, ProfileViewer.Level> levelObjhotms = new HashMap<>();
+ private static final ResourceLocation miningPageTexture = new ResourceLocation("notenoughupdates:pv_mining.png");
+ private static final ItemStack hotmSkillIcon = new ItemStack(Items.iron_pickaxe);
+ private static final Map<String, EnumChatFormatting> crystalToColor = new HashMap<String, EnumChatFormatting>() {{
+ put("jade", EnumChatFormatting.GREEN);
+ put("amethyst", EnumChatFormatting.DARK_PURPLE);
+ put("amber", EnumChatFormatting.GOLD);
+ put("sapphire", EnumChatFormatting.AQUA);
+ put("topaz", EnumChatFormatting.YELLOW);
+ put("jasper", EnumChatFormatting.LIGHT_PURPLE);
+ put("ruby", EnumChatFormatting.RED);
+ }};
public MiningPage(GuiProfileViewer instance) {
super(instance);
@@ -56,13 +63,15 @@ public class MiningPage extends GuiProfileViewerPage {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_mining);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(miningPageTexture);
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if (profileInfo == null) return;
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ JsonObject profileInfo = selectedProfile.getProfileJson();
float xStart = 22;
float yStartTop = 27;
@@ -70,218 +79,85 @@ public class MiningPage extends GuiProfileViewerPage {
int x = guiLeft + 23;
int y = guiTop + 25;
int sectionWidth = 110;
- JsonObject leveling = Constants.LEVELING;
- ProfileViewer.Level levelObjhotm = levelObjhotms.get(profileId);
- if (levelObjhotm == null) {
- float hotmXp = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.experience"), 0);
- levelObjhotm =
- ProfileViewer.getLevel(
- Utils.getElementOrDefault(leveling, "HOTM", new JsonArray()).getAsJsonArray(),
- hotmXp,
- 7,
- false
- );
- levelObjhotms.put(profileId, levelObjhotm);
- }
- String skillName = EnumChatFormatting.RED + "HOTM";
- //The stats that show
- float mithrilPowder = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.powder_mithril"), 0);
- float gemstonePowder = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.powder_gemstone"), 0);
+ // Get stats
+ JsonObject miningCore = profileInfo.getAsJsonObject("mining_core");
+ JsonObject nodes = miningCore.getAsJsonObject("nodes");
+
+ float mithrilPowder = Utils.getElementAsFloat(Utils.getElement(miningCore, "powder_mithril"), 0);
+ float gemstonePowder = Utils.getElementAsFloat(Utils.getElement(miningCore, "powder_gemstone"), 0);
float mithrilPowderTotal = Utils.getElementAsFloat(Utils.getElement(
profileInfo,
- "mining_core.powder_spent_mithril"
+ "powder_spent_mithril"
), 0);
- float gemstonePowderTotal = (Utils.getElementAsFloat(Utils.getElement(
+ float gemstonePowderTotal = Utils.getElementAsFloat(Utils.getElement(
profileInfo,
- "mining_core.powder_spent_gemstone"
- ), 0));
- String jadeCrystal =
- (Utils.getElementAsString(Utils.getElement(profileInfo, "mining_core.crystals.jade_crystal.state"), "Not Found"));
+ "powder_spent_gemstone"
+ ), 0);
+
float crystalPlacedAmount =
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.crystals.jade_crystal.total_placed"), 0));
- String jadeCrystalString = "§c✖";
- String amethystCrystal =
- (Utils.getElementAsString(
- Utils.getElement(profileInfo, "mining_core.crystals.amethyst_crystal.state"),
- "Not Found"
- ));
- String amethystCrystalString = "§c✖";
- String amberCrystal =
- (Utils.getElementAsString(
- Utils.getElement(profileInfo, "mining_core.crystals.amber_crystal.state"),
- "Not Found"
- ));
- String amberCrystalString = "§c✖";
- String sapphireCrystal =
- (Utils.getElementAsString(
- Utils.getElement(profileInfo, "mining_core.crystals.sapphire_crystal.state"),
- "Not Found"
- ));
- String sapphireCrystalString = "§c✖";
- String topazCrystal =
- (Utils.getElementAsString(
- Utils.getElement(profileInfo, "mining_core.crystals.topaz_crystal.state"),
- "Not Found"
- ));
- String topazCrystalString = "§c✖";
- String jasperCrystal =
- (Utils.getElementAsString(
- Utils.getElement(profileInfo, "mining_core.crystals.jasper_crystal.state"),
- "Not Found"
- ));
- String jasperCrystalString = "§c✖";
- String rubyCrystal =
- (Utils.getElementAsString(Utils.getElement(profileInfo, "mining_core.crystals.ruby_crystal.state"), "Not Found"));
- String rubyCrystalString = "§c✖";
- int miningFortune = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune"), 0)));
- int miningFortuneStat = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune"),
- 0
- )) * 5);
- int miningSpeed = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed"), 0)));
- int miningSpeedStat = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed"), 0)) *
- 20);
- int dailyPowder = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.daily_powder"), 0)));
- int dailyPowderStat = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.daily_powder"), 0)) *
- 36 + 364);
- int effMiner = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.efficient_miner"), 0)));
- float effMinerStat = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.efficient_miner"), 0)) * 0.4 + 10.4
- );
- float effMinerStat2 = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.efficient_miner"), 0)) * .06 + 0.31
- );
- int tittyInsane = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.titanium_insanium"),
- 0
- )));
- float tittyInsaneStat = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.titanium_insanium"), 0)) * .1 + 2
- );
- int luckofcave = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.random_event"), 0)));
- int luckofcaveStat = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.random_event"), 0)));
- int madMining = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_madness"), 0)));
- int skyMall = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.daily_effect"), 0)));
- int goblinKiller = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.goblin_killer"), 0)));
- int seasonMine = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_experience"), 0)));
- float seasonMineStat = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.mining_experience"), 0)) * 0.1 + 5
- );
- int quickForge = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.forge_time"), 0)));
- float quickForgeStat = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.forge_time"), 0)) * .5 + 10
- );
- int frontLoad = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.front_loaded"), 0)));
- int orbit = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.experience_orbs"), 0)));
- float orbitStat = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.experience_orbs"), 0)) * .01 + 0.2
- );
- int crystallized = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.fallen_star_bonus"),
- 0
- )));
- int crystallizedStat = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.fallen_star_bonus"),
- 0
- )) * 6 + 14);
- int professional = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.professional"), 0)));
- int professionalStat = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.professional"),
- 0
- )) * 5 + 50);
- int greatExplorer = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.great_explorer"), 0)));
- int greatExplorerStat = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.great_explorer"),
- 0
- )) * 4 + 16);
- int fortunate = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.fortunate"), 0)));
- int fortunateStat = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.fortunate"), 0)) * 4 +
- 20);
- int lonesomeMiner = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.lonesome_miner"), 0)));
- float lonesomeMinerStat = (float) (
- (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.lonesome_miner"), 0)) * .5 + 5
- );
- int miningFortune2 = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune_2"),
- 0
- )));
- int miningFortune2Stat = ((Utils.getElementAsInt(Utils.getElement(
- profileInfo,
- "mining_core.nodes.mining_fortune_2"
- ), 0)) * 5);
- int miningSpeed2 = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed_2"), 0)));
- int miningSpeed2Stat = ((Utils.getElementAsInt(
- Utils.getElement(profileInfo, "mining_core.nodes.mining_speed_2"),
- 0
- )) * 40);
- int miningSpeedBoost = ((Utils.getElementAsInt(Utils.getElement(
- profileInfo,
- "mining_core.nodes.mining_speed_boost"
- ), 0)));
- int veinSeeker = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.vein_seeker"), 0)));
- int powderBuff = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.powder_buff"), 0)));
- int potm = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.special_0"), 0)));
- int fortnite = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.precision_mining"), 0)));
- int starPowder = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.star_powder"), 0)));
- int pickoblus = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.pickaxe_toss"), 0)));
- int maniacMiner = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.maniac_miner"), 0)));
+ Utils.getElementAsFloat(Utils.getElement(miningCore, "crystals.jade_crystal.total_placed"), 0);
- if (effMinerStat2 < 1) {
- effMinerStat2 = 1;
+ int miningFortune = Utils.getElementAsInt(Utils.getElement(nodes, "mining_fortune"), 0);
+ int miningFortuneStat = miningFortune * 5;
+ int miningSpeed = Utils.getElementAsInt(Utils.getElement(nodes, "mining_speed"), 0);
+ int miningSpeedStat = miningSpeed * 20;
+ int dailyPowder = Utils.getElementAsInt(Utils.getElement(nodes, "daily_powder"), 0);
+ int dailyPowderStat = dailyPowder * 36 + 364;
+ int effMiner = Utils.getElementAsInt(Utils.getElement(nodes, "efficient_miner"), 0);
+ float effMinerStat = (float) (effMiner * 0.4 + 10.4);
+ float effMinerStat2 = Math.max(1, (float) (effMiner * .06 + 0.31));
+ int tittyInsane = Utils.getElementAsInt(Utils.getElement(nodes, "titanium_insanium"), 0);
+ float tittyInsaneStat = (float) (tittyInsane * .1 + 2);
+ int luckOfCave = Utils.getElementAsInt(Utils.getElement(nodes, "random_event"), 0);
+ int madMining = Utils.getElementAsInt(Utils.getElement(nodes, "mining_madness"), 0);
+ int skyMall = Utils.getElementAsInt(Utils.getElement(nodes, "daily_effect"), 0);
+ int goblinKiller = Utils.getElementAsInt(Utils.getElement(nodes, "goblin_killer"), 0);
+ int seasonMine = Utils.getElementAsInt(Utils.getElement(nodes, "mining_experience"), 0);
+ float seasonMineStat = (float) (seasonMine * 0.1 + 5);
+ int quickForge = Utils.getElementAsInt(Utils.getElement(nodes, "forge_time"), 0);
+ float quickForgeStat = (float) (quickForge * .5 + 10);
+ int frontLoad = Utils.getElementAsInt(Utils.getElement(nodes, "front_loaded"), 0);
+ int orbit = Utils.getElementAsInt(Utils.getElement(nodes, "experience_orbs"), 0);
+ float orbitStat = (float) (orbit * .01 + 0.2);
+ int crystallized = Utils.getElementAsInt(Utils.getElement(nodes, "fallen_star_bonus"), 0);
+ int crystallizedStat = crystallized * 6 + 14;
+ int professional = Utils.getElementAsInt(Utils.getElement(nodes, "professional"), 0);
+ int professionalStat = professional * 5 + 50;
+ int greatExplorer = Utils.getElementAsInt(Utils.getElement(nodes, "great_explorer"), 0);
+ int greatExplorerStat = greatExplorer * 4 + 16;
+ int fortunate = Utils.getElementAsInt(Utils.getElement(nodes, "fortunate"), 0);
+ int fortunateStat = fortunate * 4 + 20;
+ int lonesomeMiner = ((Utils.getElementAsInt(Utils.getElement(nodes, "lonesome_miner"), 0)));
+ float lonesomeMinerStat = (float) (lonesomeMiner * .5 + 5);
+ int miningFortune2 = Utils.getElementAsInt(Utils.getElement(nodes, "mining_fortune_2"), 0);
+ int miningFortune2Stat = miningFortune2 * 5;
+ int miningSpeed2 = Utils.getElementAsInt(Utils.getElement(nodes, "mining_speed_2"), 0);
+ int miningSpeed2Stat = miningSpeed2 * 40;
+ int miningSpeedBoost = Utils.getElementAsInt(Utils.getElement(nodes, "mining_speed_boost"), 0);
+ int veinSeeker = Utils.getElementAsInt(Utils.getElement(nodes, "vein_seeker"), 0);
+ int powderBuff = Utils.getElementAsInt(Utils.getElement(nodes, "powder_buff"), 0);
+ int potm = ((Utils.getElementAsInt(Utils.getElement(nodes, "special_0"), 0)));
+ int fortnite = Utils.getElementAsInt(Utils.getElement(nodes, "precision_mining"), 0);
+ int starPowder = Utils.getElementAsInt(Utils.getElement(nodes, "star_powder"), 0);
+ int pickoblus = Utils.getElementAsInt(Utils.getElement(nodes, "pickaxe_toss"), 0);
+ int maniacMiner = Utils.getElementAsInt(Utils.getElement(nodes, "maniac_miner"), 0);
+ int mole = Utils.getElementAsInt(Utils.getElement(nodes, "mole"), 0);
+ float moleStat = (float) (mole * 0.051);
+ double molePerkStat = (double) mole / 20 - 0.55 + 50;
+ double molePerkStat2 = (double) Math.round(molePerkStat * 100) / 100;
+ float molePerkPct = Math.round((float) (molePerkStat2 % 1) * 100);
+ if (molePerkPct == 0) {
+ molePerkPct = 100;
}
- int mole = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mole"), 0)));
- float moleStat = (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.mole"), 0)) *
- 0.051);
- double moleperkstat = (double) mole / 20 - 0.55 + 50;
- double moleperkstat2 = (double) Math.round(moleperkstat * 100) / 100;
- float output = Math.round((float) (moleperkstat2 % 1) * 100);
- if (output == 0) {
- output = 100;
- }
+ ProfileViewer.Level hotmLevelingInfo = selectedProfile.getLevelingInfo().get("hotm");
- //The logic for some of the stats
- if (Objects.equals(jadeCrystal, "NOT_FOUND")) {
- jadeCrystalString = "§c✖";
- } else if (Objects.equals(jadeCrystal, "FOUND")) {
- jadeCrystalString = "§a✔";
- }
- if (Objects.equals(amethystCrystal, "NOT_FOUND")) {
- amethystCrystalString = "§c✖";
- } else if (Objects.equals(amethystCrystal, "FOUND")) {
- amethystCrystalString = "§a✔";
- }
- if (Objects.equals(amberCrystal, "NOT_FOUND")) {
- amberCrystalString = "§c✖";
- } else if (Objects.equals(amberCrystal, "FOUND")) {
- amberCrystalString = "§a✔";
- }
- if (Objects.equals(sapphireCrystal, "NOT_FOUND")) {
- sapphireCrystalString = "§c✖";
- } else if (Objects.equals(sapphireCrystal, "FOUND")) {
- sapphireCrystalString = "§a✔";
- }
- if (Objects.equals(topazCrystal, "NOT_FOUND")) {
- topazCrystalString = "§c✖";
- } else if (Objects.equals(topazCrystal, "FOUND")) {
- topazCrystalString = "§a✔";
- }
- if (Objects.equals(jasperCrystal, "NOT_FOUND")) {
- jasperCrystalString = "§c✖";
- } else if (Objects.equals(jasperCrystal, "FOUND")) {
- jasperCrystalString = "§a✔";
- }
- if (Objects.equals(rubyCrystal, "NOT_FOUND")) {
- rubyCrystalString = "§c✖";
- } else if (Objects.equals(rubyCrystal, "FOUND")) {
- rubyCrystalString = "§a✔";
- }
+ // Render stats
+ // HOTM
+ getInstance().renderXpBar(EnumChatFormatting.RED + "HOTM", hotmSkillIcon, x, y, sectionWidth, hotmLevelingInfo, mouseX, mouseY);
- //The rendering of the stats
- //hotm level
- getInstance().renderXpBar(skillName, iron_pick, x, y, sectionWidth, levelObjhotm, mouseX, mouseY);
- //Powder
+ // Powder
Utils.renderAlignedString(
EnumChatFormatting.DARK_GREEN + "Mithril Powder",
EnumChatFormatting.WHITE + StringUtils.shortNumberFormat(mithrilPowder),
@@ -310,56 +186,22 @@ public class MiningPage extends GuiProfileViewerPage {
guiTop + yStartTop + 54,
115
);
- //Crystals
- Utils.renderAlignedString(
- EnumChatFormatting.GREEN + "Jade Crystal:",
- EnumChatFormatting.WHITE + jadeCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 74,
- 110
- );
- Utils.renderAlignedString(
- EnumChatFormatting.GOLD + "Amber Crystal:",
- EnumChatFormatting.WHITE + amberCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 84,
- 110
- );
- Utils.renderAlignedString(
- EnumChatFormatting.DARK_PURPLE + "Amethyst Crystal:",
- EnumChatFormatting.WHITE + amethystCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 94,
- 110
- );
- Utils.renderAlignedString(
- EnumChatFormatting.AQUA + "Sapphire Crystal:",
- EnumChatFormatting.WHITE + sapphireCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 104,
- 110
- );
- Utils.renderAlignedString(
- EnumChatFormatting.YELLOW + "Topaz Crystal:",
- EnumChatFormatting.WHITE + topazCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 114,
- 110
- );
- Utils.renderAlignedString(
- EnumChatFormatting.LIGHT_PURPLE + "Jasper Crystal:",
- EnumChatFormatting.WHITE + jasperCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 124,
- 110
- );
- Utils.renderAlignedString(
- EnumChatFormatting.RED + "Ruby Crystal:",
- EnumChatFormatting.WHITE + rubyCrystalString,
- guiLeft + xStart,
- guiTop + yStartTop + 134,
- 110
- );
+
+ // Crystals
+ int idx = 0;
+ for (Map.Entry<String, EnumChatFormatting> crystal : crystalToColor.entrySet()) {
+ String crystalState = Utils.getElementAsString(Utils.getElement(miningCore, "crystals." + crystal.getKey() + "_crystal.state"), "NOT_FOUND");
+ String crystalStr = crystalState.equals("FOUND") ? "§a✔" : "§c✖";
+ Utils.renderAlignedString(
+ crystal.getValue() + WordUtils.capitalizeFully(crystal.getKey()) + " Crystal:",
+ EnumChatFormatting.WHITE + crystalStr,
+ guiLeft + xStart,
+ guiTop + yStartTop + 74 + idx * 10,
+ 110
+ );
+ idx ++; // Move text down 10 px every crystal
+ }
+
Utils.renderAlignedString(
EnumChatFormatting.BLUE + "Total Placed Crystals:",
EnumChatFormatting.WHITE + StringUtils.shortNumberFormat(crystalPlacedAmount),
@@ -368,9 +210,7 @@ public class MiningPage extends GuiProfileViewerPage {
110
);
- //hotm render
- //Pain
-
+ // HOTM tree
renderHotmPerk(
miningSpeed,
(int) (guiLeft + xStart + 255),
@@ -394,8 +234,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format(Math.pow(miningSpeed + 2, 3)) +
+ StringUtils.formatNumber(Math.pow(miningSpeed + 2, 3)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -437,8 +276,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format(Math.pow(miningFortune + 2, 3)) +
+ StringUtils.formatNumber(Math.pow(miningFortune + 2, 3)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -482,8 +320,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(tittyInsane + 2, 3)) +
+ StringUtils.formatNumber((int) Math.pow(tittyInsane + 2, 3)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -563,34 +400,33 @@ public class MiningPage extends GuiProfileViewerPage {
);
renderHotmPerk(
- luckofcave,
+ luckOfCave,
(int) (guiLeft + xStart + 207),
(int) (guiTop + yStartTop + 90),
mouseX,
mouseY,
() ->
- luckofcave != 0 && luckofcave != 45
+ luckOfCave != 0 && luckOfCave != 45
? Lists.newArrayList(
"Luck of the Cave",
- "§7Level " + luckofcave + EnumChatFormatting.DARK_GRAY + "/45",
+ "§7Level " + luckOfCave + EnumChatFormatting.DARK_GRAY + "/45",
"",
"§7Increases the chance for you to",
"§7trigger rare occurrences in",
- "§2Dwarven Mines " + EnumChatFormatting.GRAY + "by " + EnumChatFormatting.GREEN + luckofcaveStat + "%§7.",
+ "§2Dwarven Mines " + EnumChatFormatting.GRAY + "by " + EnumChatFormatting.GREEN + luckOfCave + "%§7.",
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(luckofcave + 2, 3.07)) +
+ StringUtils.formatNumber((int) Math.pow(luckOfCave + 2, 3.07)) +
" Mithril Powder"
)
: Lists.newArrayList(
"Luck of the Cave",
- "§7Level " + luckofcave + EnumChatFormatting.DARK_GRAY + "/45",
+ "§7Level " + luckOfCave + EnumChatFormatting.DARK_GRAY + "/45",
"",
"§7Increases the chance for you to",
"§7trigger rare occurrences in",
- "§2Dwarven Mines " + EnumChatFormatting.GRAY + "by " + EnumChatFormatting.GREEN + luckofcaveStat + "%§7."
+ "§2Dwarven Mines " + EnumChatFormatting.GRAY + "by " + EnumChatFormatting.GREEN + luckOfCave + "%§7."
),
45
);
@@ -618,7 +454,7 @@ public class MiningPage extends GuiProfileViewerPage {
EnumChatFormatting.GRAY + "Works for all Powder types.",
"",
EnumChatFormatting.GRAY + "Cost",
- EnumChatFormatting.DARK_GREEN + "" + (200 + ((dailyPowder) * 18)) + " Mithril Powder"
+ EnumChatFormatting.DARK_GREEN + String.valueOf(200 + ((dailyPowder) * 18)) + " Mithril Powder"
)
: Lists.newArrayList(
"Daily Powder",
@@ -637,7 +473,6 @@ public class MiningPage extends GuiProfileViewerPage {
100
);
- float finalEffMinerStat2 = effMinerStat2;
renderHotmPerk(
effMiner,
(int) (guiLeft + xStart + 255),
@@ -652,19 +487,17 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "When mining ores, you have a",
EnumChatFormatting.GREEN +
- "" +
- effMinerStat +
+ String.valueOf(effMinerStat) +
"%" +
EnumChatFormatting.GRAY +
" chance to mine " +
EnumChatFormatting.GREEN +
- Math.round(finalEffMinerStat2),
+ Math.round(effMinerStat2),
EnumChatFormatting.GRAY + "adjacent ores.",
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(effMiner + 2, 2.6)) +
+ StringUtils.formatNumber((int) Math.pow(effMiner + 2, 2.6)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -673,13 +506,12 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "When mining ores, you have a",
EnumChatFormatting.GREEN +
- "" +
- effMinerStat +
+ String.valueOf(effMinerStat) +
"%" +
EnumChatFormatting.GRAY +
" chance to mine " +
EnumChatFormatting.GREEN +
- Math.round(finalEffMinerStat2),
+ Math.round(effMinerStat2),
EnumChatFormatting.GRAY + "adjacent ores."
),
100
@@ -814,7 +646,7 @@ public class MiningPage extends GuiProfileViewerPage {
true // A redstone block or bedrock is being rendered, so standard GUI item lighting needs to be enabled.
);
- float finalOutput = output;
+ float finalMolePerkPct = molePerkPct;
renderHotmPerk(
mole,
(int) (guiLeft + xStart + 255),
@@ -831,22 +663,20 @@ public class MiningPage extends GuiProfileViewerPage {
EnumChatFormatting.GRAY +
"a " +
EnumChatFormatting.GREEN +
- finalOutput +
+ finalMolePerkPct +
"% " +
EnumChatFormatting.GRAY +
"chance to mine " +
EnumChatFormatting.GREEN,
EnumChatFormatting.GREEN +
- "" +
- Math.round(moleStat) +
+ String.valueOf(Math.round(moleStat)) +
EnumChatFormatting.GRAY +
" adjacent hard stone block" +
(moleStat == 1.0 ? "." : "s."),
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(mole + 2, 2.2)) +
+ StringUtils.formatNumber((int) Math.pow(mole + 2, 2.2)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -857,14 +687,13 @@ public class MiningPage extends GuiProfileViewerPage {
EnumChatFormatting.GRAY +
"a " +
EnumChatFormatting.GREEN +
- finalOutput +
+ finalMolePerkPct +
"% " +
EnumChatFormatting.GRAY +
"chance to mine " +
EnumChatFormatting.GREEN,
EnumChatFormatting.GREEN +
- "" +
- Math.round(moleStat) +
+ String.valueOf(Math.round(moleStat)) +
EnumChatFormatting.GRAY +
" adjacent hard stone block" +
(moleStat == 1.0 ? "." : "s.")
@@ -895,8 +724,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(powderBuff + 2, 3.2)) +
+ StringUtils.formatNumber((int) Math.pow(powderBuff + 2, 3.2)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -976,8 +804,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(seasonMine + 2, 2.3)) +
+ StringUtils.formatNumber((int) Math.pow(seasonMine + 2, 2.3)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -1019,8 +846,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(lonesomeMiner + 2, 3.07)) +
+ StringUtils.formatNumber((int) Math.pow(lonesomeMiner + 2, 3.07)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -1052,8 +878,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(professional + 2, 2.3)) +
+ StringUtils.formatNumber((int) Math.pow(professional + 2, 2.3)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -1083,8 +908,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format(Math.pow(miningSpeed2 + 2, 3)) +
+ StringUtils.formatNumber(Math.pow(miningSpeed2 + 2, 3)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -1114,8 +938,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(quickForge + 2, 4)) +
+ StringUtils.formatNumber((int) Math.pow(quickForge + 2, 4)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -1145,8 +968,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(fortunate + 2, 3.05)) +
+ StringUtils.formatNumber((int) Math.pow(fortunate + 2, 3.05)) +
" Mithril Powder"
)
: Lists.newArrayList(
@@ -1177,8 +999,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(greatExplorer + 2, 4)) +
+ StringUtils.formatNumber((int) Math.pow(greatExplorer + 2, 4)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -1209,8 +1030,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.LIGHT_PURPLE +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(miningFortune2 + 2, 3.2)) +
+ StringUtils.formatNumber((int) Math.pow(miningFortune2 + 2, 3.2)) +
" Gemstone Powder"
)
: Lists.newArrayList(
@@ -1236,18 +1056,18 @@ public class MiningPage extends GuiProfileViewerPage {
"§7Level " + orbit + EnumChatFormatting.DARK_GRAY + "/80",
"",
"§7When mining ores, you have a",
- EnumChatFormatting.GREEN + "" + orbitStat + "%" + EnumChatFormatting.GRAY + " chance to get a random",
+ EnumChatFormatting.GREEN + String.valueOf(orbitStat) + "%" + EnumChatFormatting.GRAY + " chance to get a random",
"§7amount of experience orbs.",
"",
EnumChatFormatting.GRAY + "Cost",
- EnumChatFormatting.DARK_GREEN + "" + ((orbit + 1) * 70) + " Mithril Powder"
+ EnumChatFormatting.DARK_GREEN + String.valueOf((orbit + 1) * 70) + " Mithril Powder"
)
: Lists.newArrayList(
"Orbiter",
"§7Level " + orbit + EnumChatFormatting.DARK_GRAY + "/80",
"",
"§7When mining ores, you have a",
- EnumChatFormatting.GREEN + "" + orbitStat + "%" + EnumChatFormatting.GRAY + " chance to get a random",
+ EnumChatFormatting.GREEN + String.valueOf(orbitStat) + "%" + EnumChatFormatting.GRAY + " chance to get a random",
"§7amount of experience orbs."
),
80
@@ -1323,8 +1143,7 @@ public class MiningPage extends GuiProfileViewerPage {
"",
EnumChatFormatting.GRAY + "Cost",
EnumChatFormatting.DARK_GREEN +
- "" +
- GuiProfileViewer.numberFormat.format((int) Math.pow(crystallized + 2, 2.4)) +
+ StringUtils.formatNumber((int) Math.pow(crystallized + 2, 2.4)) +
" Mithril Powder"
)
: Lists.newArrayList(
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
index af904e1d..07e72a68 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
@@ -19,7 +19,6 @@
package io.github.moulberry.notenoughupdates.profileviewer;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@@ -30,7 +29,6 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
@@ -39,8 +37,6 @@ import java.util.HashMap;
public class Panorama {
- private static final TexLoc tl = new TexLoc(97, 19, Keyboard.KEY_P);
- private static final TexLoc tl2 = new TexLoc(37, 80, Keyboard.KEY_L);
private static final HashMap<String, ResourceLocation[]> panoramasMap = new HashMap<>();
private static ResourceLocation backgroundTexture = null;
private static int lastWidth = 0;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java
index a56662e7..4eda3d9f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java
@@ -65,15 +65,23 @@ public class PetsPage extends GuiProfileViewerPage {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
- ProfileViewer.Profile profile = GuiProfileViewer.getProfile();
- String profileId = GuiProfileViewer.getProfileId();
- JsonObject petsInfo = profile.getPetsInfo(profileId);
- if (petsInfo == null) return;
JsonObject petsJson = Constants.PETS;
- if (petsJson == null) return;
+ if (petsJson == null) {
+ return;
+ }
+
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ JsonObject petsInfo = selectedProfile.getPetsInfo();
+ if (petsInfo == null) {
+ return;
+ }
String location = null;
- JsonObject status = profile.getPlayerStatus();
+ JsonObject status = GuiProfileViewer.getProfile().getPlayerStatus();
if (status != null && status.has("mode")) {
location = status.get("mode").getAsString();
}
@@ -98,13 +106,13 @@ public class PetsPage extends GuiProfileViewerPage {
}
sortedPets.sort((pet1, pet2) -> {
String tier1 = pet1.get("tier").getAsString();
- String tierNum1 = GuiProfileViewer.MINION_RARITY_TO_NUM.get(tier1);
+ String tierNum1 = GuiProfileViewer.RARITY_TO_NUM.get(tier1);
if (tierNum1 == null) return 1;
int tierNum1I = Integer.parseInt(tierNum1);
float exp1 = pet1.get("exp").getAsFloat();
String tier2 = pet2.get("tier").getAsString();
- String tierNum2 = GuiProfileViewer.MINION_RARITY_TO_NUM.get(tier2);
+ String tierNum2 = GuiProfileViewer.RARITY_TO_NUM.get(tier2);
if (tierNum2 == null) return -1;
int tierNum2I = Integer.parseInt(tierNum2);
float exp2 = pet2.get("exp").getAsFloat();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
index 9be3eaf4..0d298a71 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
@@ -27,11 +27,9 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.profileviewer.info.QuiverInfo;
import io.github.moulberry.notenoughupdates.util.Constants;
-import io.github.moulberry.notenoughupdates.util.JsonUtils;
import io.github.moulberry.notenoughupdates.util.PetLeveling;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.nbt.CompressedStreamTools;
-import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
@@ -40,17 +38,11 @@ import org.jetbrains.annotations.Nullable;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.util.AbstractMap;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
public class PlayerStats {
@@ -296,11 +288,11 @@ public class PlayerStats {
private static Stats getSetBonuses(
Stats stats,
- JsonObject inventoryInfo,
+ Map<String, JsonArray> inventoryInfo,
Map<String, ProfileViewer.Level> skyblockInfo,
JsonObject profile
) {
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ JsonArray armor = inventoryInfo.get("inv_armor");
Stats bonuses = new Stats();
@@ -346,7 +338,7 @@ public class PlayerStats {
if (chestplateElement != null && chestplateElement.isJsonObject()) {
JsonObject chestplate = chestplateElement.getAsJsonObject();
if (chestplate.get("internalname").getAsString().equals("OBSIDIAN_CHESTPLATE")) {
- JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
+ JsonArray inventory = inventoryInfo.get("inv_contents");
for (int i = 0; i < inventory.size(); i++) {
JsonElement itemElement = inventory.get(i);
if (itemElement != null && itemElement.isJsonObject()) {
@@ -484,7 +476,7 @@ public class PlayerStats {
return new Stats();
}
- String tierNum = GuiProfileViewer.MINION_RARITY_TO_NUM.get(tier);
+ String tierNum = GuiProfileViewer.RARITY_TO_NUM.get(tier);
float exp = pet.get("exp").getAsFloat();
if (tierNum == null) return new Stats();
@@ -561,10 +553,10 @@ public class PlayerStats {
return new Stats();
}
- private static float getStatMult(JsonObject inventoryInfo) {
+ private static float getStatMult(Map<String, JsonArray> inventoryInfo) {
float mult = 1f;
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ JsonArray armor = inventoryInfo.get("inv_armor");
String fullset = getFullset(armor, -1);
@@ -577,8 +569,6 @@ public class PlayerStats {
if (itemElement == null || !itemElement.isJsonObject()) continue;
JsonObject item = itemElement.getAsJsonObject();
- String internalname = item.get("internalname").getAsString();
-
String reforge = Utils.getElementAsString(Utils.getElement(item, "ExtraAttributes.modifier"), "");
if (reforge.equals("renowned")) {
@@ -589,9 +579,9 @@ public class PlayerStats {
return mult;
}
- private static void applyLimits(Stats stats, JsonObject inventoryInfo) {
+ private static void applyLimits(Stats stats, Map<String, JsonArray> inventoryInfo) {
//>0
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ JsonArray armor = inventoryInfo.get("inv_armor");
String fullset = getFullset(armor, 3);
@@ -617,19 +607,19 @@ public class PlayerStats {
}
public static Stats getStats(
- Map<String, ProfileViewer.Level> skyblockInfo,
- JsonObject inventoryInfo,
+ Map<String, ProfileViewer.Level> levelingInfo,
+ Map<String, JsonArray> inventoryInfo,
JsonObject petsInfo,
JsonObject profile
) {
- if (skyblockInfo == null || inventoryInfo == null || profile == null) return null;
+ if (levelingInfo == null || inventoryInfo == null || profile == null) return null;
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
- JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
- JsonArray talisman_bag = Utils.getElement(inventoryInfo, "talisman_bag").getAsJsonArray();
+ JsonArray armor = inventoryInfo.get("inv_armor");
+ JsonArray inventory = inventoryInfo.get("inv_contents");
+ JsonArray talisman_bag = inventoryInfo.get("talisman_bag");
- Stats passiveBonuses = getPassiveBonuses(skyblockInfo, profile);
- Stats hotmBonuses = getHOTMBonuses(skyblockInfo, profile);
+ Stats passiveBonuses = getPassiveBonuses(levelingInfo, profile);
+ Stats hotmBonuses = getHOTMBonuses(levelingInfo, profile);
Stats armorBonuses = getItemBonuses(false, armor);
Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag);
@@ -643,11 +633,10 @@ public class PlayerStats {
}
Stats petBonus = getPetStatBonuses(petsInfo);
- if (petBonus == null) return null;
stats = stats.add(passiveBonuses).add(armorBonuses).add(talismanBonuses).add(petBonus).add(hotmBonuses);
- stats.add(getSetBonuses(stats, inventoryInfo, skyblockInfo, profile));
+ stats.add(getSetBonuses(stats, inventoryInfo, levelingInfo, profile));
stats.scaleAll(getStatMult(inventoryInfo));
@@ -661,7 +650,7 @@ public class PlayerStats {
*
* @param profileInfo profile information object
* @return selected magical power as a String or null
- * @see io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer.Profile#getProfileInformation(String)
+ * @see SkyblockProfiles.SkyblockProfile#getLevelingInfo()
*/
public static @Nullable String getSelectedMagicalPower(JsonObject profileInfo) {
String abs = "accessory_bag_storage";
@@ -678,16 +667,15 @@ public class PlayerStats {
return selectedPower.substring(0, 1).toUpperCase() + selectedPower.substring(1);
}
- public static @Nullable QuiverInfo getQuiverInfo(JsonObject inventoryInfo, JsonObject profileInfo) {
+ public static @Nullable QuiverInfo getQuiverInfo(Map<String, JsonArray> inventoryInfo, JsonObject profileInfo) {
if (inventoryInfo == null
- || !inventoryInfo.has("quiver")
- || !inventoryInfo.get("quiver").isJsonArray()) {
+ || !inventoryInfo.containsKey("quiver")) {
return null;
}
QuiverInfo quiverInfo = new QuiverInfo();
quiverInfo.arrows = new HashMap<>();
- JsonArray quiver = inventoryInfo.getAsJsonArray("quiver");
+ JsonArray quiver = inventoryInfo.get("quiver");
for (JsonElement quiverEntry : quiver) {
if (quiverEntry == null || quiverEntry.isJsonNull() || !quiverEntry.isJsonObject()) {
continue;
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 ea852da3..8c552146 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -19,57 +19,27 @@
package io.github.moulberry.notenoughupdates.profileviewer;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
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.bestiary.BestiaryData;
-import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight;
-import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
-import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo;
+import lombok.Getter;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompressedStreamTools;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
-import javax.annotation.Nullable;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.time.Duration;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
-import java.util.regex.Pattern;
public class ProfileViewer {
- private static final HashMap<String, String> petRarityToNumMap = new HashMap<String, String>() {
- {
- put("COMMON", "0");
- put("UNCOMMON", "1");
- put("RARE", "2");
- put("EPIC", "3");
- put("LEGENDARY", "4");
- put("MYTHIC", "5");
- }
- };
+ @Getter
private static final LinkedHashMap<String, ItemStack> skillToSkillDisplayMap =
new LinkedHashMap<String, ItemStack>() {
{
@@ -121,6 +91,7 @@ public class ProfileViewer {
Items.fishing_rod,
EnumChatFormatting.AQUA + "Fishing"
);
+ @Getter
private static final LinkedHashMap<ItemStack, List<String>> collectionCatToCollectionMap =
new LinkedHashMap<ItemStack, List<String>>() {
{
@@ -213,6 +184,7 @@ public class ProfileViewer {
);
}
};
+ @Getter
private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap =
new LinkedHashMap<ItemStack, List<String>>() {
{
@@ -289,6 +261,7 @@ public class ProfileViewer {
put(CAT_FISHING, Utils.createList("FISHING", null, null, null, null, null, "CLAY", null, null, null));
}
};
+ @Getter
private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap =
new LinkedHashMap<String, ItemStack>() {
{
@@ -448,74 +421,20 @@ public class ProfileViewer {
);
}
};
-
- public static final List<String> SLAYERS = Arrays.asList("zombie", "spider", "wolf", "enderman", "blaze");
-
private static final AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
private static JsonObject resourceCollection = null;
- private final NEUManager manager;
+ @Getter
private final HashMap<String, JsonObject> uuidToHypixelProfile = new HashMap<>();
- private final HashMap<String, Profile> uuidToProfileMap = new HashMap<>();
-
+ @Getter
+ private final NEUManager manager;
+ private final HashMap<String, SkyblockProfiles> uuidToSkyblockProfiles = new HashMap<>();
private final HashMap<String, String> nameToUuid = new HashMap<>();
public ProfileViewer(NEUManager manager) {
this.manager = manager;
}
- public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToMinionMap() {
- return collectionCatToMinionMap;
- }
-
- public static LinkedHashMap<String, ItemStack> getCollectionToCollectionDisplayMap() {
- return collectionToCollectionDisplayMap;
- }
-
- public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToCollectionMap() {
- return collectionCatToCollectionMap;
- }
-
- public static Map<String, ItemStack> getSkillToSkillDisplayMap() {
- return Collections.unmodifiableMap(skillToSkillDisplayMap);
- }
-
- public static Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) {
- Level levelObj = new Level();
- levelObj.totalXp = xp;
- levelObj.maxLevel = levelCap;
-
- for (int level = 0; level < levelingArray.size(); level++) {
- float levelXp = levelingArray.get(level).getAsFloat();
-
- if (levelXp > xp) {
- if (cumulative) {
- float previous = level > 0 ? levelingArray.get(level - 1).getAsFloat() : 0;
- levelObj.maxXpForLevel = (levelXp - previous);
- levelObj.level = 1 + level + (xp - levelXp) / levelObj.maxXpForLevel;
- } else {
- levelObj.maxXpForLevel = levelXp;
- levelObj.level = level + xp / levelXp;
- }
-
- if (levelObj.level > levelCap) {
- levelObj.level = levelCap;
- levelObj.maxed = true;
- }
-
- return levelObj;
- } else {
- if (!cumulative) {
- xp -= levelXp;
- }
- }
- }
-
- levelObj.level = Math.min(levelingArray.size(), levelCap);
- levelObj.maxed = true;
- return levelObj;
- }
-
- public static JsonObject getResourceCollectionInformation() {
+ public static JsonObject getOrLoadCollectionsResource() {
if (resourceCollection != null) return resourceCollection;
if (updatingResourceCollection.get()) return null;
@@ -533,53 +452,26 @@ public class ProfileViewer {
return null;
}
- public void getHypixelProfile(String name, Consumer<JsonObject> callback) {
- String nameF = name.toLowerCase();
- manager.apiUtils
- .newHypixelApiRequest("player")
- .queryArgument("name", nameF)
- .maxCacheAge(Duration.ofSeconds(30))
- .requestJson()
- .thenAccept(jsonObject -> {
- if (
- jsonObject != null &&
- jsonObject.has("success") &&
- jsonObject.get("success").getAsBoolean() &&
- jsonObject.get("player").isJsonObject()
- ) {
- nameToUuid.put(nameF, jsonObject.get("player").getAsJsonObject().get("uuid").getAsString());
- uuidToHypixelProfile.put(
- jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(),
- jsonObject.get("player").getAsJsonObject()
- );
- if (callback != null) callback.accept(jsonObject);
- } else {
- if (callback != null) callback.accept(null);
- }
- }
- );
- }
-
public void putNameUuid(String name, String uuid) {
nameToUuid.put(name, uuid);
}
public void getPlayerUUID(String name, Consumer<String> uuidCallback) {
- String nameF = name.toLowerCase();
- if (nameToUuid.containsKey(nameF)) {
- uuidCallback.accept(nameToUuid.get(nameF));
+ String nameLower = name.toLowerCase();
+ if (nameToUuid.containsKey(nameLower)) {
+ uuidCallback.accept(nameToUuid.get(nameLower));
return;
}
manager.apiUtils
.request()
- .url("https://api.mojang.com/users/profiles/minecraft/" + nameF)
+ .url("https://api.mojang.com/users/profiles/minecraft/" + nameLower)
.requestJson()
.thenAccept(jsonObject -> {
if (jsonObject.has("id") && jsonObject.get("id").isJsonPrimitive() &&
- ((JsonPrimitive) jsonObject.get("id")).isString()) {
+ jsonObject.get("id").getAsJsonPrimitive().isString()) {
String uuid = jsonObject.get("id").getAsString();
- nameToUuid.put(nameF, uuid);
+ nameToUuid.put(nameLower, uuid);
uuidCallback.accept(uuid);
return;
}
@@ -587,54 +479,60 @@ public class ProfileViewer {
});
}
- public void getProfileByName(String name, Consumer<Profile> callback) {
- String nameF = name.toLowerCase();
+ public void loadPlayerByName(String name, Consumer<SkyblockProfiles> callback) {
+ String nameLower = name.toLowerCase();
- if (nameToUuid.containsKey(nameF) && nameToUuid.get(nameF) == null) {
+ if (nameToUuid.containsKey(nameLower) && nameToUuid.get(nameLower) == null) {
callback.accept(null);
return;
}
getPlayerUUID(
- nameF,
+ nameLower,
uuid -> {
+ nameToUuid.put(nameLower, uuid);
if (uuid == null) {
- getHypixelProfile(
- nameF,
- jsonObject -> {
- if (jsonObject != null) {
- callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {}));
- } else {
- callback.accept(null);
- nameToUuid.put(nameF, null);
- }
- }
- );
+ callback.accept(null);
} else {
if (!uuidToHypixelProfile.containsKey(uuid)) {
- getHypixelProfile(nameF, jsonObject -> {});
+ manager.apiUtils
+ .newHypixelApiRequest("player")
+ .queryArgument("uuid", uuid)
+ .maxCacheAge(Duration.ofSeconds(30))
+ .requestJson()
+ .thenAccept(playerJson -> {
+ if (
+ playerJson != null &&
+ playerJson.has("success") &&
+ playerJson.get("success").getAsBoolean() &&
+ playerJson.get("player").isJsonObject()
+ ) {
+ uuidToHypixelProfile.put(uuid, playerJson.get("player").getAsJsonObject());
+ }
+ }
+ );
}
- callback.accept(getProfileReset(uuid, ignored -> {}));
+
+ callback.accept(getOrLoadSkyblockProfiles(uuid, ignored -> {}));
}
}
);
}
- public Profile getProfile(String uuid, Consumer<Profile> callback) {
- Profile profile = uuidToProfileMap.computeIfAbsent(uuid, k -> new Profile(uuid));
- if (profile.skyblockProfiles != null) {
+ public SkyblockProfiles getOrLoadSkyblockProfiles(String uuid, Consumer<SkyblockProfiles> callback) {
+ if (uuidToSkyblockProfiles.containsKey(uuid)) {
+ uuidToSkyblockProfiles.get(uuid).resetCache();
+ }
+
+ SkyblockProfiles profile = uuidToSkyblockProfiles.computeIfAbsent(uuid, key -> new SkyblockProfiles(this, uuid));
+ if (profile.getNameToProfile() != null) {
callback.accept(profile);
} else {
- profile.getSkyblockProfiles(() -> callback.accept(profile));
+ profile.getOrLoadSkyblockProfiles(() -> callback.accept(profile));
}
return profile;
}
- public Profile getProfileReset(String uuid, Consumer<Profile> callback) {
- if (uuidToProfileMap.containsKey(uuid)) uuidToProfileMap.get(uuid).resetCache();
- return getProfile(uuid, callback);
- }
-
public static class Level {
public float level = 0;
@@ -643,1081 +541,4 @@ public class ProfileViewer {
public int maxLevel;
public float totalXp;
}
-
- public class Profile {
-
- private final String uuid;
- private final HashMap<String, JsonObject> profileMap = new HashMap<>();
- private final HashMap<String, JsonObject> petsInfoMap = new HashMap<>();
- private final HashMap<String, List<JsonObject>> coopProfileMap = new HashMap<>();
- private final HashMap<String, Map<String, Level>> skyblockInfoCache = new HashMap<>();
- private final HashMap<String, JsonObject> inventoryCacheMap = new HashMap<>();
- private final HashMap<String, CompletableFuture<ProfileCollectionInfo>> collectionInfoMap = new HashMap<>();
- private final HashMap<String, Double> skyBlockExperience = new HashMap<>();
- private final HashMap<String, EnumChatFormatting> skyBlockExperienceColour = new HashMap<>();
- private final List<String> profileNames = new ArrayList<>();
- private final HashMap<String, PlayerStats.Stats> stats = new HashMap<>();
- private final HashMap<String, PlayerStats.Stats> passiveStats = new HashMap<>();
- private final HashMap<String, Long> networth = new HashMap<>();
- private final HashMap<String, Integer> magicalPower = new HashMap<>();
- private final HashMap<String, SoopyNetworthData> soopyNetworth = new HashMap<>();
- private final AtomicBoolean updatingSkyblockProfilesState = new AtomicBoolean(false);
- private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
- private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
- 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 long soopyWeightLeaderboardPosition = -1; //-1 = default, -2 = loading, -3 = error
- private String latestProfile = null;
- private JsonArray skyblockProfiles = null;
- private JsonObject guildInformation = null;
- private JsonObject playerStatus = null;
- private JsonObject bingoInformation = null;
- private long lastPlayerInfoState = 0;
- private long lastStatusInfoState = 0;
- private long lastGuildInfoState = 0;
- private long lastBingoInfoState = 0;
-
- public Profile(String uuid) {
- this.uuid = uuid;
- }
-
- /**
- * Calculates the amount of Magical Power the player has using the list of accessories
- *
- * @return the amount of Magical Power or -1
- * @see io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer.Profile#getInventoryInfo(String)
- */
- public int getMagicalPower(String profileId) {
- JsonObject inventoryInfo = getInventoryInfo(profileId);
- JsonObject profileInfo = getProfileInformation(profileId);
- if (magicalPower.containsKey(profileId)) return magicalPower.get(profileId);
- if (inventoryInfo == null || !inventoryInfo.has("talisman_bag") ||
- !inventoryInfo.get("talisman_bag").isJsonArray()) {
- return -1;
- }
-
- int powerAmount = ProfileViewerUtils.getMagicalPower(inventoryInfo, profileInfo);
- magicalPower.put(profileId, powerAmount);
- return powerAmount;
- }
-
- public JsonObject getPlayerStatus() {
- if (playerStatus != null) return playerStatus;
- if (updatingPlayerStatusState.get()) return null;
-
- long currentTime = System.currentTimeMillis();
- if (currentTime - lastStatusInfoState < 15 * 1000) return null;
- lastStatusInfoState = currentTime;
- updatingPlayerStatusState.set(true);
-
- HashMap<String, String> args = new HashMap<>();
- args.put("uuid", "" + uuid);
- manager.apiUtils
- .newHypixelApiRequest("status")
- .queryArgument("uuid", "" + uuid)
- .requestJson()
- .handle((jsonObject, ex) -> {
- updatingPlayerStatusState.set(false);
-
- if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- playerStatus = jsonObject.get("session").getAsJsonObject();
- }
- return null;
- });
- return null;
- }
-
- public JsonObject getBingoInformation() {
- long currentTime = System.currentTimeMillis();
- if (bingoInformation != null && currentTime - lastBingoInfoState < 15 * 1000) return bingoInformation;
- if (updatingBingoInfo.get() && bingoInformation != null) return bingoInformation;
- if (updatingBingoInfo.get() && bingoInformation == null) return null;
-
- lastBingoInfoState = currentTime;
- updatingBingoInfo.set(true);
-
- NotEnoughUpdates.INSTANCE.manager.apiUtils
- .newHypixelApiRequest("skyblock/bingo")
- .queryArgument("uuid", "" + uuid)
- .requestJson()
- .handle(((jsonObject, throwable) -> {
- updatingBingoInfo.set(false);
-
- if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- bingoInformation = jsonObject;
- } else {
- bingoInformation = null;
- }
- return null;
- }));
- return bingoInformation != null ? bingoInformation : null;
- }
-
- public class SoopyNetworthData {
- private HashMap<String, Long> categoryWorth;
- private Long totalWorth;
- private String[] keys;
-
- SoopyNetworthData(JsonObject nwData) {
- categoryWorth = new HashMap<>();
-
- if (nwData == null || nwData.isJsonNull()) {
- totalWorth = -1l;
- keys = new String[0];
- return;
- }
- if (nwData.get("total").isJsonNull()) {
- totalWorth = -1l;
- keys = new String[0];
- return;
- }
-
- totalWorth = nwData.get("total").getAsLong();
- for (Map.Entry<String, JsonElement> entry : nwData.get("categories").getAsJsonObject().entrySet()) {
- if (entry.getValue().isJsonNull()) {
- continue;
- }
- categoryWorth.put(entry.getKey(), entry.getValue().getAsLong());
- }
-
- //Sort keys based on category value
- keys = categoryWorth
- .keySet()
- .stream()
- .sorted(Comparator.comparingLong(k -> getCategory((String) k)).reversed())
- .toArray(String[]::new);
- }
-
- private SoopyNetworthData setLoading() {
- totalWorth = -2l;
- return this;
- }
-
- public long getTotal() {
- return totalWorth;
- }
-
- public long getCategory(String name) {
- if (categoryWorth.containsKey(name)) return categoryWorth.get(name);
- return 0;
- }
-
- public String[] getCategories() {
- return keys;
- }
- }
-
- /**
- * -1 = default, -2 = loading, -3 = error
- * >= 0 = actual position
- */
- public long getSoopyNetworthLeaderboardPosition() {
- if ("d0e05de76067454dbeaec6d19d886191".equals(uuid)) return 1;
- return soopyNetworthLeaderboardPosition;
- }
-
- public long getSoopyWeightLeaderboardPosition() {
- if ("d0e05de76067454dbeaec6d19d886191".equals(uuid)) return 1;
- return soopyWeightLeaderboardPosition;
- }
-
- 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);
- }
-
- /**
- * Returns SoopyNetworthData with total = -1 if error
- * Returns null if still loading
- */
- public SoopyNetworthData getSoopyNetworth(String profileName, Runnable callback) {
- if (profileName == null) profileName = latestProfile;
- if (soopyNetworth.get(profileName) != null) {
- callback.run();
- return soopyNetworth.get(profileName);
- }
-
- 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
- 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;
- });
-
- 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)
- .method("POST")
- .postData("application/json", skyblockProfiles.toString())
- .requestJson()
- .handle((jsonObject, throwable) -> {
- if (throwable != null) throwable.printStackTrace();
- if (throwable != null || !jsonObject.has("success") || !jsonObject.get("success").getAsBoolean()) {
- //Something went wrong
- //Set profile networths to null to indicate that
- for (int i = 0; i < skyblockProfiles.size(); i++) {
- if (!skyblockProfiles.get(i).isJsonObject()) {
- return null;
- }
- JsonObject profile = skyblockProfiles.get(i).getAsJsonObject();
-
- String cuteName = profile.get("cute_name").getAsString();
-
- soopyNetworth.put(cuteName, new SoopyNetworthData(null));
- }
- updatingSoopyNetworth.set(false);
- callback.run();
- return null;
- }
-
- //Success, update networth data
- for (int i = 0; i < skyblockProfiles.size(); i++) {
- if (!skyblockProfiles.get(i).isJsonObject()) {
- return null;
- }
- JsonObject profile = skyblockProfiles.get(i).getAsJsonObject();
-
- String cuteName = profile.get("cute_name").getAsString();
- String profileId = profile.get("profile_id").getAsString().replace("-", "");
-
- SoopyNetworthData networth;
- if (jsonObject.getAsJsonObject("data").get(profileId) == null) {
- networth = new SoopyNetworthData(null);
- } else {
- networth = new SoopyNetworthData(jsonObject.getAsJsonObject("data").get(profileId).getAsJsonObject());
- }
-
- soopyNetworth.put(cuteName, networth);
- }
-
- updatingSoopyNetworth.set(false);
- callback.run();
- return null;
- });
- return null;
- }
-
- public EnumChatFormatting getSkyblockLevelColour(String profileName) {
- if (Constants.SBLEVELS == null) return EnumChatFormatting.WHITE;
- if (skyBlockExperienceColour.containsKey(profileName)) {
- return skyBlockExperienceColour.get(profileName);
- }
-
- double skyblockLevel = getSkyblockLevel(profileName);
- EnumChatFormatting levelColour = EnumChatFormatting.WHITE;
-
- if (Constants.SBLEVELS == null || !Constants.SBLEVELS.has("sblevel_colours")) {
- Utils.showOutdatedRepoNotification();
- return EnumChatFormatting.WHITE;
- }
-
- JsonObject sblevelColours = Constants.SBLEVELS.getAsJsonObject("sblevel_colours");
- try {
- for (Map.Entry<String, JsonElement> stringJsonElementEntry : sblevelColours.entrySet()) {
- int nextLevelBracket = Integer.parseInt(stringJsonElementEntry.getKey());
- EnumChatFormatting valueByName = EnumChatFormatting.getValueByName(stringJsonElementEntry
- .getValue()
- .getAsString());
- if (skyblockLevel >= nextLevelBracket) {
- levelColour = valueByName;
- }
- }
- } catch (RuntimeException ignored) {
- // catch both numberformat and getValueByName being wrong
- }
- skyBlockExperienceColour.put(profileName, levelColour);
- return levelColour;
- }
-
- public double getSkyblockLevel(String profileName) {
- if (skyBlockExperience.containsKey(profileName)) {
- return skyBlockExperience.get(profileName);
- }
- final JsonObject profileInfo = getProfileInformation(profileName);
- int element = Utils.getElementAsInt(Utils.getElement(profileInfo, "leveling.experience"), 0);
- double level = (element / 100F);
- skyBlockExperience.put(profileName, level);
- return level;
- }
-
- public long getNetWorth(String profileName) {
- if (profileName == null) profileName = latestProfile;
- if (networth.get(profileName) != null) return networth.get(profileName);
- if (getProfileInformation(profileName) == null) return -1;
- if (getInventoryInfo(profileName) == null) return -1;
-
- JsonObject inventoryInfo = getInventoryInfo(profileName);
- JsonObject profileInfo = getProfileInformation(profileName);
-
- HashMap<String, Long> mostExpensiveInternal = new HashMap<>();
-
- long networth = 0;
- for (Map.Entry<String, JsonElement> entry : inventoryInfo.entrySet()) {
- if (entry.getValue().isJsonArray()) {
- for (JsonElement element : entry.getValue().getAsJsonArray()) {
- if (element != null && element.isJsonObject()) {
- JsonObject item = element.getAsJsonObject();
- String internalname = item.get("internalname").getAsString();
-
- if (manager.auctionManager.isVanillaItem(internalname)) continue;
-
- JsonObject bzInfo = manager.auctionManager.getBazaarInfo(internalname);
-
- long auctionPrice;
- if (bzInfo != null && bzInfo.has("curr_sell")) {
- auctionPrice = (int) bzInfo.get("curr_sell").getAsFloat();
- } else {
- auctionPrice = (long) manager.auctionManager.getItemAvgBin(internalname);
- if (auctionPrice <= 0) {
- auctionPrice = manager.auctionManager.getLowestBin(internalname);
- }
- }
-
- try {
- if (item.has("item_contents")) {
- JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
- byte[] bytes = new byte[bytesArr.size()];
- for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) {
- bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte();
- }
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- for (int j = 0; j < items.tagCount(); j++) {
- if (items.getCompoundTagAt(j).getKeySet().size() > 0) {
- NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
- String internalname2 = manager.getInternalnameFromNBT(nbt);
- if (internalname2 != null) {
- if (manager.auctionManager.isVanillaItem(internalname2)) continue;
-
- JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname2);
-
- long auctionPrice2;
- if (bzInfo2 != null && bzInfo2.has("curr_sell")) {
- auctionPrice2 = (int) bzInfo2.get("curr_sell").getAsFloat();
- } else {
- auctionPrice2 = (long) manager.auctionManager.getItemAvgBin(internalname2);
- if (auctionPrice2 <= 0) {
- auctionPrice2 = manager.auctionManager.getLowestBin(internalname2);
- }
- }
-
- int count2 = items.getCompoundTagAt(j).getByte("Count");
-
- mostExpensiveInternal.put(
- internalname2,
- auctionPrice2 * count2 + mostExpensiveInternal.getOrDefault(internalname2, 0L)
- );
- networth += auctionPrice2 * count2;
- }
- }
- }
- }
- } catch (IOException ignored) {
- }
-
- int count = 1;
- if (element.getAsJsonObject().has("count")) {
- count = element.getAsJsonObject().get("count").getAsInt();
- }
- mostExpensiveInternal.put(
- internalname,
- auctionPrice * count + mostExpensiveInternal.getOrDefault(internalname, 0L)
- );
- networth += auctionPrice * count;
- }
- }
- }
- }
- if (networth == 0) return -1;
-
- networth = (int) (networth * 1.3f);
-
- JsonObject petsInfo = getPetsInfo(profileName);
- if (petsInfo != null && petsInfo.has("pets")) {
- if (petsInfo.get("pets").isJsonArray()) {
- JsonArray pets = petsInfo.get("pets").getAsJsonArray();
- for (JsonElement element : pets) {
- if (element.isJsonObject()) {
- JsonObject pet = element.getAsJsonObject();
-
- String petname = pet.get("type").getAsString();
- String tier = pet.get("tier").getAsString();
- String tierNum = petRarityToNumMap.get(tier);
- if (tierNum != null) {
- String internalname2 = petname + ";" + tierNum;
- JsonObject info2 = manager.auctionManager.getItemAuctionInfo(internalname2);
- if (info2 == null || !info2.has("price") || !info2.has("count")) continue;
- int auctionPrice2 = (int) (info2.get("price").getAsFloat() / info2.get("count").getAsFloat());
-
- networth += auctionPrice2;
- }
- }
- }
- }
- }
-
- float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
- float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
-
- networth += bankBalance + purseBalance;
-
- this.networth.put(profileName, networth);
- return networth;
- }
-
- public String getLatestProfile() {
- return latestProfile;
- }
-
- public JsonArray getSkyblockProfiles(Runnable runnable) {
- if (skyblockProfiles != null) return skyblockProfiles;
-
- long currentTime = System.currentTimeMillis();
-
- if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingSkyblockProfilesState.get()) return null;
- lastPlayerInfoState = currentTime;
- updatingSkyblockProfilesState.set(true);
-
- manager.apiUtils
- .newHypixelApiRequest("skyblock/profiles")
- .queryArgument("uuid", "" + uuid)
- .requestJson()
- .handle((jsonObject, throwable) -> {
- updatingSkyblockProfilesState.set(false);
-
- if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- if (!jsonObject.has("profiles")) return null;
- skyblockProfiles = jsonObject.get("profiles").getAsJsonArray();
-
- String lastCuteName = null;
-
- profileNames.clear();
-
- for (JsonElement profileEle : skyblockProfiles) {
- JsonObject profile = profileEle.getAsJsonObject();
-
- if (!profile.has("members")) continue;
- JsonObject members = profile.get("members").getAsJsonObject();
-
- if (members.has(uuid)) {
- JsonObject member = members.get(uuid).getAsJsonObject();
-
- if (member.has("coop_invitation")) {
- if (!member.get("coop_invitation").getAsJsonObject().get("confirmed").getAsBoolean()) {
- continue;
- }
- }
-
- String cuteName = profile.get("cute_name").getAsString();
- profileNames.add(cuteName);
- if (profile.has("selected") && profile.get("selected").getAsBoolean()) {
- lastCuteName = cuteName;
- }
- }
- }
- latestProfile = lastCuteName;
-
- if (runnable != null) runnable.run();
- }
- return null;
- });
- return null;
- }
-
- public JsonObject getGuildInformation(Runnable runnable) {
- if (guildInformation != null) return guildInformation;
-
- long currentTime = System.currentTimeMillis();
-
- if (currentTime - lastGuildInfoState < 15 * 1000 && updatingGuildInfoState.get()) return null;
- lastGuildInfoState = currentTime;
- updatingGuildInfoState.set(true);
-
- manager.apiUtils
- .newHypixelApiRequest("guild")
- .queryArgument("player", "" + uuid)
- .requestJson()
- .handle((jsonObject, ex) -> {
- updatingGuildInfoState.set(false);
-
- if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- if (!jsonObject.has("guild")) return null;
-
- guildInformation = jsonObject.get("guild").getAsJsonObject();
-
- if (runnable != null) runnable.run();
- }
- return null;
- });
- return null;
- }
-
- public List<String> getProfileNames() {
- return profileNames;
- }
-
- public JsonObject getProfileInformation(String profileName) {
- if (profileName == null) profileName = latestProfile;
- if (profileMap.containsKey(profileName)) return profileMap.get(profileName);
- JsonObject profile = getRawProfileInformation(profileName);
- if (profile == null) return null;
- if (!profile.has("members")) return null;
- JsonObject members = profile.get("members").getAsJsonObject();
- if (!members.has(uuid)) return null;
- JsonObject profileInfo = members.get(uuid).getAsJsonObject();
- if (profile.has("banking")) {
- profileInfo.add("banking", profile.get("banking").getAsJsonObject());
- }
- if (profile.has("game_mode")) {
- profileInfo.add("game_mode", profile.get("game_mode"));
- }
- if (profile.has("community_upgrades")) {
- profileInfo.add("community_upgrades", profile.get("community_upgrades"));
- }
- profileMap.put(profileName, profileInfo);
- return profileInfo;
- }
-
- public JsonObject getRawProfileInformation(String profileName) {
- JsonArray playerInfo = getSkyblockProfiles(() -> {});
- if (playerInfo == null) return null;
- if (profileName == null) profileName = latestProfile;
-
- for (JsonElement skyblockProfile : skyblockProfiles) {
- if (!skyblockProfile.isJsonObject()) {
- skyblockProfiles = null;
- return null;
- }
- if (skyblockProfile.getAsJsonObject().get("cute_name").getAsString().equalsIgnoreCase(profileName))
- return skyblockProfile.getAsJsonObject();
- }
- return null;
- }
-
- public List<JsonObject> getCoopProfileInformation(String profileName) {
- if (profileName == null) profileName = latestProfile;
- if (coopProfileMap.containsKey(profileName)) return coopProfileMap.get(profileName);
- JsonObject profile = getRawProfileInformation(profileName);
- if (profile == null) return null;
-
- if (!profile.has("members")) return null;
- JsonObject members = profile.get("members").getAsJsonObject();
- if (!members.has(uuid)) return null;
- List<JsonObject> coopList = new ArrayList<>();
- for (Map.Entry<String, JsonElement> islandMember : members.entrySet()) {
- if (!islandMember.getKey().equals(uuid)) {
- JsonObject coopProfileInfo = islandMember.getValue().getAsJsonObject();
- coopList.add(coopProfileInfo);
- }
- }
- coopProfileMap.put(profileName, coopList);
- return coopList;
-
- }
-
- public void resetCache() {
- skyblockProfiles = null;
- guildInformation = null;
- playerStatus = null;
- stats.clear();
- passiveStats.clear();
- profileNames.clear();
- profileMap.clear();
- coopProfileMap.clear();
- petsInfoMap.clear();
- skyblockInfoCache.clear();
- inventoryCacheMap.clear();
- collectionInfoMap.clear();
- networth.clear();
- magicalPower.clear();
- skyBlockExperience.clear();
- skyBlockExperienceColour.clear();
- }
-
- public int getCap(JsonObject leveling, String skillName) {
- JsonElement capsElement = Utils.getElement(leveling, "leveling_caps");
- return capsElement != null && capsElement.isJsonObject() && capsElement.getAsJsonObject().has(skillName)
- ? capsElement.getAsJsonObject().get(skillName).getAsInt()
- : 50;
- }
-
- public int getBestiaryTiers(JsonObject profileInfo) {
- int beLevel = 0;
- for (ItemStack items : BestiaryData.getBestiaryLocations().keySet()) {
- List<String> mobs = BestiaryData.getBestiaryLocations().get(items);
- if (mobs != null) {
- for (String mob : mobs) {
- if (mob != null) {
- float kills = Utils.getElementAsFloat(Utils.getElement(profileInfo, "bestiary.kills_" + mob), 0);
- String type;
- if (BestiaryData.getMobType().get(mob) != null) {
- type = BestiaryData.getMobType().get(mob);
- } else {
- type = "MOB";
- }
- JsonObject leveling = Constants.LEVELING;
- ProfileViewer.Level level = null;
- if (leveling != null && Utils.getElement(leveling, "bestiary." + type) != null) {
- JsonArray levelingArray = Utils.getElement(leveling, "bestiary." + type).getAsJsonArray();
- int levelCap = Utils.getElementAsInt(Utils.getElement(leveling, "bestiary.caps." + type), 0);
- level = ProfileViewer.getLevel(levelingArray, kills, levelCap, false);
- }
-
- float levelNum = 0;
- if (level != null) {
- levelNum = level.level;
- }
- beLevel += (int) Math.floor(levelNum);
- }
- }
- }
- }
- return beLevel;
- }
-
- public Map<String, Level> getSkyblockInfo(String profileName) {
- JsonObject profileInfo = getProfileInformation(profileName);
-
- if (profileInfo == null) return null;
- if (profileName == null) profileName = latestProfile;
- List<JsonObject> coopProfileInfo = getCoopProfileInformation(profileName);
- if (skyblockInfoCache.containsKey(profileName)) return skyblockInfoCache.get(profileName);
-
- JsonObject leveling = Constants.LEVELING;
- if (leveling == null || !leveling.has("social")) {
- Utils.showOutdatedRepoNotification();
- return null;
- }
-
- Map<String, Level> out = new HashMap<>();
-
- List<String> skills = Arrays.asList(
- "taming",
- "mining",
- "foraging",
- "enchanting",
- "carpentry",
- "farming",
- "combat",
- "fishing",
- "alchemy",
- "runecrafting",
- "social"
- );
- float totalSkillXP = 0;
- for (String skillName : skills) {
- float skillExperience = Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "experience_skill_" + (skillName.equals("social") ? "social2" : skillName)),
- 0
- );
- // Get the coop's social skill experience since social is a shared skill
- if (skillName.equals("social")) {
- for (JsonObject coopProfile : coopProfileInfo) {
- skillExperience += Utils.getElementAsFloat(
- Utils.getElement(coopProfile, "experience_skill_social2"),
- 0
- );
- }
- }
- totalSkillXP += skillExperience;
-
- JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray();
- if (skillName.equals("runecrafting")) {
- levelingArray = Utils.getElement(leveling, "runecrafting_xp").getAsJsonArray();
- } else if (skillName.equals("social")) {
- levelingArray = Utils.getElement(leveling, "social").getAsJsonArray();
- }
-
- int maxLevel =
- getCap(leveling, skillName) +
- (
- skillName.equals("farming")
- ? Utils.getElementAsInt(Utils.getElement(profileInfo, "jacob2.perks.farming_level_cap"), 0)
- : 0
- );
- out.put(skillName, getLevel(levelingArray, skillExperience, maxLevel, false));
- }
-
- // Skills API disabled?
- if (totalSkillXP <= 0) {
- return null;
- }
-
- out.put(
- "hotm",
- getLevel(
- Utils.getElement(leveling, "leveling_xp").getAsJsonArray(),
- Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.experience"), 0),
- getCap(leveling, "HOTM"),
- false
- )
- );
-
- out.put(
- "catacombs",
- getLevel(
- Utils.getElement(leveling, "catacombs").getAsJsonArray(),
- Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.experience"), 0),
- getCap(leveling, "catacombs"),
- false
- )
- );
-
- List<String> dungeonClasses = Arrays.asList("healer", "tank", "mage", "archer", "berserk");
- for (String className : dungeonClasses) {
- float classExperience = Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "dungeons.player_classes." + className + ".experience"),
- 0
- );
- out.put(
- className,
- getLevel(
- Utils.getElement(leveling, "catacombs").getAsJsonArray(),
- classExperience,
- getCap(leveling, "catacombs"),
- false
- )
- );
- }
- for (String slayerName : SLAYERS) {
- float slayerExperience = Utils.getElementAsFloat(Utils.getElement(
- profileInfo,
- "slayer_bosses." + slayerName + ".xp"
- ), 0);
- out.put(
- slayerName,
- getLevel(Utils.getElement(leveling, "slayer_xp." + slayerName).getAsJsonArray(), slayerExperience, 9, true)
- );
- }
-
- skyblockInfoCache.put(profileName, out);
-
- return out;
- }
-
- public JsonObject getInventoryInfo(String profileName) {
- JsonObject profileInfo = getProfileInformation(profileName);
- if (profileInfo == null) return null;
- if (profileName == null) profileName = latestProfile;
- if (inventoryCacheMap.containsKey(profileName)) return inventoryCacheMap.get(profileName);
-
- String inv_armor_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "inv_armor.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String fishing_bag_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "fishing_bag.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String quiver_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "quiver.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String ender_chest_contents_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "ender_chest_contents.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- //Todo clean this up
- //Fake string is so for I loop works the same
- String backpack_contents_json_fake = "fake should fix later";
- JsonObject backpack_contents_json = (JsonObject) Utils.getElement(profileInfo, "backpack_contents");
- JsonObject backpack_icons = (JsonObject) Utils.getElement(profileInfo, "backpack_icons");
- String personal_vault_contents_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "personal_vault_contents.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String wardrobe_contents_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "wardrobe_contents.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String potion_bag_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "potion_bag.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String inv_contents_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "inv_contents.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String talisman_bag_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "talisman_bag.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String candy_inventory_contents_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "candy_inventory_contents.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
- String equipment_contents_bytes = Utils.getElementAsString(
- Utils.getElement(profileInfo, "equippment_contents.data"),
- "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
- );
-
- JsonObject inventoryInfo = new JsonObject();
-
- String[] inv_names = new String[]{
- "inv_armor",
- "fishing_bag",
- "quiver",
- "ender_chest_contents",
- "backpack_contents",
- "personal_vault_contents",
- "wardrobe_contents",
- "potion_bag",
- "inv_contents",
- "talisman_bag",
- "candy_inventory_contents",
- "equippment_contents",
- };
- String[] inv_bytes = new String[]{
- inv_armor_bytes,
- fishing_bag_bytes,
- quiver_bytes,
- ender_chest_contents_bytes,
- backpack_contents_json_fake,
- personal_vault_contents_bytes,
- wardrobe_contents_bytes,
- potion_bag_bytes,
- inv_contents_bytes,
- talisman_bag_bytes,
- candy_inventory_contents_bytes,
- equipment_contents_bytes,
- };
- for (int i = 0; i < inv_bytes.length; i++) {
- try {
- String bytes = inv_bytes[i];
-
- JsonArray contents = new JsonArray();
-
- if (inv_names[i].equals("backpack_contents")) {
- JsonObject temp = getBackpackData(backpack_contents_json, backpack_icons);
- contents = (JsonArray) temp.get("contents");
- inventoryInfo.add("backpack_sizes", temp.get("backpack_sizes"));
- } else {
- NBTTagCompound inv_contents_nbt = CompressedStreamTools.readCompressed(
- new ByteArrayInputStream(Base64.getDecoder().decode(bytes))
- );
- NBTTagList items = inv_contents_nbt.getTagList("i", 10);
- for (int j = 0; j < items.tagCount(); j++) {
- JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
- contents.add(item);
- }
- }
- inventoryInfo.add(inv_names[i], contents);
- } catch (IOException e) {
- inventoryInfo.add(inv_names[i], new JsonArray());
- }
- }
-
- inventoryCacheMap.put(profileName, inventoryInfo);
-
- return inventoryInfo;
- }
-
- public JsonObject getBackpackData(JsonObject backpackContentsJson, JsonObject backpackIcons) {
- if (backpackContentsJson == null || backpackIcons == null) {
- JsonObject bundledReturn = new JsonObject();
- bundledReturn.add("contents", new JsonArray());
- bundledReturn.add("backpack_sizes", new JsonArray());
-
- return bundledReturn;
- }
-
- String[] backpackArray = new String[0];
-
- //Create backpack array which sizes up
- for (Map.Entry<String, JsonElement> backpackIcon : backpackIcons.entrySet()) {
- if (backpackIcon.getValue() instanceof JsonObject) {
- JsonObject backpackData = (JsonObject) backpackContentsJson.get(backpackIcon.getKey());
- String bytes = Utils.getElementAsString(backpackData.get("data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- backpackArray = growArray(bytes, Integer.parseInt(backpackIcon.getKey()), backpackArray);
- }
- }
-
- //reduce backpack array to filter out not existent backpacks
- {
- String[] tempBackpackArray = new String[0];
- for (String s : backpackArray) {
- if (s != null) {
- String[] veryTempBackpackArray = new String[tempBackpackArray.length + 1];
- System.arraycopy(tempBackpackArray, 0, veryTempBackpackArray, 0, tempBackpackArray.length);
-
- veryTempBackpackArray[veryTempBackpackArray.length - 1] = s;
- tempBackpackArray = veryTempBackpackArray;
- }
- }
- backpackArray = tempBackpackArray;
- }
-
- JsonArray backpackSizes = new JsonArray();
- JsonArray contents = new JsonArray();
-
- for (String backpack : backpackArray) {
- try {
- NBTTagCompound inv_contents_nbt = CompressedStreamTools.readCompressed(
- new ByteArrayInputStream(Base64.getDecoder().decode(backpack))
- );
- NBTTagList items = inv_contents_nbt.getTagList("i", 10);
-
- backpackSizes.add(new JsonPrimitive(items.tagCount()));
- for (int j = 0; j < items.tagCount(); j++) {
- JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
- contents.add(item);
- }
- } catch (IOException ignored) {
- }
- }
-
- JsonObject bundledReturn = new JsonObject();
- bundledReturn.add("contents", contents);
- bundledReturn.add("backpack_sizes", backpackSizes);
-
- return bundledReturn;
- }
-
- public String[] growArray(String bytes, int index, String[] oldArray) {
- int newSize = Math.max(index + 1, oldArray.length);
-
- String[] newArray = new String[newSize];
- System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
- newArray[index] = bytes;
-
- return newArray;
- }
-
- public JsonObject getPetsInfo(String profileName) {
- JsonObject profileInfo = getProfileInformation(profileName);
- if (profileInfo == null) return null;
- if (petsInfoMap.containsKey(profileName)) return petsInfoMap.get(profileName);
-
- JsonObject petsInfo = new JsonObject();
- JsonElement petsElement = profileInfo.get("pets");
- if (petsElement != null && petsElement.isJsonArray()) {
- JsonObject activePet = null;
- JsonArray pets = petsElement.getAsJsonArray();
- for (int i = 0; i < pets.size(); i++) {
- JsonObject pet = pets.get(i).getAsJsonObject();
- if (pet.has("active") && pet.get("active").getAsBoolean()) {
- activePet = pet;
- break;
- }
- }
- petsInfo.add("active_pet", activePet);
- petsInfo.add("pets", pets);
- petsInfoMap.put(profileName, petsInfo);
- return petsInfo;
- }
- return null;
- }
-
- public ProfileCollectionInfo getCollectionInfo(String profileName) {
- JsonObject rawProfileInformation = getRawProfileInformation(profileName);
- if (rawProfileInformation == null) return null;
- CompletableFuture<ProfileCollectionInfo> future =
- collectionInfoMap.computeIfAbsent(
- profileName.toLowerCase(Locale.ROOT),
- ignored -> ProfileCollectionInfo.getCollectionData(rawProfileInformation, uuid)
- );
- return future.getNow(null);
- }
-
- public PlayerStats.Stats getPassiveStats(String profileName) {
- if (passiveStats.get(profileName) != null) return passiveStats.get(profileName);
- JsonObject profileInfo = getProfileInformation(profileName);
- if (profileInfo == null) return null;
-
- PlayerStats.Stats passiveStats = PlayerStats.getPassiveBonuses(getSkyblockInfo(profileName), profileInfo);
-
- if (passiveStats != null) {
- passiveStats.add(PlayerStats.getBaseStats());
- }
-
- this.passiveStats.put(profileName, passiveStats);
-
- return passiveStats;
- }
-
- public PlayerStats.Stats getStats(String profileName) {
- if (stats.get(profileName) != null) return stats.get(profileName);
- JsonObject profileInfo = getProfileInformation(profileName);
- if (profileInfo == null) {
- return null;
- }
-
- PlayerStats.Stats stats = PlayerStats.getStats(
- getSkyblockInfo(profileName),
- getInventoryInfo(profileName),
- getPetsInfo(profileName),
- profileInfo
- );
- if (stats == null) return null;
- this.stats.put(profileName, stats);
- return stats;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public @Nullable JsonObject getHypixelProfile() {
- return uuidToHypixelProfile.getOrDefault(uuid, null);
- }
- }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java
index 66164688..5c7e4b29 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewerUtils.java
@@ -48,34 +48,30 @@ import java.util.stream.Collectors;
public class ProfileViewerUtils {
- public static JsonObject readInventoryInfo(JsonObject profileInfo, String bagName) {
- JsonObject inventoryInfo = new JsonObject();
- JsonElement element = Utils.getElement(profileInfo, bagName + ".data");
+ public static JsonArray readInventoryInfo(JsonObject profileInfo, String bagName) {
+ String bytes = Utils.getElementAsString(Utils.getElement(profileInfo, bagName + ".data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String bytes = Utils.getElementAsString(element, "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- NBTTagCompound inv_contents_nbt;
+ NBTTagCompound nbt;
try {
- inv_contents_nbt = CompressedStreamTools.readCompressed(
+ nbt = CompressedStreamTools.readCompressed(
new ByteArrayInputStream(Base64.getDecoder().decode(bytes))
);
} catch (IOException e) {
e.printStackTrace();
return null;
}
- NBTTagList items = inv_contents_nbt.getTagList("i", 10);
+
+ NBTTagList items = nbt.getTagList("i", 10);
JsonArray contents = new JsonArray();
NEUManager manager = NotEnoughUpdates.INSTANCE.manager;
for (int j = 0; j < items.tagCount(); j++) {
- JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
- contents.add(item);
+ contents.add(manager.getJsonFromNBTEntry(items.getCompoundTagAt(j)));
}
- inventoryInfo.add(bagName, contents);
- return inventoryInfo;
+ return contents;
}
- public static int getMagicalPower(JsonObject inventoryInfo, JsonObject profileInfo) {
- JsonArray talismanBag = inventoryInfo.get("talisman_bag").getAsJsonArray();
+ public static int getMagicalPower(JsonArray talismanBag, JsonObject profileInfo) {
Map<String, Integer> accessories = JsonUtils.getJsonArrayAsStream(talismanBag).map(o -> {
try {
return JsonToNBT.getTagFromJson(o.getAsJsonObject().get("nbttag").getAsString());
@@ -153,4 +149,47 @@ public class ProfileViewerUtils {
}
return powerAmount;
}
+
+ public static int getLevelingCap(JsonObject leveling, String skillName) {
+ JsonElement capsElement = Utils.getElement(leveling, "leveling_caps");
+ return capsElement != null && capsElement.isJsonObject() && capsElement.getAsJsonObject().has(skillName)
+ ? capsElement.getAsJsonObject().get(skillName).getAsInt()
+ : 50;
+ }
+
+ public static ProfileViewer.Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) {
+ ProfileViewer.Level levelObj = new ProfileViewer.Level();
+ levelObj.totalXp = xp;
+ levelObj.maxLevel = levelCap;
+
+ for (int level = 0; level < levelingArray.size(); level++) {
+ float levelXp = levelingArray.get(level).getAsFloat();
+
+ if (levelXp > xp) {
+ if (cumulative) {
+ float previous = level > 0 ? levelingArray.get(level - 1).getAsFloat() : 0;
+ levelObj.maxXpForLevel = (levelXp - previous);
+ levelObj.level = 1 + level + (xp - levelXp) / levelObj.maxXpForLevel;
+ } else {
+ levelObj.maxXpForLevel = levelXp;
+ levelObj.level = level + xp / levelXp;
+ }
+
+ if (levelObj.level > levelCap) {
+ levelObj.level = levelCap;
+ levelObj.maxed = true;
+ }
+
+ return levelObj;
+ } else {
+ if (!cumulative) {
+ xp -= levelXp;
+ }
+ }
+ }
+
+ levelObj.level = Math.min(levelingArray.size(), levelCap);
+ levelObj.maxed = true;
+ return levelObj;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java
new file mode 100644
index 00000000..614e03f1
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/SkyblockProfiles.java
@@ -0,0 +1,974 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.profileviewer;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryData;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo;
+import lombok.Getter;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.EnumChatFormatting;
+
+import javax.annotation.Nullable;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class SkyblockProfiles {
+ private static final String defaultNbtData = "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=";
+ private static final String moulberryUuid = "d0e05de76067454dbeaec6d19d886191";
+ private static final List<String> inventoryNames = Arrays.asList(
+ "inv_armor",
+ "fishing_bag",
+ "quiver",
+ "ender_chest_contents",
+ "backpack_contents",
+ "personal_vault_contents",
+ "wardrobe_contents",
+ "potion_bag",
+ "inv_contents",
+ "talisman_bag",
+ "candy_inventory_contents",
+ "equippment_contents"
+ );
+ private static final List<String> skills = Arrays.asList(
+ "taming",
+ "mining",
+ "foraging",
+ "enchanting",
+ "carpentry",
+ "farming",
+ "combat",
+ "fishing",
+ "alchemy",
+ "runecrafting",
+ "social"
+ );
+ private final ProfileViewer profileViewer;
+ private final String uuid;
+ private final AtomicBoolean updatingSkyblockProfilesState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingSoopyData = new AtomicBoolean(false);
+ private final AtomicBoolean updatingBingoInfo = new AtomicBoolean(false);
+ @Getter
+ private Map<String, SkyblockProfile> nameToProfile = null;
+ private JsonArray profilesArray;
+ private List<String> profileNames = new ArrayList<>();
+ private String latestProfileName;
+ private long soopyNetworthLeaderboardPosition = -1; // -1 = default, -2 = loading, -3 = error
+ private long soopyWeightLeaderboardPosition = -1; // -1 = default, -2 = loading, -3 = error
+ private JsonObject guildInformation = null;
+ private JsonObject playerStatus = null;
+ private JsonObject bingoInformation = null;
+ private long lastPlayerInfoState = 0;
+ private long lastStatusInfoState = 0;
+ private long lastGuildInfoState = 0;
+ private long lastBingoInfoState = 0;
+
+ public SkyblockProfiles(ProfileViewer profileViewer, String uuid) {
+ this.profileViewer = profileViewer;
+ this.uuid = uuid;
+ }
+
+ public JsonObject getPlayerStatus() {
+ if (playerStatus != null) return playerStatus;
+ if (updatingPlayerStatusState.get()) return null;
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastStatusInfoState < 15 * 1000) return null;
+ lastStatusInfoState = currentTime;
+ updatingPlayerStatusState.set(true);
+
+ profileViewer.getManager().apiUtils
+ .newHypixelApiRequest("status")
+ .queryArgument("uuid", uuid)
+ .requestJson()
+ .handle((jsonObject, ex) -> {
+ updatingPlayerStatusState.set(false);
+
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ playerStatus = jsonObject.get("session").getAsJsonObject();
+ }
+ return null;
+ });
+ return null;
+ }
+
+ public JsonObject getBingoInformation() {
+ long currentTime = System.currentTimeMillis();
+ if (bingoInformation != null && currentTime - lastBingoInfoState < 15 * 1000) return bingoInformation;
+ if (updatingBingoInfo.get() && bingoInformation != null) return bingoInformation;
+ if (updatingBingoInfo.get() && bingoInformation == null) return null;
+
+ lastBingoInfoState = currentTime;
+ updatingBingoInfo.set(true);
+
+ NotEnoughUpdates.INSTANCE.manager.apiUtils
+ .newHypixelApiRequest("skyblock/bingo")
+ .queryArgument("uuid", uuid)
+ .requestJson()
+ .handle(((jsonObject, throwable) -> {
+ updatingBingoInfo.set(false);
+
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ bingoInformation = jsonObject;
+ } else {
+ bingoInformation = null;
+ }
+ return null;
+ }));
+ return bingoInformation != null ? bingoInformation : null;
+ }
+
+ /**
+ * -1 = default, -2 = loading, -3 = error
+ * >= 0 = actual position
+ */
+ public long getSoopyNetworthLeaderboardPosition() {
+ if (soopyNetworthLeaderboardPosition == -1) {
+ loadSoopyData(() -> {});
+ }
+ return moulberryUuid.equals(uuid) ? 1 : soopyNetworthLeaderboardPosition;
+ }
+
+ public long getSoopyWeightLeaderboardPosition() {
+ if (soopyWeightLeaderboardPosition == -1) {
+ loadSoopyData(() -> {});
+ }
+ return moulberryUuid.equals(uuid) ? 1 : soopyWeightLeaderboardPosition;
+ }
+
+ public boolean isProfileMaxSoopyWeight(String profileName) {
+ String highestProfileName = "";
+ double largestProfileWeight = 0;
+
+ for (Map.Entry<String, SkyblockProfile> profileEntry : nameToProfile.entrySet()) {
+ if (!profileEntry.getValue().skillsApiEnabled()) {
+ continue;
+ }
+
+ Map<String, ProfileViewer.Level> levelingInfo = profileEntry.getValue().getLevelingInfo();
+ if (levelingInfo == null) {
+ continue;
+ }
+
+ double weightValue = new SenitherWeight(levelingInfo).getTotalWeight().getRaw();
+ if (weightValue > largestProfileWeight) {
+ largestProfileWeight = weightValue;
+ highestProfileName = profileEntry.getKey();
+ }
+ }
+
+ return highestProfileName.equals(profileName);
+ }
+
+ private void loadSoopyData(Runnable callback) {
+ if (updatingSoopyData.get()) {
+ return;
+ }
+
+ updatingSoopyData.set(true);
+
+ soopyNetworthLeaderboardPosition = -2; // Loading
+ profileViewer.getManager().apiUtils
+ .request()
+ .url("https://soopy.dev/api/v2/leaderboard/networth/user/" + this.uuid)
+ .requestJson()
+ .handle((jsonObject, throwable) -> {
+ if (jsonObject == null || !jsonObject.has("success") || !jsonObject.get("success").getAsBoolean()
+ || !jsonObject.has("data")
+ || !jsonObject.getAsJsonObject("data").has("data")
+ || !jsonObject.getAsJsonObject("data").getAsJsonObject("data").has("position")) {
+ soopyNetworthLeaderboardPosition = -3; // Error
+ } else {
+ soopyNetworthLeaderboardPosition = jsonObject.getAsJsonObject("data").getAsJsonObject("data").get(
+ "position").getAsLong();
+ }
+ return null;
+ });
+
+ soopyWeightLeaderboardPosition = -2; // Loading
+ profileViewer.getManager().apiUtils
+ .request()
+ .url("https://soopy.dev/api/v2/leaderboard/weight/user/" + this.uuid)
+ .requestJson()
+ .handle((jsonObject, throwable) -> {
+ if (jsonObject == null || !jsonObject.has("success") || !jsonObject.get("success").getAsBoolean()
+ || !jsonObject.has("data")
+ || !jsonObject.getAsJsonObject("data").has("data")
+ || !jsonObject.getAsJsonObject("data").getAsJsonObject("data").has("position")) {
+ soopyWeightLeaderboardPosition = -3; // Error
+ } else {
+ soopyWeightLeaderboardPosition = jsonObject.getAsJsonObject("data").getAsJsonObject("data").get(
+ "position").getAsLong();
+ }
+ return null;
+ });
+
+ profileViewer.getManager().apiUtils
+ .request()
+ .url("https://soopy.dev/api/v2/player_networth/" + this.uuid)
+ .method("POST")
+ .postData("application/json", profilesArray.toString())
+ .requestJson()
+ .handle((jsonObject, throwable) -> {
+ if (jsonObject == null || !jsonObject.has("success") || !jsonObject.get("success").getAsBoolean()) {
+ for (Map.Entry<String, SkyblockProfile> entry : nameToProfile.entrySet()) {
+ entry.getValue().soopyNetworth = new SoopyNetworth(null);
+ }
+ updatingSoopyData.set(false);
+ callback.run();
+ return null;
+ }
+
+ for (Map.Entry<String, SkyblockProfile> entry : nameToProfile.entrySet()) {
+ String profileId = entry.getValue().getOuterProfileJson().get("profile_id").getAsString().replace("-", "");
+ JsonElement curProfileData = jsonObject.getAsJsonObject("data").get(profileId);
+ if (curProfileData == null) {
+ entry.getValue().soopyNetworth = new SoopyNetworth(null);
+ } else {
+ entry.getValue().soopyNetworth = new SoopyNetworth(curProfileData.getAsJsonObject());
+ }
+ }
+
+ updatingSoopyData.set(false);
+ callback.run();
+ return null;
+ });
+ }
+
+ public AtomicBoolean getUpdatingSkyblockProfilesState() {
+ return updatingSkyblockProfilesState;
+ }
+
+ public @Nullable SkyblockProfile getProfile(String profileName) {
+ return nameToProfile == null ? null : nameToProfile.get(profileName);
+ }
+
+ public SkyblockProfile getLatestProfile() {
+ return nameToProfile.get(latestProfileName);
+ }
+
+ public String getLatestProfileName() {
+ return latestProfileName;
+ }
+
+ public Map<String, SkyblockProfile> getOrLoadSkyblockProfiles(Runnable runnable) {
+ if (nameToProfile != null) {
+ return nameToProfile;
+ }
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingSkyblockProfilesState.get()) {
+ return null;
+ }
+ lastPlayerInfoState = currentTime;
+ updatingSkyblockProfilesState.set(true);
+
+ profileViewer.getManager().apiUtils
+ .newHypixelApiRequest("skyblock/profiles")
+ .queryArgument("uuid", uuid)
+ .requestJson()
+ .handle((profilesJson, throwable) -> {
+ if (profilesJson != null && profilesJson.has("success")
+ && profilesJson.get("success").getAsBoolean() && profilesJson.has("profiles")) {
+ Map<String, SkyblockProfile> nameToProfile = new HashMap<>();
+ String latestProfileName = null;
+ List<String> profileNames = new ArrayList<>();
+
+ // player has no skyblock profiles
+ if (profilesJson.get("profiles").isJsonNull()) {
+ updatingSkyblockProfilesState.set(false);
+ this.nameToProfile = new HashMap<>();
+ return null;
+ }
+
+ for (JsonElement profileEle : profilesJson.getAsJsonArray("profiles")) {
+ JsonObject profile = profileEle.getAsJsonObject();
+
+ if (!profile.has("members")) {
+ continue;
+ }
+
+ JsonObject members = profile.getAsJsonObject("members");
+ if (members.has(uuid)) {
+ JsonObject member = members.getAsJsonObject(uuid);
+ if (member.has("coop_invitation")) {
+ if (!member.getAsJsonObject("coop_invitation").get("confirmed").getAsBoolean()) {
+ continue;
+ }
+ }
+
+ String profileName = profile.get("cute_name").getAsString();
+ if (profile.has("selected") && profile.get("selected").getAsBoolean()) {
+ latestProfileName = profileName;
+ }
+ nameToProfile.put(profileName, new SkyblockProfile(profile));
+ profileNames.add(profileName);
+ }
+ }
+
+ this.nameToProfile = nameToProfile;
+ this.profilesArray = profilesJson.getAsJsonArray("profiles");
+ this.latestProfileName = latestProfileName;
+ this.profileNames.addAll(profileNames);
+ updatingSkyblockProfilesState.set(false);
+
+ if (runnable != null) {
+ runnable.run();
+ }
+ }
+ return null;
+ });
+
+ return null;
+ }
+
+ public JsonObject getOrLoadGuildInformation(Runnable runnable) {
+ if (guildInformation != null) {
+ return guildInformation;
+ }
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastGuildInfoState < 15 * 1000 && updatingGuildInfoState.get()) {
+ return null;
+ }
+ lastGuildInfoState = currentTime;
+ updatingGuildInfoState.set(true);
+
+ profileViewer.getManager().apiUtils
+ .newHypixelApiRequest("guild")
+ .queryArgument("player", uuid)
+ .requestJson()
+ .handle((jsonObject, ex) -> {
+ updatingGuildInfoState.set(false);
+
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ if (!jsonObject.has("guild")) {
+ return null;
+ }
+
+ guildInformation = jsonObject.getAsJsonObject("guild");
+
+ if (runnable != null) {
+ runnable.run();
+ }
+ }
+ return null;
+ });
+
+ return null;
+ }
+
+ public List<String> getProfileNames() {
+ return profileNames;
+ }
+
+ public void resetCache() {
+ profilesArray = null;
+ profileNames = new ArrayList<>();
+ guildInformation = null;
+ playerStatus = null;
+ nameToProfile = null;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public @Nullable JsonObject getHypixelProfile() {
+ return profileViewer.getUuidToHypixelProfile().getOrDefault(uuid, null);
+ }
+
+ public static class SoopyNetworth {
+ private final Map<String, Long> categoryToTotal = new LinkedHashMap<>();
+ private long networth;
+
+ private SoopyNetworth(JsonObject nwData) {
+ if (nwData == null || nwData.isJsonNull() || nwData.get("total").isJsonNull()) {
+ networth = -2;
+ return;
+ }
+
+ networth = nwData.get("total").getAsLong();
+ Map<String, Long> categoryToTotal = new HashMap<>();
+ for (Map.Entry<String, JsonElement> entry : nwData.get("categories").getAsJsonObject().entrySet()) {
+ if (!entry.getValue().isJsonNull()) {
+ categoryToTotal.put(entry.getKey(), entry.getValue().getAsLong());
+ }
+ }
+
+ // Sort based on category value
+ categoryToTotal.entrySet().stream()
+ .sorted(Comparator.comparingLong(e -> -e.getValue()))
+ .forEachOrdered(e -> this.categoryToTotal.put(e.getKey(), e.getValue()));
+ }
+
+ private SoopyNetworth asLoading() {
+ networth = -1;
+ return this;
+ }
+
+ /**
+ * @return -2 = error, -1 = loading, >= 0 = success
+ */
+ public long getNetworth() {
+ return networth;
+ }
+
+ public Map<String, Long> getCategoryToTotal() {
+ return categoryToTotal;
+ }
+ }
+
+ public class SkyblockProfile {
+
+ private final JsonObject outerProfileJson;
+ private final String gamemode;
+ private Integer magicPower = null;
+ private Double skyblockLevel = null;
+ private EnumChatFormatting skyBlockExperienceColour = null;
+ private Map<String, JsonArray> inventoryNameToInfo = null;
+ private Map<String, ProfileViewer.Level> levelingInfo = null;
+ private JsonObject petsInfo = null;
+ private ProfileCollectionInfo collectionsInfo = null;
+ private PlayerStats.Stats stats;
+ private Long networth = null;
+ private SoopyNetworth soopyNetworth = null;
+
+ public SkyblockProfile(JsonObject outerProfileJson) {
+ this.outerProfileJson = outerProfileJson;
+ this.gamemode = Utils.getElementAsString(outerProfileJson.get("game_mode"), null);
+ }
+
+ public JsonObject getOuterProfileJson() {
+ return outerProfileJson;
+ }
+
+ /**
+ * @return Profile json with UUID of {@link SkyblockProfiles#uuid}
+ */
+ public JsonObject getProfileJson() {
+ return Utils.getElement(outerProfileJson, "members." + SkyblockProfiles.this.uuid).getAsJsonObject();
+ }
+
+ public @Nullable String getGamemode() {
+ return gamemode;
+ }
+
+ /**
+ * Calculates the amount of Magical Power the player has using the list of accessories
+ *
+ * @return the amount of Magical Power or -1
+ */
+ public int getMagicalPower() {
+ if (magicPower != null) {
+ return magicPower;
+ }
+
+ Map<String, JsonArray> inventoryInfo = getInventoryInfo();
+ if (!inventoryInfo.containsKey("talisman_bag")) {
+ return -1;
+ }
+
+ return magicPower = ProfileViewerUtils.getMagicalPower(inventoryInfo.get("talisman_bag"), getProfileJson());
+ }
+
+ public Map<String, JsonArray> getInventoryInfo() {
+ if (inventoryNameToInfo != null) {
+ return inventoryNameToInfo;
+ }
+
+ JsonObject profileJson = getProfileJson();
+ inventoryNameToInfo = new HashMap<>();
+
+ for (String invName : inventoryNames) {
+ JsonArray contents = new JsonArray();
+
+ if (invName.equals("backpack_contents")) {
+ JsonObject backpackData = getBackpackData(Utils.getElement(profileJson, "backpack_contents"));
+ inventoryNameToInfo.put("backpack_sizes", backpackData.getAsJsonArray("backpack_sizes"));
+ contents = backpackData.getAsJsonArray("contents");
+ } else {
+ String contentBytes = Utils.getElementAsString(
+ Utils.getElement(profileJson, invName + ".data"),
+ defaultNbtData
+ );
+
+ try {
+ NBTTagList items = CompressedStreamTools.readCompressed(
+ new ByteArrayInputStream(Base64.getDecoder().decode(contentBytes))
+ ).getTagList("i", 10);
+ for (int j = 0; j < items.tagCount(); j++) {
+ JsonObject item = profileViewer.getManager().getJsonFromNBTEntry(items.getCompoundTagAt(j));
+ contents.add(item);
+ }
+ } catch (IOException ignored) {
+ }
+ }
+
+ inventoryNameToInfo.put(invName, contents);
+ }
+
+ return inventoryNameToInfo;
+ }
+
+ private JsonObject getBackpackData(JsonElement backpackContentsJson) {
+ // JsonArray of JsonObjects
+ JsonArray contents = new JsonArray();
+ JsonArray backpackSizes = new JsonArray();
+
+ JsonObject bundledReturn = new JsonObject();
+ bundledReturn.add("contents", contents);
+ bundledReturn.add("backpack_sizes", backpackSizes);
+
+ if (backpackContentsJson == null || !backpackContentsJson.isJsonObject()) {
+ return bundledReturn;
+ }
+
+ for (Map.Entry<String, JsonElement> backpack : backpackContentsJson.getAsJsonObject().entrySet()) {
+ if (backpack.getValue().isJsonObject()) {
+ try {
+ String bytes = Utils.getElementAsString(backpack.getValue().getAsJsonObject().get("data"), defaultNbtData);
+ NBTTagList items = CompressedStreamTools.readCompressed(
+ new ByteArrayInputStream(Base64.getDecoder().decode(bytes))
+ ).getTagList("i", 10);
+
+ backpackSizes.add(new JsonPrimitive(items.tagCount()));
+ for (int j = 0; j < items.tagCount(); j++) {
+ contents.add(profileViewer.getManager().getJsonFromNBTEntry(items.getCompoundTagAt(j)));
+ }
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ return bundledReturn;
+ }
+
+ public EnumChatFormatting getSkyblockLevelColour() {
+ if (Constants.SBLEVELS == null || !Constants.SBLEVELS.has("sblevel_colours")) {
+ Utils.showOutdatedRepoNotification();
+ return EnumChatFormatting.WHITE;
+ }
+
+ if (skyBlockExperienceColour != null) {
+ return skyBlockExperienceColour;
+ }
+
+ double skyblockLevel = getSkyblockLevel();
+ EnumChatFormatting levelColour = EnumChatFormatting.WHITE;
+
+ JsonObject sblevelColours = Constants.SBLEVELS.getAsJsonObject("sblevel_colours");
+ try {
+ for (Map.Entry<String, JsonElement> stringJsonElementEntry : sblevelColours.entrySet()) {
+ int nextLevelBracket = Integer.parseInt(stringJsonElementEntry.getKey());
+ EnumChatFormatting valueByName = EnumChatFormatting.getValueByName(stringJsonElementEntry
+ .getValue()
+ .getAsString());
+ if (skyblockLevel >= nextLevelBracket) {
+ levelColour = valueByName;
+ }
+ }
+ } catch (RuntimeException ignored) {
+ // catch both numberformat and getValueByName being wrong
+ }
+
+ return skyBlockExperienceColour = levelColour;
+ }
+
+ public double getSkyblockLevel() {
+ if (skyblockLevel != null) {
+ return skyblockLevel;
+ }
+
+ int element = Utils.getElementAsInt(Utils.getElement(getProfileJson(), "leveling.experience"), 0);
+ return skyblockLevel = (element / 100.0);
+ }
+
+ public boolean skillsApiEnabled() {
+ return getProfileJson().has("experience_skill_combat");
+ }
+
+ /**
+ * NOTE: will NOT return null if skills api is disabled, use {@link SkyblockProfile#skillsApiEnabled()} instead
+ * This can still return null if the leveling constant is not up-to-date
+ * @return Map containing skills, slayers, HOTM, dungeons & dungeon classes
+ */
+ public Map<String, ProfileViewer.Level> getLevelingInfo() {
+ if (levelingInfo != null) {
+ return levelingInfo;
+ }
+
+ JsonObject leveling = Constants.LEVELING;
+ if (leveling == null || !leveling.has("social")) {
+ Utils.showOutdatedRepoNotification();
+ return null;
+ }
+
+ JsonObject profileJson = getProfileJson();
+ Map<String, ProfileViewer.Level> out = new HashMap<>();
+
+ for (String skillName : skills) {
+ float skillExperience = 0;
+ if (skillName.equals("social")) {
+ // Get the coop's social skill experience since social is a shared skill
+ for (Map.Entry<String, JsonElement> memberProfileJson : outerProfileJson.entrySet()) {
+ skillExperience += Utils.getElementAsFloat(
+ Utils.getElement(memberProfileJson.getValue(), "experience_skill_social2"),
+ 0
+ );
+ }
+ } else {
+ skillExperience += Utils.getElementAsFloat(
+ Utils.getElement(profileJson, "experience_skill_" + skillName),
+ 0
+ );
+ }
+
+ JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray();
+ if (skillName.equals("runecrafting")) {
+ levelingArray = Utils.getElement(leveling, "runecrafting_xp").getAsJsonArray();
+ } else if (skillName.equals("social")) {
+ levelingArray = Utils.getElement(leveling, "social").getAsJsonArray();
+ }
+
+ int maxLevel = ProfileViewerUtils.getLevelingCap(leveling, skillName);
+ if (skillName.equals("farming")) {
+ maxLevel += Utils.getElementAsInt(Utils.getElement(profileJson, "jacob2.perks.farming_level_cap"), 0);
+ }
+
+ out.put(skillName, ProfileViewerUtils.getLevel(levelingArray, skillExperience, maxLevel, false));
+ }
+
+ out.put(
+ "hotm",
+ ProfileViewerUtils.getLevel(
+ Utils.getElement(leveling, "HOTM").getAsJsonArray(),
+ Utils.getElementAsFloat(Utils.getElement(profileJson, "mining_core.experience"), 0),
+ ProfileViewerUtils.getLevelingCap(leveling, "HOTM"),
+ false
+ )
+ );
+
+ out.put(
+ "catacombs",
+ ProfileViewerUtils.getLevel(
+ Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ Utils.getElementAsFloat(Utils.getElement(profileJson, "dungeons.dungeon_types.catacombs.experience"), 0),
+ ProfileViewerUtils.getLevelingCap(leveling, "catacombs"),
+ false
+ )
+ );
+ out.put(
+ "cosmetic_catacombs",
+ ProfileViewerUtils.getLevel(
+ Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ Utils.getElementAsFloat(Utils.getElement(profileJson, "dungeons.dungeon_types.catacombs.experience"), 0),
+ 99,
+ false
+ )
+ );
+
+ for (String className : Weight.DUNGEON_CLASS_NAMES) {
+ float classExperience = Utils.getElementAsFloat(
+ Utils.getElement(profileJson, "dungeons.player_classes." + className + ".experience"),
+ 0
+ );
+ out.put(
+ className,
+ ProfileViewerUtils.getLevel(
+ Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ classExperience,
+ ProfileViewerUtils.getLevelingCap(leveling, "catacombs"),
+ false
+ )
+ );
+ out.put(
+ "cosmetic_" + className,
+ ProfileViewerUtils.getLevel(
+ Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ classExperience,
+ 99,
+ false
+ )
+ );
+ }
+
+ for (String slayerName : Weight.SLAYER_NAMES) {
+ float slayerExperience = Utils.getElementAsFloat(Utils.getElement(
+ profileJson,
+ "slayer_bosses." + slayerName + ".xp"
+ ), 0);
+ out.put(
+ slayerName,
+ ProfileViewerUtils.getLevel(
+ Utils.getElement(leveling, "slayer_xp." + slayerName).getAsJsonArray(),
+ slayerExperience,
+ 9,
+ true
+ )
+ );
+ }
+
+ return levelingInfo = out;
+ }
+
+ public int getBestiaryLevel() {
+ int beLevel = 0;
+ for (ItemStack items : BestiaryData.getBestiaryLocations().keySet()) {
+ List<String> mobs = BestiaryData.getBestiaryLocations().get(items);
+ if (mobs != null) {
+ for (String mob : mobs) {
+ if (mob != null) {
+ float kills = Utils.getElementAsFloat(Utils.getElement(getProfileJson(), "bestiary.kills_" + mob), 0);
+ String type;
+ if (BestiaryData.getMobType().get(mob) != null) {
+ type = BestiaryData.getMobType().get(mob);
+ } else {
+ type = "MOB";
+ }
+ JsonObject leveling = Constants.LEVELING;
+ ProfileViewer.Level level = null;
+ if (leveling != null && Utils.getElement(leveling, "bestiary." + type) != null) {
+ JsonArray levelingArray = Utils.getElement(leveling, "bestiary." + type).getAsJsonArray();
+ int levelCap = Utils.getElementAsInt(Utils.getElement(leveling, "bestiary.caps." + type), 0);
+ level = ProfileViewerUtils.getLevel(levelingArray, kills, levelCap, false);
+ }
+
+ float levelNum = 0;
+ if (level != null) {
+ levelNum = level.level;
+ }
+ beLevel += (int) Math.floor(levelNum);
+ }
+ }
+ }
+ }
+ return beLevel;
+ }
+
+ public JsonObject getPetsInfo() {
+ if (petsInfo != null) {
+ return petsInfo;
+ }
+
+ JsonElement petsEle = getProfileJson().get("pets");
+ if (petsEle != null && petsEle.isJsonArray()) {
+ JsonArray petsArr = petsEle.getAsJsonArray();
+ JsonObject activePet = null;
+
+ for (JsonElement petEle : petsEle.getAsJsonArray()) {
+ JsonObject petObj = petEle.getAsJsonObject();
+ if (petObj.has("active") && petObj.get("active").getAsBoolean()) {
+ activePet = petObj;
+ break;
+ }
+ }
+
+ // TODO: STOP DOING THIS AAAAA
+ petsInfo = new JsonObject();
+ petsInfo.add("active_pet", activePet);
+ petsInfo.add("pets", petsArr);
+ return petsInfo;
+ }
+
+ return null;
+ }
+
+ public ProfileCollectionInfo getCollectionInfo() {
+ if (collectionsInfo != null) {
+ return collectionsInfo;
+ }
+
+ // TODO: Is this supposed to be async?
+ return collectionsInfo = ProfileCollectionInfo.getCollectionData(outerProfileJson, uuid).getNow(null);
+ }
+
+ public PlayerStats.Stats getStats() {
+ if (stats != null) {
+ return stats;
+ }
+
+ if (skillsApiEnabled()) {
+ return null;
+ }
+
+ return stats = PlayerStats.getStats(
+ getLevelingInfo(),
+ getInventoryInfo(),
+ getPetsInfo(),
+ getProfileJson()
+ );
+ }
+
+ public long getNetworth() {
+ if (networth != null) {
+ return networth;
+ }
+
+ Map<String, JsonArray> inventoryInfo = getInventoryInfo();
+ JsonObject profileInfo = getProfileJson();
+
+ HashMap<String, Long> mostExpensiveInternal = new HashMap<>();
+
+ long networth = 0;
+ for (Map.Entry<String, JsonArray> entry : inventoryInfo.entrySet()) {
+ for (JsonElement element : entry.getValue()) {
+ if (element != null && element.isJsonObject()) {
+ JsonObject item = element.getAsJsonObject();
+ String internalName = item.get("internalname").getAsString();
+
+ if (profileViewer.getManager().auctionManager.isVanillaItem(internalName)) {
+ continue;
+ }
+
+ JsonObject bzInfo = profileViewer.getManager().auctionManager.getBazaarInfo(internalName);
+
+ long auctionPrice;
+ if (bzInfo != null && bzInfo.has("curr_sell")) {
+ auctionPrice = (int) bzInfo.get("curr_sell").getAsFloat();
+ } else {
+ auctionPrice = (long) profileViewer.getManager().auctionManager.getItemAvgBin(internalName);
+ if (auctionPrice <= 0) {
+ auctionPrice = profileViewer.getManager().auctionManager.getLowestBin(internalName);
+ }
+ }
+
+ // Backpack, cake bag, etc
+ try {
+ if (item.has("item_contents")) {
+ JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
+ byte[] bytes = new byte[bytesArr.size()];
+ for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) {
+ bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte();
+ }
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for (int j = 0; j < items.tagCount(); j++) {
+ if (items.getCompoundTagAt(j).getKeySet().size() > 0) {
+ NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
+ String internalname2 =
+ profileViewer.getManager().createItemResolutionQuery().withItemNBT(nbt).resolveInternalName();
+ if (internalname2 != null) {
+ if (profileViewer.getManager().auctionManager.isVanillaItem(internalname2)) continue;
+
+ JsonObject bzInfo2 = profileViewer.getManager().auctionManager.getBazaarInfo(internalname2);
+
+ long auctionPrice2;
+ if (bzInfo2 != null && bzInfo2.has("curr_sell")) {
+ auctionPrice2 = (int) bzInfo2.get("curr_sell").getAsFloat();
+ } else {
+ auctionPrice2 = (long) profileViewer.getManager().auctionManager.getItemAvgBin(internalname2);
+ if (auctionPrice2 <= 0) {
+ auctionPrice2 = profileViewer.getManager().auctionManager.getLowestBin(internalname2);
+ }
+ }
+
+ int count2 = items.getCompoundTagAt(j).getByte("Count");
+
+ mostExpensiveInternal.put(
+ internalname2,
+ auctionPrice2 * count2 + mostExpensiveInternal.getOrDefault(internalname2, 0L)
+ );
+ networth += auctionPrice2 * count2;
+ }
+ }
+ }
+ }
+ } catch (IOException ignored) {
+ }
+
+ int count = 1;
+ if (element.getAsJsonObject().has("count")) {
+ count = element.getAsJsonObject().get("count").getAsInt();
+ }
+ mostExpensiveInternal.put(
+ internalName,
+ auctionPrice * count + mostExpensiveInternal.getOrDefault(internalName, 0L)
+ );
+ networth += auctionPrice * count;
+ }
+ }
+ }
+ if (networth == 0) return -1;
+
+ networth = (int) (networth * 1.3f);
+
+ JsonObject petsInfo = getPetsInfo();
+ if (petsInfo != null && petsInfo.has("pets")) {
+ if (petsInfo.get("pets").isJsonArray()) {
+ JsonArray pets = petsInfo.get("pets").getAsJsonArray();
+ for (JsonElement element : pets) {
+ if (element.isJsonObject()) {
+ JsonObject pet = element.getAsJsonObject();
+
+ String petname = pet.get("type").getAsString();
+ String tier = pet.get("tier").getAsString();
+ String tierNum = GuiProfileViewer.RARITY_TO_NUM.get(tier);
+ if (tierNum != null) {
+ String internalname2 = petname + ";" + tierNum;
+ JsonObject info2 = profileViewer.getManager().auctionManager.getItemAuctionInfo(internalname2);
+ if (info2 == null || !info2.has("price") || !info2.has("count")) continue;
+ int auctionPrice2 = (int) (info2.get("price").getAsFloat() / info2.get("count").getAsFloat());
+
+ networth += auctionPrice2;
+ }
+ }
+ }
+ }
+ }
+
+ float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
+ float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
+ networth += bankBalance + purseBalance;
+
+ return this.networth = networth;
+ }
+
+ public SoopyNetworth getSoopyNetworth(Runnable callback) {
+ if (soopyNetworth != null) {
+ return soopyNetworth;
+ }
+
+ loadSoopyData(callback);
+ return new SoopyNetworth(null).asLoading();
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java
index 81b99948..17cd6787 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java
@@ -25,6 +25,8 @@ import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewerPage;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewerUtils;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -37,16 +39,14 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.awt.*;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
-import java.util.Locale;
+
+import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_elements;
public class BestiaryPage extends GuiProfileViewerPage {
- public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
private static final ResourceLocation BESTIARY_TEXTURE = new ResourceLocation("notenoughupdates:pv_bestiary_tab.png");
- private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
private static final int XCOUNT = 7;
private static final int YCOUNT = 5;
private static final float XPADDING = (190 - XCOUNT * 20) / (float) (XCOUNT + 1);
@@ -62,7 +62,13 @@ public class BestiaryPage extends GuiProfileViewerPage {
public void drawPage(int mouseX, int mouseY, float partialTicks) {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
- JsonObject profileInfo = GuiProfileViewer.getProfile().getProfileInformation(GuiProfileViewer.getProfileId());
+
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ JsonObject profileInfo = selectedProfile.getProfileJson();
int bestiarySize = BestiaryData.getBestiaryLocations().size();
int bestiaryXSize = (int) (350f / (bestiarySize - 1 + 0.0000001f));
@@ -117,7 +123,7 @@ public class BestiaryPage extends GuiProfileViewerPage {
Color color = new Color(128, 128, 128, 255);
Utils.renderAlignedString(
EnumChatFormatting.RED + "Bestiary Level: ",
- EnumChatFormatting.GRAY + "" + (float) GuiProfileViewer.getProfile().getBestiaryTiers(profileInfo) / 10,
+ EnumChatFormatting.GRAY + "" + (float) getSelectedProfile().getBestiaryLevel() / 10,
guiLeft + 220,
guiTop + 50,
110
@@ -181,7 +187,7 @@ public class BestiaryPage extends GuiProfileViewerPage {
if (leveling != null && Utils.getElement(leveling, "bestiary." + type) != null) {
JsonArray levelingArray = Utils.getElement(leveling, "bestiary." + type).getAsJsonArray();
int levelCap = Utils.getElementAsInt(Utils.getElement(leveling, "bestiary.caps." + type), 0);
- level = ProfileViewer.getLevel(levelingArray, kills, levelCap, false);
+ level = ProfileViewerUtils.getLevel(levelingArray, kills, levelCap, false);
} else {
Utils.showOutdatedRepoNotification();
}
@@ -197,10 +203,10 @@ public class BestiaryPage extends GuiProfileViewerPage {
mobItem.getDisplayName() + " " + ((levelNum == -1) ? "?" : (int) Math.floor(levelNum))
);
tooltipToDisplay.add(
- EnumChatFormatting.GRAY + "Kills: " + EnumChatFormatting.GREEN + numberFormat.format(kills)
+ EnumChatFormatting.GRAY + "Kills: " + EnumChatFormatting.GREEN + StringUtils.formatNumber(kills)
);
tooltipToDisplay.add(
- EnumChatFormatting.GRAY + "Deaths: " + EnumChatFormatting.GREEN + numberFormat.format(deaths)
+ EnumChatFormatting.GRAY + "Deaths: " + EnumChatFormatting.GREEN + StringUtils.formatNumber(deaths)
);
if (level != null) {
String progressStr;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java
index 770b295a..6ce60674 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java
@@ -20,13 +20,16 @@
package io.github.moulberry.notenoughupdates.profileviewer.level;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.BasicPage;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
-import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewerPage;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.CoreTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.DungeonTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.EssenceTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.EventTaskLevel;
+import io.github.moulberry.notenoughupdates.profileviewer.level.task.GuiTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.MiscTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.SkillRelatedTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.SlayingTaskLevel;
@@ -40,52 +43,35 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
-import java.text.NumberFormat;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class LevelPage {
+public class LevelPage extends GuiProfileViewerPage {
- private final GuiProfileViewer instance;
+ private static final ResourceLocation pv_levels = new ResourceLocation("notenoughupdates:pv_levels.png");
private final BasicPage basicPage;
- private ProfileViewer.Profile profile;
-
- private String profileId;
-
private final JsonObject constant;
-
- private final CoreTaskLevel coreTaskLevel;
- private final DungeonTaskLevel dungeonTaskLevel;
- private final EssenceTaskLevel essenceTaskLevel;
- private final MiscTaskLevel miscTaskLevel;
- private final SkillRelatedTaskLevel skillRelatedTaskLevel;
- private final SlayingTaskLevel slayingTaskLevel;
- private final StoryTaskLevel storyTaskLevel;
-
- private final EventTaskLevel eventTaskLevel;
-
- private static final ResourceLocation pv_levels = new ResourceLocation("notenoughupdates:pv_levels.png");
+ private final List<GuiTaskLevel> tasks = new ArrayList<>();
public LevelPage(GuiProfileViewer instance, BasicPage basicPage) {
- this.instance = instance;
+ super(instance);
this.basicPage = basicPage;
constant = Constants.SBLEVELS;
- coreTaskLevel = new CoreTaskLevel(this);
- dungeonTaskLevel = new DungeonTaskLevel(this);
- essenceTaskLevel = new EssenceTaskLevel(this);
- miscTaskLevel = new MiscTaskLevel(this);
- skillRelatedTaskLevel = new SkillRelatedTaskLevel(this);
- slayingTaskLevel = new SlayingTaskLevel(this);
- storyTaskLevel = new StoryTaskLevel(this);
- eventTaskLevel = new EventTaskLevel(this);
+ tasks.add(new CoreTaskLevel(this));
+ tasks.add(new DungeonTaskLevel(this));
+ tasks.add(new EssenceTaskLevel(this));
+ tasks.add(new MiscTaskLevel(this));
+ tasks.add(new SkillRelatedTaskLevel(this));
+ tasks.add(new SlayingTaskLevel(this));
+ tasks.add(new StoryTaskLevel(this));
+ tasks.add(new EventTaskLevel(this));
}
- public void drawPage(int mouseX, int mouseY) {
+ public void drawPage(int mouseX, int mouseY, float partialTicks) {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
- this.profile = GuiProfileViewer.getProfile();
- this.profileId = GuiProfileViewer.getProfileId();
basicPage.drawSideButtons();
@@ -95,20 +81,18 @@ public class LevelPage {
}
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_levels);
- Utils.drawTexturedRect(guiLeft, guiTop, instance.sizeX, instance.sizeY, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
+
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
- double skyblockLevel = profile.getSkyblockLevel(profileId);
- JsonObject profileInfo = profile.getProfileInformation(profileId);
+ double skyblockLevel = selectedProfile.getSkyblockLevel();
+ JsonObject profileInfo = selectedProfile.getProfileJson();
drawMainBar(skyblockLevel, mouseX, mouseY, guiLeft, guiTop);
- dungeonTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- essenceTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- miscTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- skillRelatedTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- slayingTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- storyTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- eventTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
- coreTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop);
+ tasks.forEach(task -> task.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop));
}
public void renderLevelBar(
@@ -149,9 +133,8 @@ public class LevelPage {
String levelStr;
if (mouseX > x && mouseX < x + 120) {
if (mouseY > y - 4 && mouseY < y + 13) {
- NumberFormat numberFormat = NumberFormat.getInstance();
- String xpFormatted = numberFormat.format((int) xp);
- String maxFormatted = numberFormat.format((int) max);
+ String xpFormatted = StringUtils.formatNumber((int) xp);
+ String maxFormatted = StringUtils.formatNumber((int) max);
levelStr =
EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.DARK_PURPLE + (int) (experienceRequired * 100) +
@@ -192,8 +175,8 @@ public class LevelPage {
}
public String buildLore(String name, double xpGotten, double xpGainful, boolean hasNoLimit) {
- String xpGottenFormatted = NumberFormat.getInstance().format((int) xpGotten);
- String xpGainfulFormatted = NumberFormat.getInstance().format((int) xpGainful);
+ String xpGottenFormatted = StringUtils.formatNumber((int) xpGotten);
+ String xpGainfulFormatted = StringUtils.formatNumber((int) xpGainful);
if (xpGainful == 0 && xpGotten == 0 && !hasNoLimit) {
return EnumChatFormatting.GOLD + name + ": §c§lNOT DETECTABLE!";
@@ -217,16 +200,4 @@ public class LevelPage {
public JsonObject getConstant() {
return constant;
}
-
- public ProfileViewer.Profile getProfile() {
- return profile;
- }
-
- public String getProfileId() {
- return profileId;
- }
-
- public GuiProfileViewer getInstance() {
- return instance;
- }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java
index 8eb577d2..de79c0b5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java
@@ -22,7 +22,9 @@ package io.github.moulberry.notenoughupdates.profileviewer.level.task;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo;
@@ -34,11 +36,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
-public class CoreTaskLevel {
+public class CoreTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
-
- public CoreTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public CoreTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
private final List<String> skills = Arrays.asList(
"taming",
@@ -52,13 +54,18 @@ public class CoreTaskLevel {
"alchemy"
);
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
JsonObject coreTask = levelPage.getConstant().get("core_task").getAsJsonObject();
- // skills
- Map<String, ProfileViewer.Level> skyblockInfo = levelPage.getProfile().getSkyblockInfo(levelPage.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = GuiProfileViewer.getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ Map<String, ProfileViewer.Level> skyblockInfo = selectedProfile.getLevelingInfo();
int sbXpGainedSkillLVL = 0;
- if (skyblockInfo != null) {
+ if (skyblockInfo != null && selectedProfile.skillsApiEnabled()) {
for (String skill : skills) {
ProfileViewer.Level level = skyblockInfo.get(skill);
for (int i = 1; i <= level.level; i++) {
@@ -108,9 +115,7 @@ public class CoreTaskLevel {
JsonObject minionXp = Constants.MISC.get("minionXp").getAsJsonObject();
int collectionsXp = coreTask.get("collections_xp").getAsInt();
ProfileCollectionInfo collection;
- collection = levelPage.getProfile().getCollectionInfo(
- levelPage.getProfileId()
- );
+ collection = GuiProfileViewer.getSelectedProfile().getCollectionInfo();
if (collection != null) {
sbXpCollection = 0;
for (Map.Entry<String, ProfileCollectionInfo.CollectionInfo> stringCollectionInfoEntry : collection
@@ -122,7 +127,7 @@ public class CoreTaskLevel {
for (int tier : collection.getCraftedGenerators().values()) {
for (int i = 1; i <= tier; i++) {
- if (minionXp.has(i + "")) sbXpMinionTier += minionXp.get(i + "").getAsInt();
+ if (minionXp.has(String.valueOf(i))) sbXpMinionTier += minionXp.get(String.valueOf(i)).getAsInt();
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java
index 6900cdf3..dfbfb834 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java
@@ -23,26 +23,31 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
import io.github.moulberry.notenoughupdates.util.Utils;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
-public class DungeonTaskLevel {
+public class DungeonTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
-
- public DungeonTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public DungeonTaskLevel(LevelPage levelPage) {super(levelPage);}
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
JsonObject dungeonTask = levelPage.getConstant().get("dungeon_task").getAsJsonObject();
- Map<String, ProfileViewer.Level> skyblockInfo =
- levelPage.getProfile().getSkyblockInfo(levelPage.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = GuiProfileViewer.getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ Map<String, ProfileViewer.Level> skyblockInfo = selectedProfile.getLevelingInfo();
int sbLevelGainedFloor = 0;
int sbXpGainedClass = 0;
@@ -60,8 +65,7 @@ public class DungeonTaskLevel {
}
}
- List<String> dungeonClasses = Arrays.asList("healer", "tank", "mage", "archer", "berserk");
- for (String dungeonClass : dungeonClasses) {
+ for (String dungeonClass : Weight.DUNGEON_CLASS_NAMES) {
ProfileViewer.Level level = skyblockInfo.get(dungeonClass);
for (int i = 1; i <= level.level; i++) {
if (i <= 50) sbXpGainedClass += dungeonTask.get("class_xp").getAsInt();
@@ -72,11 +76,10 @@ public class DungeonTaskLevel {
int index = 0;
for (JsonElement completeCatacomb : completeCatacombs) {
int value = completeCatacomb.getAsInt();
- JsonObject normalCompletions = Utils
- .getElement(object, "dungeons.dungeon_types.catacombs.tier_completions")
- .getAsJsonObject();
- if (normalCompletions.has(index + "")) {
- sbLevelGainedFloor = sbLevelGainedFloor + value;
+ JsonElement normalCompletions = Utils
+ .getElementOrDefault(object, "dungeons.dungeon_types.catacombs.tier_completions", null);
+ if (normalCompletions != null && normalCompletions.getAsJsonObject().has("" + index)) {
+ sbLevelGainedFloor += value;
}
index++;
}
@@ -86,8 +89,8 @@ public class DungeonTaskLevel {
JsonElement masterCompletions = Utils
.getElementOrDefault(object, "dungeons.dungeon_types.master_catacombs.tier_completions", null);
if (masterCompletions != null) {
- if (masterCompletions.getAsJsonObject().has(i + "")) {
- sbLevelGainedFloor = sbLevelGainedFloor + masterCatacombs;
+ if (masterCompletions.getAsJsonObject().has("" + i)) {
+ sbLevelGainedFloor += masterCatacombs;
}
}
}
@@ -105,8 +108,6 @@ public class DungeonTaskLevel {
lore.add(levelPage.buildLore("Class Level Up", sbXpGainedClass, classLevelUp, false));
lore.add(levelPage.buildLore("Complete Dungeons", sbLevelGainedFloor, completeDungeon, false));
- int totalSbXpGain = sbXpGainedLvl + sbXpGainedClass + sbLevelGainedFloor;
-
levelPage.renderLevelBar(
"Dungeon Task",
NotEnoughUpdates.INSTANCE.manager
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java
index c6df6fc1..105c7056 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java
@@ -33,12 +33,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class EssenceTaskLevel {
+public class EssenceTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
-
- public EssenceTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public EssenceTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
List<String> lore = new ArrayList<>();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java
index a5dc994a..ee028683 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java
@@ -29,12 +29,13 @@ import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
-public class EventTaskLevel {
+public class EventTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
-
- public EventTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public EventTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
List<String> lore = new ArrayList<>();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/GuiTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/GuiTaskLevel.java
new file mode 100644
index 00000000..01002485
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/GuiTaskLevel.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.profileviewer.level.task;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
+
+public abstract class GuiTaskLevel {
+ public final LevelPage levelPage;
+ public GuiTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+
+ public abstract void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop);
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java
index f78052f5..3ce2a34d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java
@@ -23,6 +23,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.profileviewer.CrimsonIslePage;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.init.Items;
@@ -35,12 +37,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-public class MiscTaskLevel {
+public class MiscTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
-
- public MiscTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public MiscTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
JsonObject miscellaneousTask = levelPage.getConstant().getAsJsonObject("miscellaneous_task");
// I love doing this on god!!!
@@ -113,9 +116,14 @@ public class MiscTaskLevel {
}
}
+ SkyblockProfiles.SkyblockProfile selectedProfile = GuiProfileViewer.getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
// community upgrades
int sbXpCommunityUpgrade = 0;
- JsonObject profileInformation = levelPage.getProfile().getProfileInformation(levelPage.getProfileId());
+ JsonObject profileInformation = selectedProfile.getOuterProfileJson();
if (profileInformation != null && profileInformation.has("community_upgrades")) {
JsonObject communityUpgrades = profileInformation.getAsJsonObject("community_upgrades");
JsonArray upgradeStates = communityUpgrades.getAsJsonArray("upgrade_states");
@@ -191,8 +199,6 @@ public class MiscTaskLevel {
true,
lore
);
-
- totalXp += sbXpAccessoryUpgrade + sbXpUnlockedPowers;
}
private int getRankIndex(int pointsTotal) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java
index 176fc899..fd56aca1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java
@@ -22,9 +22,10 @@ package io.github.moulberry.notenoughupdates.profileviewer.level.task;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
-import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -33,29 +34,32 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-public class SkillRelatedTaskLevel {
+public class SkillRelatedTaskLevel extends GuiTaskLevel{
- private final LevelPage levelPage;
-
- public SkillRelatedTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public SkillRelatedTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
- JsonObject skillRelatedTask = levelPage.getConstant().get("skill_related_task").getAsJsonObject();
- JsonObject miningObj = skillRelatedTask.get("mining").getAsJsonObject();
-
- float hotmXp = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.experience"), 0);
- ProfileViewer.Level levelObjHotm =
- ProfileViewer.getLevel(
- Utils.getElementOrDefault(Constants.LEVELING, "HOTM", new JsonArray()).getAsJsonArray(),
- hotmXp,
- 7,
- false
- );
+ SkyblockProfiles.SkyblockProfile selectedProfile = GuiProfileViewer.getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ Map<String, ProfileViewer.Level> levelingInfo = selectedProfile.getLevelingInfo();
+ if (levelingInfo == null) {
+ return;
+ }
+
+ JsonObject skillRelatedTask = levelPage.getConstant().getAsJsonObject("skill_related_task");
+ JsonObject miningObj = skillRelatedTask.getAsJsonObject("mining");
+
+ int hotmLevel = (int) levelingInfo.get("hotm").level;
int hotmXP = 0;
- float level = levelObjHotm.level;
JsonArray hotmXpArray = miningObj.get("hotm_xp").getAsJsonArray();
- for (int i = 1; i <= level; i++) {
+ for (int i = 1; i <= hotmLevel; i++) {
hotmXP += hotmXpArray.get(i - 1).getAsInt();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java
index 6b624a52..a8301bb6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java
@@ -24,10 +24,12 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.profileviewer.CrimsonIslePage;
-import io.github.moulberry.notenoughupdates.profileviewer.ExtraPage;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage;
+import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.Weight;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -37,25 +39,31 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class SlayingTaskLevel {
+public class SlayingTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
private final int[] bossLow = {25, 50, 100, 150, 250, 1000};
private final int[] thorn = {25, 50, 150, 250, 400, 1000};
private final int[] bossHigh = {50, 100, 150, 250, 500, 750, 1000};
+ public SlayingTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
- public SlayingTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
-
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
// slayer
JsonObject slayingTask = levelPage.getConstant().get("slaying_task").getAsJsonObject();
JsonArray slayerLevelUpXp = slayingTask.get("slayer_level_up_xp").getAsJsonArray();
- Map<String, ProfileViewer.Level> skyblockInfo = levelPage.getProfile().getSkyblockInfo(levelPage.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = GuiProfileViewer.getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ Map<String, ProfileViewer.Level> skyblockInfo = selectedProfile.getLevelingInfo();
int sbXpGainedSlayer = 0;
if (skyblockInfo != null) {
- for (String slayer : ProfileViewer.SLAYERS) {
+ for (String slayer : Weight.SLAYER_NAMES) {
ProfileViewer.Level level = skyblockInfo.get(slayer);
for (int i = 0; i < (int) level.level; i++) {
int asInt = slayerLevelUpXp.get(i).getAsInt();
@@ -105,8 +113,8 @@ public class SlayingTaskLevel {
int bossCollectionXp = 0;
JsonArray dungeonCollectionXp = bossCollectionsXp.getAsJsonArray("dungeon_collection_xp");
for (int i = 1; i <= 7; i++) {
- if (!allComps.containsKey(i + "")) continue;
- double value = allComps.get(i + "");
+ if (!allComps.containsKey(String.valueOf(i))) continue;
+ double value = allComps.get(String.valueOf(i));
switch (i) {
case 1:
case 2:
@@ -154,7 +162,7 @@ public class SlayingTaskLevel {
}
int sbXpBestiary = 0;
- int bestiaryTiers = GuiProfileViewer.getProfile().getBestiaryTiers(object);
+ int bestiaryTiers = GuiProfileViewer.getSelectedProfile().getBestiaryLevel();
sbXpBestiary += bestiaryTiers;
sbXpBestiary = sbXpBestiary + (sbXpBestiary / 10) * 2;
@@ -184,12 +192,17 @@ public class SlayingTaskLevel {
int sbXpFromSlayerDefeat = 0;
JsonArray defeatSlayersXp = slayingTask.get("defeat_slayers_xp").getAsJsonArray();
- for (String s : ExtraPage.slayers.keySet()) {
- int maxLevel = ExtraPage.slayers.get(s);
+ JsonObject slayerToTier = Constants.LEVELING.getAsJsonObject("slayer_to_highest_tier");
+ if (slayerToTier == null) {
+ Utils.showOutdatedRepoNotification();
+ return;
+ }
+ for (Map.Entry<String, JsonElement> entry : slayerToTier.entrySet()) {
+ int maxLevel = entry.getValue().getAsInt();
for (int i = 0; i < 5; i++) {
if (i >= maxLevel) break;
float tier = Utils.getElementAsFloat(
- Utils.getElement(object, "slayer_bosses." + s + ".boss_kills_tier_" + i),
+ Utils.getElement(object, "slayer_bosses." + entry.getKey() + ".boss_kills_tier_" + i),
0
);
if (tier != 0) {
@@ -247,7 +260,6 @@ public class SlayingTaskLevel {
true,
lore
);
- totalXp += sbXpBestiary;
}
private int loopThroughCollection(int[] array, double value, JsonArray jsonArray) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java
index 3846db5f..1cda3e01 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java
@@ -29,12 +29,13 @@ import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
-public class StoryTaskLevel {
+public class StoryTaskLevel extends GuiTaskLevel {
- private final LevelPage levelPage;
-
- public StoryTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;}
+ public StoryTaskLevel(LevelPage levelPage) {
+ super(levelPage);
+ }
+ @Override
public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) {
JsonObject storyTask = levelPage.getConstant().getAsJsonObject("story_task");
JsonArray storyTaskNames = storyTask.getAsJsonArray("complete_objectives_names");
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java
index f4378926..9aaf65a4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java
@@ -23,11 +23,12 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewerPage;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.init.Items;
@@ -38,7 +39,6 @@ import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -46,9 +46,10 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_elements;
+
public class TrophyFishPage extends GuiProfileViewerPage {
- public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
private static final Map<String, EnumChatFormatting> internalTrophyFish = new HashMap<String, EnumChatFormatting>() {
{
put("gusher", EnumChatFormatting.WHITE);
@@ -122,7 +123,6 @@ public class TrophyFishPage extends GuiProfileViewerPage {
}
};
private static final ResourceLocation TROPHY_FISH_TEXTURE = new ResourceLocation("notenoughupdates:pv_trophy_fish_tab.png");
- private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);
private static final String checkX = "§c✖";
private static final String check = "§a✔";
private final Map<String, Integer> total = new HashMap<>();
@@ -141,19 +141,20 @@ public class TrophyFishPage extends GuiProfileViewerPage {
trophyFishList.clear();
- JsonObject profileInformation = GuiProfileViewer.getProfile().getProfileInformation(GuiProfileViewer.getProfileId());
+ SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
+ if (selectedProfile == null) {
+ return;
+ }
+
+ JsonObject profileInformation = selectedProfile.getProfileJson();
if (profileInformation == null || !profileInformation.has("trophy_fish")) {
Utils.drawStringCentered(EnumChatFormatting.RED + "No data found", guiLeft + 431 / 2f, guiTop + 101, true, 0);
return;
}
- JsonObject trophyObject = profileInformation.get("trophy_fish").getAsJsonObject();
+ JsonObject trophyObject = profileInformation.getAsJsonObject("trophy_fish");
loadTrophyInformation(trophyObject);
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
Minecraft.getMinecraft().getTextureManager().bindTexture(TROPHY_FISH_TEXTURE);
Utils.drawTexturedRect(guiLeft, guiTop, 431, 202, GL11.GL_NEAREST);
@@ -161,7 +162,7 @@ public class TrophyFishPage extends GuiProfileViewerPage {
GlStateManager.disableLighting();
RenderHelper.enableGUIStandardItemLighting();
- JsonObject stats = profileInformation.get("stats").getAsJsonObject();
+ JsonObject stats = profileInformation.getAsJsonObject("stats");
int thunderKills = 0;
if (stats.has("kills_thunder")) {
@@ -340,7 +341,7 @@ public class TrophyFishPage extends GuiProfileViewerPage {
if (trophyFishList.get(name) != null) {
tooltip.add(" ");
tooltip.add(EnumChatFormatting.GRAY + "Total: " + EnumChatFormatting.GOLD +
- NUMBER_FORMAT.format(trophyFishList.get(name).getTotal()));
+ StringUtils.formatNumber(trophyFishList.get(name).getTotal()));
}
return tooltip;
}
@@ -356,7 +357,7 @@ public class TrophyFishPage extends GuiProfileViewerPage {
}
if (trophyFishRarityIntegerMap.containsKey(rarity)) {
- return color + name + ": " + EnumChatFormatting.GOLD + NUMBER_FORMAT.format(trophyFishRarityIntegerMap.get(rarity));
+ return color + name + ": " + EnumChatFormatting.GOLD + StringUtils.formatNumber(trophyFishRarityIntegerMap.get(rarity));
} else {
return color + name + ": " + checkX;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/lily/LilySkillsWeight.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/lily/LilySkillsWeight.java
index f47032a4..6935606e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/lily/LilySkillsWeight.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/lily/LilySkillsWeight.java
@@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.profileviewer.weight.lily;
import com.google.gson.JsonArray;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewerUtils;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.SkillsWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.WeightStruct;
import io.github.moulberry.notenoughupdates.util.Constants;
@@ -41,7 +42,7 @@ public class LilySkillsWeight extends SkillsWeight {
double skillAverage = 0;
for (String skill : SKILL_NAMES) {
skillAverage +=
- (int) ProfileViewer.getLevel(
+ (int) ProfileViewerUtils.getLevel(
Utils.getElement(Constants.LEVELING, "leveling_xp").getAsJsonArray(),
player.get(skill).totalXp,
60,
@@ -52,7 +53,7 @@ public class LilySkillsWeight extends SkillsWeight {
skillAverage /= SKILL_NAMES.size();
float currentExp = player.get(skillName).totalXp;
- int currentLevel = (int) ProfileViewer.getLevel(
+ int currentLevel = (int) ProfileViewerUtils.getLevel(
Utils.getElement(Constants.LEVELING, "leveling_xp").getAsJsonArray(),
currentExp,
60,
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/senither/SenitherSkillsWeight.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/senither/SenitherSkillsWeight.java
index 7ac717f7..b97c3624 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/senither/SenitherSkillsWeight.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/senither/SenitherSkillsWeight.java
@@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.profileviewer.weight.senither;
import com.google.gson.JsonArray;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewerUtils;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.SkillsWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.WeightStruct;
import io.github.moulberry.notenoughupdates.util.Constants;
@@ -46,7 +47,7 @@ public class SenitherSkillsWeight extends SkillsWeight {
int maxLevel = skillName.equals("farming")
? 60
: Utils.getElementAsInt(Utils.getElement(Constants.LEVELING, "leveling_caps." + skillName), 50);
- double level = ProfileViewer.getLevel(
+ double level = ProfileViewerUtils.getLevel(
Utils.getElement(Constants.LEVELING, "leveling_xp").getAsJsonArray(),
currentSkillXp,
maxLevel,
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/Weight.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/Weight.java
index 129f53fc..83095e96 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/Weight.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/weight/weight/Weight.java
@@ -34,8 +34,8 @@ public abstract class Weight {
"fishing",
"alchemy"
);
- protected static final List<String> SLAYER_NAMES = Arrays.asList("wolf", "zombie", "spider", "enderman", "blaze");
- protected static final List<String> DUNGEON_CLASS_NAMES = Arrays.asList("healer", "mage", "berserk", "archer", "tank");
+ public static final List<String> SLAYER_NAMES = Arrays.asList("wolf", "zombie", "spider", "enderman", "blaze");
+ public static final List<String> DUNGEON_CLASS_NAMES = Arrays.asList("healer", "mage", "berserk", "archer", "tank");
protected final SlayerWeight slayerWeight;
protected final SkillsWeight skillsWeight;
protected final DungeonsWeight dungeonsWeight;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java
index 15b3c832..9c2f0e75 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java
@@ -229,7 +229,7 @@ public class EssenceUpgrades implements NeuRecipe {
if (essenceItemStack != null) {
essenceItemStack = essenceItemStack.copy();
essenceItemStack.setStackDisplayName(
- EnumChatFormatting.AQUA + NumberFormat.getInstance().format(tierUpgrade.getEssenceRequired()) + " " + EnumChatFormatting.DARK_GRAY +
+ EnumChatFormatting.AQUA + StringUtils.formatNumber(tierUpgrade.getEssenceRequired()) + " " + EnumChatFormatting.DARK_GRAY +
tierUpgrade.getEssenceType() + " Essence");
essenceItemStack.getTagCompound().setInteger(
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
index 0e580cb8..3b9daaf2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java
@@ -24,6 +24,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscfeatures.entityviewer.EntityViewer;
import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
@@ -87,7 +88,7 @@ public class MobLootRecipe implements NeuRecipe {
return chance;
}
- String format = GuiProfileViewer.numberFormat.format(chanceIn);
+ String format = StringUtils.formatNumber(chanceIn);
return "1/" + format + " (" + chance + ")";
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
index aaae0031..d10ae721 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
@@ -25,6 +25,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.listener.ItemTooltipListener;
import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
@@ -81,7 +82,7 @@ public class ItemUtils {
"ewogICJ0aW1lc3RhbXAiIDogMTYzNTk1NzQ4ODQxNywKICAicHJvZmlsZUlkIiA6ICJmNThkZWJkNTlmNTA0MjIyOGY2MDIyMjExZDRjMTQwYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJ1bnZlbnRpdmV0YWxlbnQiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2I5NTFmZWQ2YTdiMmNiYzIwMzY5MTZkZWM3YTQ2YzRhNTY0ODE1NjRkMTRmOTQ1YjZlYmMwMzM4Mjc2NmQzYiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9";
}
ItemStack skull = Utils.createSkull(
- "§r§6" + NumberFormat.getInstance().format(coinAmount) + " Coins",
+ "§r§6" + StringUtils.formatNumber(coinAmount) + " Coins",
uuid,
texture
);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
index b90e8087..67ed7c7b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
@@ -20,7 +20,7 @@
package io.github.moulberry.notenoughupdates.util;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import net.minecraft.client.Minecraft;
import java.util.HashMap;
@@ -31,7 +31,7 @@ public class ProfileApiSyncer {
private final HashMap<String, Long> resyncTimes = new HashMap<>();
private final HashMap<String, Runnable> syncingCallbacks = new HashMap<>();
- private final HashMap<String, Consumer<ProfileViewer.Profile>> finishSyncCallbacks = new HashMap<>();
+ private final HashMap<String, Consumer<SkyblockProfiles>> finishSyncCallbacks = new HashMap<>();
private long lastResync;
public static ProfileApiSyncer getInstance() {
@@ -50,7 +50,7 @@ public class ProfileApiSyncer {
String id,
long timeBetween,
Runnable syncingCallback,
- Consumer<ProfileViewer.Profile> finishSyncCallback
+ Consumer<SkyblockProfiles> finishSyncCallback
) {
resyncTimes.put(id, timeBetween);
syncingCallbacks.put(id, syncingCallback);
@@ -89,8 +89,8 @@ public class ProfileApiSyncer {
if (Minecraft.getMinecraft().thePlayer == null) return;
String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
- NotEnoughUpdates.profileViewer.getProfileReset(uuid, (profile) -> {
- for (Consumer<ProfileViewer.Profile> c : finishSyncCallbacks.values()) c.accept(profile);
+ NotEnoughUpdates.profileViewer.getOrLoadSkyblockProfiles(uuid, (profile) -> {
+ for (Consumer<SkyblockProfiles> c : finishSyncCallbacks.values()) c.accept(profile);
finishSyncCallbacks.clear();
});
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
index 94bfbee8..c4c85597 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
@@ -25,6 +25,7 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -230,8 +231,8 @@ public class XPInformation {
"runecrafting"
};
- private void onApiUpdated(ProfileViewer.Profile profile) {
- Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(null);
+ private void onApiUpdated(SkyblockProfiles profile) {
+ Map<String, ProfileViewer.Level> skyblockInfo = profile.getLatestProfile().getLevelingInfo();
for (String skill : skills) {
SkillInfo info = new SkillInfo();