aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-10-21 15:51:44 +0800
committerGitHub <noreply@github.com>2022-10-21 09:51:44 +0200
commit44fad457f0a066b0378b3cb615fd389d8d2a0850 (patch)
treecdf1c1efb35432e52c4448ed23152c50051148ed /src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
parent280a89cdbf086e53bcd6985e1ddd48b6aa718087 (diff)
downloadnotenoughupdates-44fad457f0a066b0378b3cb615fd389d8d2a0850.tar.gz
notenoughupdates-44fad457f0a066b0378b3cb615fd389d8d2a0850.tar.bz2
notenoughupdates-44fad457f0a066b0378b3cb615fd389d8d2a0850.zip
Soopy networth option in pv (#303)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
index 806b1bff..a0a78938 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java
@@ -49,6 +49,7 @@ 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.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -225,7 +226,31 @@ public class BasicPage extends GuiProfileViewerPage {
}
}
- long networth = profile.getNetWorth(profileId);
+ long networth;
+ 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("_", " ")) +
+ ": " +
+ EnumChatFormatting.GOLD +
+ GuiProfileViewer.numberFormat.format(nwData.getCategory(category)));
+ }
+
+ nwCategoryHover.add("");
+ }
+ } else {
+ networth = profile.getNetWorth(profileId);
+ }
+
if (networth > 0) {
Utils.drawStringCentered(
EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD +
@@ -245,7 +270,7 @@ public class BasicPage extends GuiProfileViewerPage {
.get("avg_buy")
.getAsDouble()
);
- String networthIRLMoney = Long.toString(Math.round(((networthInCookies * 325) / 675) * 4.99));
+ String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round(((networthInCookies * 325) / 675) * 4.99));
if (
mouseX > guiLeft + 8 &&
mouseX < guiLeft + 8 + fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth))
@@ -262,7 +287,9 @@ public class BasicPage extends GuiProfileViewerPage {
networthIRLMoney
);
getInstance().tooltipToDisplay.add("");
+
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ getInstance().tooltipToDisplay.addAll(nwCategoryHover);
getInstance().tooltipToDisplay.add(EnumChatFormatting.RED + "This is calculated using the current");
getInstance().tooltipToDisplay.add(
EnumChatFormatting.RED + "price of booster cookies on bazaar and the price");
@@ -282,7 +309,26 @@ public class BasicPage extends GuiProfileViewerPage {
}
}
} catch (Exception ignored) {
+ ignored.printStackTrace();
}
+ } else {
+ //Networth is under 0
+ //If = -1 -> an error occured
+ //If = -2 -> still loading networth
+
+ String stateStr = EnumChatFormatting.RED + "An error occured";
+ if (networth == -2) {
+ stateStr = EnumChatFormatting.YELLOW + "Loading...";
+ }
+
+ Utils.drawStringCentered(
+ EnumChatFormatting.GREEN + "Net Worth: " + stateStr,
+ fr,
+ guiLeft + 63,
+ guiTop + 38,
+ true,
+ 0
+ );
}
if (status != null) {