From 82d3c94ddd024d38bd594787c2779a3cc1935462 Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Mon, 16 Jan 2023 20:58:17 +0100 Subject: not finished hgdt< --- .../moulberry/notenoughupdates/NEUOverlay.java | 4 +- .../commands/dev/DevTestCommand.java | 2 +- .../notenoughupdates/profileviewer/BasicPage.java | 227 ++++++++-------- .../profileviewer/CollectionsPage.java | 5 +- .../profileviewer/CrimsonIslePage.java | 6 +- .../profileviewer/DungeonPage.java | 225 ++++++++-------- .../notenoughupdates/profileviewer/ExtraPage.java | 2 +- .../profileviewer/GuiProfileViewer.java | 84 +++++- .../profileviewer/InventoriesPage.java | 2 +- .../profileviewer/PlayerStats.java | 105 +------- .../profileviewer/ProfileViewer.java | 255 +++++++++++++++++- .../profileviewer/bestiary/BestiaryPage.java | 36 +-- .../profileviewer/level/LevelPage.java | 195 ++++++++++++++ .../profileviewer/level/task/CoreTaskLevel.java | 169 ++++++++++++ .../profileviewer/level/task/DungeonTaskLevel.java | 126 +++++++++ .../profileviewer/level/task/EssenceTaskLevel.java | 151 +++++++++++ .../profileviewer/level/task/MiscTaskLevel.java | 200 ++++++++++++++ .../level/task/SkillRelatedTaskLevel.java | 211 +++++++++++++++ .../profileviewer/level/task/SlayingTaskLevel.java | 291 +++++++++++++++++++++ .../profileviewer/level/task/StoryTaskLevel.java | 81 ++++++ .../moulberry/notenoughupdates/util/Constants.java | 3 + .../moulberry/notenoughupdates/util/Utils.java | 85 +++++- 22 files changed, 2094 insertions(+), 371 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 7159ef89..8442697a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -105,10 +105,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; public class NEUOverlay extends Gui { - private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation( + public static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation( "notenoughupdates:supersecretassets/bald.png"); - private static final ResourceLocation ATMOULBERRYWHYISMYLUNARCLIENTBUGGING = new ResourceLocation( + public static final ResourceLocation ATMOULBERRYWHYISMYLUNARCLIENTBUGGING = new ResourceLocation( "notenoughupdates:supersecretassets/lunar.png"); private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png"); private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java index 5787c075..0d882358 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java @@ -147,7 +147,7 @@ public class DevTestCommand extends ClientCommandBase { }) .thenCompose(obj -> ProfileCollectionInfo.getCollectionData( obj, - Minecraft.getMinecraft().thePlayer.getUniqueID() + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() )) .thenAccept(it -> Utils.addChatMessage("Response: " + it)); 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 873ee9f2..0f17bb86 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -19,13 +19,13 @@ package io.github.moulberry.notenoughupdates.profileviewer; -import com.google.common.base.Splitter; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; 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.util.Constants; @@ -53,11 +53,12 @@ import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; import java.awt.*; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -72,6 +73,34 @@ import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt; public class BasicPage extends GuiProfileViewerPage { private static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png"); + + public static final ItemStack skull = Utils.createSkull( + "egirlefe", + "152de44a-43a3-46e1-badc-66cca2793471", + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODdkODg1YjMyYjBkZDJkNmI3ZjFiNTgyYTM0MTg2ZjhhNTM3M2M0NjU4OWEyNzM0MjMxMzJiNDQ4YjgwMzQ2MiJ9fX0=" + ); + + private static final LinkedHashMap dungeonsModeIcons = new LinkedHashMap() { + { + put( + "first_page", + Utils.editItemStackInfo( + new ItemStack(Items.paper), + EnumChatFormatting.GRAY + "Front Page", + true + ) + ); + put( + "second_page", + Utils.editItemStackInfo( + skull, + EnumChatFormatting.GRAY + "Level Page", + true + ) + ); + } + }; + private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1); public EntityOtherPlayerMP entityPlayer = null; private ResourceLocation playerLocationSkin = null; @@ -88,9 +117,14 @@ public class BasicPage extends GuiProfileViewerPage { private int backgroundClickedX = -1; + private boolean onSecondPage; + + private final LevelPage levelPage; + public BasicPage(GuiProfileViewer instance) { super(instance); this.guiProfileViewer = instance; + this.levelPage = new LevelPage(guiProfileViewer, this); } @Override @@ -101,6 +135,11 @@ public class BasicPage extends GuiProfileViewerPage { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); + if (onSecondPage) { + levelPage.drawPage(mouseX, mouseY, partialTicks); + return; + } + String location = null; JsonObject status = profile.getPlayerStatus(); if (status != null && status.has("mode")) { @@ -534,116 +573,29 @@ public class BasicPage extends GuiProfileViewerPage { ); } - PlayerStats.Stats stats = profile.getStats(profileId); + // sb lvlL - if (stats != null) { - Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2); - for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) { - String statName = PlayerStats.defaultStatNames[i]; - //if (statName.equals("mining_fortune") || statName.equals("mining_speed")) continue; - String statNamePretty = PlayerStats.defaultStatNamesPretty[i]; + int sbLevelX = guiLeft + 162; + int sbLevelY = guiTop + 90; - int val = Math.round(stats.get(statName)); + double skyblockLevel = profile.getSkyblockLevel(profileId); + EnumChatFormatting skyblockLevelColour = profile.getSkyblockLevelColour(profileId); - GlStateManager.color(1, 1, 1, 1); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate( - GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, - GL11.GL_ONE, - GL11.GL_ONE_MINUS_SRC_ALPHA - ); - Utils.renderAlignedString( - statNamePretty, - EnumChatFormatting.WHITE.toString() + val, - guiLeft + 132, - guiTop + 21 + 11f * i, - 80 - ); + GlStateManager.pushMatrix(); + GlStateManager.translate(sbLevelX, sbLevelY, 0); + GlStateManager.scale(1.5f, 1.5f, 1); + Utils.drawItemStack(skull, 0, 0); + GlStateManager.popMatrix(); + Utils.drawStringScaled(skyblockLevelColour.toString() + (int) skyblockLevel, fr, + sbLevelX - 2, sbLevelY - 15, true, 0, 1.5f + ); - if (mouseX > guiLeft + 132 && mouseX < guiLeft + 212) { - if (mouseY > guiTop + 21 + 11f * i && mouseY < guiTop + 37 + 11f * i) { - List split = splitter.splitToList(statNamePretty); - PlayerStats.Stats baseStats = PlayerStats.getBaseStats(); - getInstance().tooltipToDisplay = new ArrayList<>(); - getInstance().tooltipToDisplay.add(statNamePretty); - int base = Math.round(baseStats.get(statName)); - getInstance() - .tooltipToDisplay.add( - EnumChatFormatting.GRAY + - "Base " + - split.get(1) + - ": " + - EnumChatFormatting.GREEN + - base + - " " + - split.get(0) - ); - int passive = Math.round(profile.getPassiveStats(profileId).get(statName) - baseStats.get(statName)); - getInstance() - .tooltipToDisplay.add( - EnumChatFormatting.GRAY + - "Passive " + - split.get(1) + - " Bonus: +" + - EnumChatFormatting.YELLOW + - passive + - " " + - split.get(0) - ); - int itemBonus = Math.round(stats.get(statName) - profile.getPassiveStats(profileId).get(statName)); - getInstance() - .tooltipToDisplay.add( - EnumChatFormatting.GRAY + - "Item " + - split.get(1) + - " Bonus: +" + - EnumChatFormatting.DARK_PURPLE + - itemBonus + - " " + - split.get(0) - ); - int finalStat = Math.round(stats.get(statName)); - getInstance() - .tooltipToDisplay.add( - EnumChatFormatting.GRAY + - "Final " + - split.get(1) + - ": +" + - EnumChatFormatting.RED + - finalStat + - " " + - split.get(0) - ); - } - } - } - } else { - Utils.drawStringCentered( - EnumChatFormatting.RED + "Skill/Inv/Coll", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 172, - guiTop + 101 - 10, - true, - 0 - ); - Utils.drawStringCentered( - EnumChatFormatting.RED + "APIs not", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 172, - guiTop + 101, - true, - 0 - ); - Utils.drawStringCentered( - EnumChatFormatting.RED + "enabled!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 172, - guiTop + 101 + 10, - true, - 0 - ); - } + float progress = (float) (skyblockLevel - (long) skyblockLevel); + getInstance().renderBar(sbLevelX - 30, sbLevelY + 30, 80, progress); + + Utils.drawStringScaled(EnumChatFormatting.YELLOW.toString() + (int) (progress * 100) + "/100", fr, + sbLevelX - 30, sbLevelY + 20, true, 0, 0.9f + ); if (skyblockInfo != null) { int position = 0; @@ -672,6 +624,12 @@ public class BasicPage extends GuiProfileViewerPage { getInstance().renderBar(x, y + 6, 80, level.level % 1); } + if (mouseX >= guiLeft + 128 && mouseX <= guiLeft + 216) { + if (mouseY >= guiTop + 69 && mouseY <= guiTop + 131) { + if(Mouse.isButtonDown(0)) onSecondPage = true; + } + } + if (mouseX > x && mouseX < x + 80) { if (mouseY > y - 4 && mouseY < y + 13) { getInstance().tooltipToDisplay = new ArrayList<>(); @@ -759,6 +717,7 @@ public class BasicPage extends GuiProfileViewerPage { ); } + drawSideButtons(); renderWeight(mouseX, mouseY, skyblockInfo, profileInfo); } @@ -992,10 +951,62 @@ public class BasicPage extends GuiProfileViewerPage { GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } + @Override + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + int guiLeft = GuiProfileViewer.getGuiLeft(); + int guiTop = GuiProfileViewer.getGuiTop(); + + int i = onSlotToChangePage(mouseX, mouseY, guiLeft, guiTop); + switch (i) { + case 1: + onSecondPage = false; + break; + case 2: + onSecondPage = true; + break; + + default: + break; + } + + return false; + } + + public int onSlotToChangePage(int mouseX, int mouseY, int guiLeft, int guiTop) { + if (mouseX >= guiLeft - 29 && mouseX <= guiLeft) { + if (mouseY >= guiTop && mouseY <= guiTop + 28) { + return 1; + } else if (mouseY + 28 >= guiTop && mouseY <= guiTop + 28 * 2) { + return 2; + } + } + 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); + if (onSecondPage) { + Utils.drawPvSideButton(1, dungeonsModeIcons.get("second_page"), true, guiProfileViewer); + } else { + Utils.drawPvSideButton(0, dungeonsModeIcons.get("first_page"), true, guiProfileViewer); + } + GlStateManager.translate(0, 0, -3); + + GlStateManager.translate(0, 0, -2); + if (!onSecondPage) { + Utils.drawPvSideButton(1, dungeonsModeIcons.get("second_page"), false, guiProfileViewer); + } else { + Utils.drawPvSideButton(0, dungeonsModeIcons.get("first_page"), false, guiProfileViewer); + } + GlStateManager.disableDepth(); + } } 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 554e204c..e2e40ed1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java @@ -37,6 +37,7 @@ import java.awt.*; import java.io.IOException; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -217,10 +218,10 @@ public class CollectionsPage extends GuiProfileViewerPage { String tierString; int tier = (int) Utils.getElementAsFloat(collectionTiers.get(collection), 0); - if (tier > 20 || tier < 0) { + if (tier > 20 || tier <= 0) { tierString = String.valueOf(tier); } else { - tierString = romans[tier]; + tierString = romans[tier-1]; } float amount = Utils.getElementAsFloat(totalAmounts.get(collection), 0); float maxAmount = Utils.getElementAsFloat(maxAmounts.get(collection), 0); 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 95009b1d..c423bab9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java @@ -63,7 +63,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { "Infernal" }; - private static final LinkedHashMap apiDojoTestNames = new LinkedHashMap() {{ + public static final LinkedHashMap apiDojoTestNames = new LinkedHashMap() {{ put("mob_kb", EnumChatFormatting.GOLD + "Test of Force"); put("wall_jump", EnumChatFormatting.LIGHT_PURPLE + "Test of Stamina"); put("archer", EnumChatFormatting.YELLOW + "Test of Mastery"); @@ -73,7 +73,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { put("fireball", EnumChatFormatting.GOLD + "Test of Tenacity"); }}; - private static final LinkedHashMap dojoPointsToRank = new LinkedHashMap() {{ + public static final LinkedHashMap dojoPointsToRank = new LinkedHashMap() {{ put(0, EnumChatFormatting.GRAY + "None"); put(1000, EnumChatFormatting.YELLOW + "Yellow"); put(2000, EnumChatFormatting.GREEN + "Green"); @@ -278,7 +278,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { ); } - public String getRank(int points) { + public static String getRank(int points) { int lastRank = 0; for (Map.Entry rank : dojoPointsToRank.entrySet()) { if (points < rank.getKey()) { 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 cbebb6f4..2c0dc110 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/DungeonPage.java @@ -54,7 +54,7 @@ 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 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), @@ -63,7 +63,7 @@ public class DungeonPage extends GuiProfileViewerPage { new ItemStack(Items.bow), new ItemStack(Items.leather_chestplate), }; - private static final String[] bossFloorArr = { "Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron" }; + private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"}; private static final String[] bossFloorHeads = { "12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c", "7de7bbbdf22bfe17980d4e20687e386f11d59ee1db6f8b4762391b79a5ac532d", @@ -145,7 +145,10 @@ public class DungeonPage extends GuiProfileViewerPage { //Catacombs level thingy { if (levelObjCata == null) { - float cataXp = Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.experience"), 0); + float cataXp = Utils.getElementAsFloat(Utils.getElement( + profileInfo, + "dungeons.dungeon_types.catacombs.experience" + ), 0); levelObjCata = ProfileViewer.getLevel( Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(), @@ -181,11 +184,20 @@ public class DungeonPage extends GuiProfileViewerPage { if (mouseX > x && mouseX < x + sectionWidth && mouseY > y + 16 && mouseY < y + 24 && !onMasterMode) { float F5 = - (Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.tier_completions." + 5), 0)); //this can prob be done better + (Utils.getElementAsFloat(Utils.getElement( + profileInfo, + "dungeons.dungeon_types.catacombs.tier_completions." + 5 + ), 0)); //this can prob be done better float F6 = - (Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.tier_completions." + 6), 0)); + (Utils.getElementAsFloat(Utils.getElement( + profileInfo, + "dungeons.dungeon_types.catacombs.tier_completions." + 6 + ), 0)); float F7 = - (Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.tier_completions." + 7), 0)); + (Utils.getElementAsFloat(Utils.getElement( + profileInfo, + "dungeons.dungeon_types.catacombs.tier_completions." + 7 + ), 0)); if (F5 > 150) { F5 = 150; } @@ -223,7 +235,8 @@ public class DungeonPage extends GuiProfileViewerPage { getInstance().tooltipToDisplay = Lists.newArrayList( - EnumChatFormatting.YELLOW + "Remaining XP: " + EnumChatFormatting.GRAY + String.format("%,d", floorLevelToXP), + EnumChatFormatting.YELLOW + "Remaining XP: " + EnumChatFormatting.GRAY + + String.format("%,d", floorLevelToXP), String.format("# F5 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpF5), runsF5), String.format("# F6 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpF6), runsF6), String.format("# F7 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpF7), runsF7), @@ -232,17 +245,26 @@ public class DungeonPage extends GuiProfileViewerPage { boolean hasTime = false; if (timeF5 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (F5) : %s", Utils.prettyTime(runsF5 * (long) (timeF5 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (F5) : %s", + Utils.prettyTime(runsF5 * (long) (timeF5 * 1.2)) + )); hasTime = true; } if (timeF6 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (F6) : %s", Utils.prettyTime(runsF6 * (long) (timeF6 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (F6) : %s", + Utils.prettyTime(runsF6 * (long) (timeF6 * 1.2)) + )); hasTime = true; } if (timeF7 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (F7) : %s", Utils.prettyTime(runsF7 * (long) (timeF7 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (F7) : %s", + Utils.prettyTime(runsF7 * (long) (timeF7 * 1.2)) + )); hasTime = true; } if (hasTime) { @@ -261,19 +283,20 @@ public class DungeonPage extends GuiProfileViewerPage { getInstance() .tooltipToDisplay.add( "The " + - EnumChatFormatting.DARK_PURPLE + - "Catacombs Expert Ring" + - EnumChatFormatting.GRAY + - " is assumed to be used, unless " + - EnumChatFormatting.YELLOW + - "SHIFT" + - EnumChatFormatting.GRAY + - " is held." + EnumChatFormatting.DARK_PURPLE + + "Catacombs Expert Ring" + + EnumChatFormatting.GRAY + + " is assumed to be used, unless " + + EnumChatFormatting.YELLOW + + "SHIFT" + + EnumChatFormatting.GRAY + + " is held." ); getInstance().tooltipToDisplay.add("[Time per run] is calculated using Fastest S+ x 120%"); } else { getInstance() - .tooltipToDisplay.add("[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]"); + .tooltipToDisplay.add( + "[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]"); } } @@ -371,38 +394,54 @@ public class DungeonPage extends GuiProfileViewerPage { getInstance().tooltipToDisplay = Lists.newArrayList( - EnumChatFormatting.YELLOW + "Remaining XP: " + EnumChatFormatting.GRAY + String.format("%,d", floorLevelToXP), + EnumChatFormatting.YELLOW + "Remaining XP: " + EnumChatFormatting.GRAY + + String.format("%,d", floorLevelToXP), String.format("# M3 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpM3), runsM3), String.format("# M4 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpM4), runsM4), String.format("# M5 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpM5), runsM5), String.format("# M6 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpM6), runsM6), - String.format("# M7 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpM7), runsM7), + String.format("# M7 Runs (%s xp) : %d", StringUtils.shortNumberFormat(xpM7), runsM7), "" ); boolean hasTime = false; if (timeM3 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (M3) : %s", Utils.prettyTime(runsM3 * (long) (timeM3 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (M3) : %s", + Utils.prettyTime(runsM3 * (long) (timeM3 * 1.2)) + )); hasTime = true; } if (timeM4 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (M4) : %s", Utils.prettyTime(runsM4 * (long) (timeM4 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (M4) : %s", + Utils.prettyTime(runsM4 * (long) (timeM4 * 1.2)) + )); hasTime = true; } if (timeM5 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (M5) : %s", Utils.prettyTime(runsM5 * (long) (timeM5 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (M5) : %s", + Utils.prettyTime(runsM5 * (long) (timeM5 * 1.2)) + )); hasTime = true; } if (timeM6 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (M6) : %s", Utils.prettyTime(runsM6 * (long) (timeM6 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (M6) : %s", + Utils.prettyTime(runsM6 * (long) (timeM6 * 1.2)) + )); hasTime = true; } if (timeM7 > 1000) { getInstance() - .tooltipToDisplay.add(String.format("Expected Time (M7) : %s", Utils.prettyTime(runsM7 * (long) (timeM7 * 1.2)))); + .tooltipToDisplay.add(String.format( + "Expected Time (M7) : %s", + Utils.prettyTime(runsM7 * (long) (timeM7 * 1.2)) + )); hasTime = true; } if (hasTime) { @@ -421,26 +460,32 @@ public class DungeonPage extends GuiProfileViewerPage { getInstance() .tooltipToDisplay.add( "The " + - EnumChatFormatting.DARK_PURPLE + - "Catacombs Expert Ring" + - EnumChatFormatting.GRAY + - " is assumed to be used, unless " + - EnumChatFormatting.YELLOW + - "SHIFT" + - EnumChatFormatting.GRAY + - " is held." + EnumChatFormatting.DARK_PURPLE + + "Catacombs Expert Ring" + + EnumChatFormatting.GRAY + + " is assumed to be used, unless " + + EnumChatFormatting.YELLOW + + "SHIFT" + + EnumChatFormatting.GRAY + + " is held." ); getInstance().tooltipToDisplay.add("[Time per run] is calculated using Fastest S+ x 120%"); } else { getInstance() - .tooltipToDisplay.add("[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]"); + .tooltipToDisplay.add( + "[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]"); } } dungeonLevelTextField.setSize(20, 10); dungeonLevelTextField.render(x + 22, y + 29); int calcLen = fontRendererObj.getStringWidth("Calculate"); - Utils.renderShadowedString(EnumChatFormatting.WHITE + "Calculate", x + sectionWidth - 17 - calcLen / 2f, y + 30, 100); + Utils.renderShadowedString( + EnumChatFormatting.WHITE + "Calculate", + x + sectionWidth - 17 - calcLen / 2f, + y + 30, + 100 + ); //Random stats @@ -518,7 +563,8 @@ public class DungeonPage extends GuiProfileViewerPage { ); Utils.renderAlignedString( EnumChatFormatting.YELLOW + "Secrets (/Run) ", - EnumChatFormatting.WHITE.toString() + (secrets == -1 ? "?" : (Math.round(secrets / Math.max(1, totalRuns) * 100) / 100f)), + EnumChatFormatting.WHITE.toString() + (secrets == -1 ? "?" : (Math.round( + secrets / Math.max(1, totalRuns) * 100) / 100f)), x, miscTopY + 30, sectionWidth @@ -545,18 +591,6 @@ public class DungeonPage extends GuiProfileViewerPage { float vMax = 11 / 256f; GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(GuiProfileViewer.pv_elements); - Utils.drawTexturedRect( - bx - 2, - y3 - 2, - 9, - 11, - invert ? uMax : uMin, - invert ? uMin : uMax, - invert ? vMax : vMin, - invert ? vMin : vMax, - GL11.GL_NEAREST - ); Utils.renderShadowedString(EnumChatFormatting.WHITE.toString() + i, bx + w / 2, y3, 10); } @@ -614,7 +648,8 @@ public class DungeonPage extends GuiProfileViewerPage { if (BOSS_HEADS[i - 1] == null) { String textureLink = bossFloorHeads[i - 1]; - String b64Decoded = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + textureLink + "\"}}}"; + String b64Decoded = + "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + textureLink + "\"}}}"; String b64Encoded = new String(Base64.getEncoder().encode(b64Decoded.getBytes())); ItemStack stack = new ItemStack(Items.skull, 1, 3); @@ -646,7 +681,11 @@ public class DungeonPage extends GuiProfileViewerPage { GlStateManager.popMatrix(); Utils.renderAlignedString( - String.format(EnumChatFormatting.YELLOW + "%s (" + (onMasterMode ? "M" : "F") + "%d) ", bossFloorArr[i - 1], i), + String.format( + EnumChatFormatting.YELLOW + "%s (" + (onMasterMode ? "M" : "F") + "%d) ", + bossFloorArr[i - 1], + i + ), EnumChatFormatting.WHITE.toString() + (int) compl, x + 16, y + 18 + 20 * (i - 1), @@ -662,7 +701,12 @@ public class DungeonPage extends GuiProfileViewerPage { //Gui.drawRect(x, y, x+120, y+147, 0xffffffff); - Utils.renderShadowedString(EnumChatFormatting.DARK_PURPLE + "Class Levels", x + sectionWidth / 2, y, sectionWidth); + Utils.renderShadowedString( + EnumChatFormatting.DARK_PURPLE + "Class Levels", + x + sectionWidth / 2, + y, + sectionWidth + ); JsonElement activeClassElement = Utils.getElement(profileInfo, "dungeons.selected_dungeon_class"); String activeClass = null; @@ -675,7 +719,10 @@ public class DungeonPage extends GuiProfileViewerPage { for (int i = 0; i < dungSkillsName.length; i++) { String skillName = dungSkillsName[i]; - HashMap levelObjClasses = levelObjClasseses.computeIfAbsent(profileId, k -> new HashMap<>()); + HashMap levelObjClasses = levelObjClasseses.computeIfAbsent( + profileId, + k -> new HashMap<>() + ); if (!levelObjClasses.containsKey(skillName)) { float cataXp = Utils.getElementAsFloat( Utils.getElement(profileInfo, "dungeons.player_classes." + skillName.toLowerCase() + ".experience"), @@ -708,7 +755,16 @@ public class DungeonPage extends GuiProfileViewerPage { ProfileViewer.Level levelObj = levelObjClasses.get(skillName); getInstance() - .renderXpBar(colour + skillName, dungSkillsStack[i], x, y + 20 + 24 * i, sectionWidth, levelObj, mouseX, mouseY); + .renderXpBar( + colour + skillName, + dungSkillsStack[i], + x, + y + 20 + 24 * i, + sectionWidth, + levelObj, + mouseX, + mouseY + ); } getInstance().renderXpBar( @@ -718,7 +774,8 @@ public class DungeonPage extends GuiProfileViewerPage { y + 20 + 24 * 5, sectionWidth, classAverage, - mouseX, mouseY); + mouseX, mouseY + ); } drawSideButtons(); @@ -737,7 +794,8 @@ public class DungeonPage extends GuiProfileViewerPage { } int cW = fontRendererObj.getStringWidth("Calculate"); - if (mouseX >= guiLeft + 23 + 110 - 17 - cW && mouseX <= guiLeft + 23 + 110 - 17 && mouseY >= guiTop + 55 && mouseY <= guiTop + 65) { + if (mouseX >= guiLeft + 23 + 110 - 17 - cW && mouseX <= guiLeft + 23 + 110 - 17 && mouseY >= guiTop + 55 && + mouseY <= guiTop + 65) { calculateFloorLevelXP(); } @@ -774,66 +832,21 @@ public class DungeonPage extends GuiProfileViewerPage { GlStateManager.enableDepth(); GlStateManager.translate(0, 0, 5); if (onMasterMode) { - drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), true); + Utils.drawPvSideButton(1, dungeonsModeIcons.get("master_catacombs"), true, getInstance()); } else { - drawSideButton(0, dungeonsModeIcons.get("catacombs"), true); + Utils.drawPvSideButton(0, dungeonsModeIcons.get("catacombs"), true, getInstance()); } GlStateManager.translate(0, 0, -3); GlStateManager.translate(0, 0, -2); if (!onMasterMode) { - drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), false); + Utils.drawPvSideButton(1, dungeonsModeIcons.get("master_catacombs"), false, getInstance()); } else { - drawSideButton(0, dungeonsModeIcons.get("catacombs"), false); + Utils.drawPvSideButton(0, dungeonsModeIcons.get("catacombs"), false, getInstance()); } GlStateManager.disableDepth(); } - private void drawSideButton(int yIndex, ItemStack itemStack, boolean pressed) { - int guiLeft = GuiProfileViewer.getGuiLeft(); - int guiTop = GuiProfileViewer.getGuiTop(); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(516, 0.1F); - - int x = guiLeft - 28; - int y = guiTop + yIndex * 28; - - float uMin = 193 / 256f; - float uMax = 223 / 256f; - float vMin = 200 / 256f; - float vMax = 228 / 256f; - if (pressed) { - uMin = 224 / 256f; - uMax = 1f; - - if (yIndex != 0) { - vMin = 228 / 256f; - vMax = 1f; - } - - getInstance().renderBlurredBackground(getInstance().width, getInstance().height, x + 2, y + 2, 30, 28 - 4); - } else { - getInstance().renderBlurredBackground(getInstance().width, getInstance().height, x + 2, y + 2, 28 - 2, 28 - 4); - } - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(516, 0.1F); - - Minecraft.getMinecraft().getTextureManager().bindTexture(GuiProfileViewer.pv_elements); - - Utils.drawTexturedRect(x, y, pressed ? 32 : 28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); - - GlStateManager.enableDepth(); - Utils.drawItemStack(itemStack, x + 8, y + 7); - } - private void calculateFloorLevelXP() { JsonObject leveling = Constants.LEVELING; if (leveling == null) return; @@ -852,7 +865,7 @@ public class DungeonPage extends GuiProfileViewerPage { if (level < Math.floor(levelObjCata.level)) { continue; } - remaining += levelingArray.get(level).getAsFloat(); + remaining += levelingArray.get(level).getAsFloat(); } if (remaining < 0) { 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 59c78dda..90ffd388 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java @@ -94,7 +94,7 @@ public class ExtraPage extends GuiProfileViewerPage { } // pls update in the future tyvm !!! - final static HashMap slayers = new HashMap() { + public final static HashMap slayers = new HashMap() { { put("zombie", 5); put("spider", 4); 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 4bf65cc6..c189cbad 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -171,7 +171,10 @@ public class GuiProfileViewer extends GuiScreen { ); public final GuiElementTextField playerNameTextField; public final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); - public final GuiElementTextField killDeathSearchTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); + public final GuiElementTextField killDeathSearchTextField = new GuiElementTextField( + "", + GuiElementTextField.SCALE_TEXT + ); private final Map pages = new HashMap<>(); public int sizeX; public int sizeY; @@ -390,7 +393,7 @@ public class GuiProfileViewer extends GuiScreen { GL11.GL_NEAREST ); Utils.drawStringCenteredScaledMaxWidth( - "Open in Skycrypt", + "Open in SkyCrypt", Minecraft.getMinecraft().fontRendererObj, guiLeft + 50 + 100 + 6, guiTop + sizeY + 3 + 10, @@ -838,8 +841,9 @@ public class GuiProfileViewer extends GuiScreen { profileId != null ) { if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) { - String url = "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" + - profileId; + String url = + "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" + + profileId; Utils.openUrl(url); Utils.playPressSound(); return; @@ -960,14 +964,17 @@ 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 + " (" + + numberFormat.format(levelObj.totalXp) + EnumChatFormatting.DARK_GRAY + " (" + DECIMAL_FORMAT.format(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 + // Adds overflow level to each level object that is maxed, avoids hotm level as there is no overflow xp for it if (levelObj.maxed) { levelStr = levelObj.maxLevel != 7 ? - EnumChatFormatting.GOLD + "MAXED!" + EnumChatFormatting.GRAY + " (Overflow level: " + String.format("%.2f", levelObj.level) + ")" : - EnumChatFormatting.GOLD + "MAXED!"; + EnumChatFormatting.GOLD + "MAXED!" + EnumChatFormatting.GRAY + " (Overflow level: " + String.format( + "%.2f", + levelObj.level + ) + ")" : + EnumChatFormatting.GOLD + "MAXED!"; } else { if (skillName.contains("Class Average")) { levelStr = "Progress: " + EnumChatFormatting.DARK_PURPLE + String.format("%.1f", (level % 1 * 100)) + "%"; @@ -1010,6 +1017,67 @@ public class GuiProfileViewer extends GuiScreen { return ((BasicPage) pages.get(ProfileViewerPage.BASIC)).entityPlayer; } + public void renderLevelBar( + String name, + ItemStack stack, + int x, + int y, + int xSize, + double level, + double xp, + double max, + int mouseX, + int mouseY, + boolean percentage, + List tooltip + ) { + + if (xp < 0) xp = 0; + double experienceRequired = (xp / max); + + String second = EnumChatFormatting.WHITE.toString() + (int) level; + if (percentage) { + second = EnumChatFormatting.WHITE.toString() + (int) (experienceRequired * 100) + "%"; + } + Utils.renderAlignedString( + EnumChatFormatting.RED + name, + second, + x + 14, + y - 4, + xSize - 20 + ); + + if (xp >= max) { + renderGoldBar(x, y + 6, xSize); + } else { + renderBar(x, y + 6, xSize, (float) experienceRequired); + } + String levelStr; + if (mouseX > x && mouseX < x + 120) { + if (mouseY > y - 4 && mouseY < y + 13) { + levelStr = + EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.DARK_PURPLE + (int) (experienceRequired * 100) + + "%" + + " ยง8(" + (int) xp + "/" + (int) max + " XP)"; + if (tooltip != null && !tooltip.isEmpty()) { + tooltip.add(""); + tooltip.add(levelStr); + tooltipToDisplay = tooltip; + } else { + tooltipToDisplay = Utils.createList(levelStr); + } + } + } + + GlStateManager.enableDepth(); + GL11.glTranslatef((x), (y - 6f), 0); + GL11.glScalef(0.7f, 0.7f, 1); + Utils.drawItemStackLinear(stack, 0, 0); + GL11.glScalef(1 / 0.7f, 1 / 0.7f, 1); + GL11.glTranslatef(-(x), -(y - 6f), 0); + GlStateManager.disableDepth(); + } + public void renderGoldBar(float x, float y, float xSize) { if (!OpenGlHelper.areShadersSupported()) { renderBar(x, y, xSize, 1); 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 a981183a..164f5d78 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java @@ -154,7 +154,7 @@ public class InventoriesPage extends GuiProfileViewerPage { 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 = PlayerStats.getMagicalPower(inventoryInfo, profileInformation); + int magicalPower = profile.getMagicalPower(profileId); getInstance() .tooltipToDisplay.add( magicalPower == -1 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 56ecd3a2..64ea0f6c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java @@ -170,12 +170,10 @@ public class PlayerStats { return skillBonus; } - private static Stats getTamingBonus(JsonObject profile) { + public static int getPetScore(JsonObject profile) { JsonObject bonuses = Constants.BONUSES; - if (bonuses == null) return null; - JsonElement petsElement = Utils.getElement(profile, "pets"); - if (petsElement == null) return new Stats(); + if (petsElement == null) return 0; JsonArray pets = petsElement.getAsJsonArray(); @@ -190,11 +188,19 @@ public class PlayerStats { for (String value : highestRarityMap.values()) { petScore += Utils.getElementAsFloat(Utils.getElement(bonuses, "pet_value." + value.toUpperCase()), 0); } + return petScore; + } + + private static Stats getTamingBonus(JsonObject profile) { + JsonObject bonuses = Constants.BONUSES; + if (bonuses == null) return null; JsonElement petRewardsElement = Utils.getElement(bonuses, "pet_rewards"); if (petRewardsElement == null) return null; JsonObject petRewards = petRewardsElement.getAsJsonObject(); + int petScore = getPetScore(profile); + Stats petBonus = new Stats(); for (int i = 0; i <= petScore; i++) { if (petRewards.has("" + i)) { @@ -654,97 +660,6 @@ public class PlayerStats { return stats; } - /** - * Calculates the amount of Magical Power the player has using the list of accessories - * - * @param inventoryInfo inventory info object - * @return the amount of Magical Power or -1 - * @see io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer.Profile#getInventoryInfo(String) - */ - public static int getMagicalPower(JsonObject inventoryInfo, JsonObject profileInfo) { - if (inventoryInfo == null || !inventoryInfo.has("talisman_bag") || !inventoryInfo.get("talisman_bag").isJsonArray()) { - return -1; - } - - Map accessories = JsonUtils.getJsonArrayAsStream(inventoryInfo.get("talisman_bag").getAsJsonArray()) - .map(o -> { - try { - return JsonToNBT.getTagFromJson(o.getAsJsonObject().get("nbttag").getAsString()); - } catch (Exception ignored) { - return null; - } - }).filter(Objects::nonNull).map(tag -> { - NBTTagList loreTagList = tag.getCompoundTag("display").getTagList("Lore", 8); - String lastElement = loreTagList.getStringTagAt(loreTagList.tagCount() - 1); - if (lastElement.contains(EnumChatFormatting.OBFUSCATED.toString())) { - lastElement = lastElement.substring(lastElement.indexOf(' ')).trim().substring(4); - } - JsonArray lastElementJsonArray = new JsonArray(); - lastElementJsonArray.add(new JsonPrimitive(lastElement)); - return new AbstractMap.SimpleEntry<>( - tag.getCompoundTag("ExtraAttributes").getString("id"), - Utils.getRarityFromLore(lastElementJsonArray) - ); - }).sorted(Comparator.comparingInt(e -> -e.getValue())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2)->v1, LinkedHashMap::new)); - - Set ignoredTalismans = new HashSet<>(); - int powderAmount = 0; - for (Map.Entry entry : accessories.entrySet()) { - if (ignoredTalismans.contains(entry.getKey())) { - continue; - } - - JsonArray children = Utils.getElementOrDefault(Constants.PARENTS, entry.getKey(), new JsonArray()).getAsJsonArray(); - for (JsonElement child : children) { - ignoredTalismans.add(child.getAsString()); - } - - if (entry.getKey().equals("HEGEMONY_ARTIFACT")) { - switch (entry.getValue()) { - case 4: - powderAmount += 16; - break; - case 5: - powderAmount += 22; - break; - } - } - if (entry.getKey().equals("ABICASE")) { - if (profileInfo.has("nether_island_player_data") && - profileInfo.get("nether_island_player_data").getAsJsonObject().has("abiphone") && profileInfo.get( - "nether_island_player_data").getAsJsonObject().get("abiphone").getAsJsonObject().has("active_contacts")) { // BatChest - int contact = - profileInfo.get("nether_island_player_data").getAsJsonObject().get("abiphone").getAsJsonObject().get( - "active_contacts").getAsJsonArray().size(); - powderAmount += Math.floor(contact / 2); - } - } - switch (entry.getValue()) { - case 0: - case 6: - powderAmount += 3; - break; - case 1: - case 7: - powderAmount += 5; - break; - case 2: - powderAmount += 8; - break; - case 3: - powderAmount += 12; - break; - case 4: - powderAmount += 16; - break; - case 5: - powderAmount += 22; - break; - } - } - return powderAmount; - } - /** * Finds the Magical Power the player selected if applicable * 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 63c2435a..d1d2f553 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -25,14 +25,18 @@ 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.JsonUtils; import io.github.moulberry.notenoughupdates.util.Utils; +import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo; 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.JsonToNBT; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; @@ -40,19 +44,27 @@ import net.minecraft.util.EnumChatFormatting; import javax.annotation.Nullable; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.util.AbstractMap; 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.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; public class ProfileViewer { @@ -247,7 +259,7 @@ public class ProfileViewer { "REDSTONE", "QUARTZ", "OBSIDIAN", - "GLOWSTONE", + "GLOWSTONE_DUST", "GRAVEL", "ICE", null, @@ -449,6 +461,10 @@ public class ProfileViewer { private final NEUManager manager; private final HashMap uuidToHypixelProfile = new HashMap<>(); private final HashMap uuidToProfileMap = new HashMap<>(); + private final HashMap skyBlockExperience = new HashMap<>(); + + private final HashMap skyBlockExperienceColour = new HashMap<>(); + private final HashMap nameToUuid = new HashMap<>(); public ProfileViewer(NEUManager manager) { @@ -648,6 +664,10 @@ public class ProfileViewer { private final HashMap stats = new HashMap<>(); private final HashMap passiveStats = new HashMap<>(); private final HashMap networth = new HashMap<>(); + private final HashMap magicalPower = new HashMap<>(); + + private final HashMap> collectionInfoHashMap = new HashMap<>(); + private final HashMap soopyNetworth = new HashMap<>(); private final AtomicBoolean updatingSkyblockProfilesState = new AtomicBoolean(false); private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false); @@ -671,6 +691,118 @@ public class ProfileViewer { 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; + } + + Map accessories = JsonUtils.getJsonArrayAsStream(inventoryInfo + .get("talisman_bag") + .getAsJsonArray()) + .map(o -> { + try { + return JsonToNBT.getTagFromJson(o + .getAsJsonObject() + .get("nbttag") + .getAsString()); + } catch (Exception ignored) { + return null; + } + }).filter(Objects::nonNull).map(tag -> { + NBTTagList loreTagList = tag.getCompoundTag("display").getTagList("Lore", 8); + String lastElement = loreTagList.getStringTagAt(loreTagList.tagCount() - 1); + if (lastElement.contains(EnumChatFormatting.OBFUSCATED.toString())) { + lastElement = lastElement.substring(lastElement.indexOf(' ')).trim().substring(4); + } + JsonArray lastElementJsonArray = new JsonArray(); + lastElementJsonArray.add(new JsonPrimitive(lastElement)); + return new AbstractMap.SimpleEntry<>( + tag.getCompoundTag("ExtraAttributes").getString("id"), + Utils.getRarityFromLore(lastElementJsonArray) + ); + }).sorted(Comparator.comparingInt(e -> -e.getValue())).collect(Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (v1, v2) -> v1, + LinkedHashMap::new + )); + + Set ignoredTalismans = new HashSet<>(); + int powerAmount = 0; + for (Map.Entry entry : accessories.entrySet()) { + if (ignoredTalismans.contains(entry.getKey())) { + continue; + } + + JsonArray children = Utils + .getElementOrDefault(Constants.PARENTS, entry.getKey(), new JsonArray()) + .getAsJsonArray(); + for (JsonElement child : children) { + ignoredTalismans.add(child.getAsString()); + } + + if (entry.getKey().equals("HEGEMONY_ARTIFACT")) { + switch (entry.getValue()) { + case 4: + powerAmount += 16; + break; + case 5: + powerAmount += 22; + break; + } + } + if (entry.getKey().equals("ABICASE")) { + if (profileInfo != null && profileInfo.has("nether_island_player_data") && + profileInfo.get("nether_island_player_data").getAsJsonObject().has("abiphone") && profileInfo + .get( + "nether_island_player_data") + .getAsJsonObject() + .get("abiphone") + .getAsJsonObject() + .has("active_contacts")) { // BatChest + int contact = + profileInfo.get("nether_island_player_data").getAsJsonObject().get("abiphone").getAsJsonObject().get( + "active_contacts").getAsJsonArray().size(); + powerAmount += Math.floor(contact / 2); + } + } + switch (entry.getValue()) { + case 0: + case 6: + powerAmount += 3; + break; + case 1: + case 7: + powerAmount += 5; + break; + case 2: + powerAmount += 8; + break; + case 3: + powerAmount += 12; + break; + case 4: + powerAmount += 16; + break; + case 5: + powerAmount += 22; + break; + } + } + magicalPower.put(profileId, powerAmount); + return powerAmount; + } + public JsonObject getPlayerStatus() { if (playerStatus != null) return playerStatus; if (updatingPlayerStatusState.get()) return null; @@ -924,6 +1056,69 @@ public class ProfileViewer { return null; } + /* + public LevelData getLevelData(String profileName) { + if (levelData.containsKey(profileName)) { + return levelData.get(profileName); + } + LevelData data = new LevelData( + new CoreTaskData().loadInformation(profileName), + new DungeonTaskData().loadInformation(profileName), + new EssenceTaskData().loadInformation(profileName), + new MiscTaskData().loadInformation(profileName), + new SkillRelatedTaskData().loadInformation(profileName), + new SlayingTaskData().loadInformation(profileName), + new StoryTaskData().loadInformation(profileName), + Constants.SBLEVELS + ); + levelData.put(profileName, data); + + return data; + } + + */ + + public EnumChatFormatting getSkyblockLevelColour(String profileName) { + if (skyBlockExperienceColour.containsKey(profileName)) { + return skyBlockExperienceColour.get(profileName); + } + + double skyblockLevel = getSkyblockLevel(profileName); + + EnumChatFormatting previousColor = EnumChatFormatting.WHITE; + JsonObject sblevelColours = Constants.SBLEVELS.getAsJsonObject("sblevel_colours"); + try { + for (Map.Entry stringJsonElementEntry : sblevelColours.entrySet()) { + int key = Integer.parseInt(stringJsonElementEntry.getKey()); + EnumChatFormatting valueByName = EnumChatFormatting.getValueByName(stringJsonElementEntry + .getValue() + .getAsString()); + if (skyblockLevel <= key) { + + skyBlockExperienceColour.put(profileName, previousColor); + return previousColor; + } + previousColor = valueByName; + } + } catch (RuntimeException ignored) { // catch both numberformat and getValueByName being wrong + } + return EnumChatFormatting.WHITE; + } + + public double getSkyblockLevel(String profileName) { + if (skyBlockExperience.containsKey(profileName)) { + return skyBlockExperience.get(profileName); + } + final JsonObject profileInfo = getProfileInformation(profileName); + JsonElement element = Utils.getElement(profileInfo, "leveling.experience"); + double level = 0; + if (element != null) { + level = (element.getAsLong() / 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); @@ -1163,6 +1358,10 @@ public class ProfileViewer { 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")); + } + profileInfo.add("members", members); profileMap.put(profileName, profileInfo); return profileInfo; } @@ -1216,6 +1415,7 @@ public class ProfileViewer { inventoryCacheMap.clear(); collectionInfoMap.clear(); networth.clear(); + magicalPower.clear(); } public int getCap(JsonObject leveling, String skillName) { @@ -1225,6 +1425,40 @@ public class ProfileViewer { : 50; } + public int getBestiaryTiers(JsonObject profileInfo) { + int beLevel = 0; + for (ItemStack items : BestiaryData.getBestiaryLocations().keySet()) { + List 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 getSkyblockInfo(String profileName) { JsonObject profileInfo = getProfileInformation(profileName); @@ -1560,6 +1794,23 @@ public class ProfileViewer { return null; } + public ProfileCollectionInfo getCollectionInfoNew(String profileName, String uuid) + throws ExecutionException, InterruptedException { + if (collectionInfoHashMap.containsKey(profileName)) { + return collectionInfoHashMap.get(profileName).getNow(null); + } + JsonObject profileInfo = getProfileInformation(profileName); + CompletableFuture collectionData = ProfileCollectionInfo.getCollectionData( + profileInfo, + uuid + ); + if(collectionData.isDone()) { + collectionInfoHashMap.put(profileName, collectionData); + return collectionData.get(); + } + return null; + } + public JsonObject getCollectionInfo(String profileName) { JsonObject profileInfo = getProfileInformation(profileName); if (profileInfo == null) return null; @@ -1666,7 +1917,7 @@ public class ProfileViewer { } maxAmountRequired = amountRequired; } - if (maxTierAcquired >= 0 && maxTierAcquired > collTier) { + if (maxTierAcquired >= 0) { updatedCollectionTiers.addProperty(collName, maxTierAcquired); } maxAmount.addProperty(collName, maxAmountRequired); 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 70ea051a..7da6c627 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 @@ -117,7 +117,7 @@ public class BestiaryPage extends GuiProfileViewerPage { Color color = new Color(128, 128, 128, 255); Utils.renderAlignedString( EnumChatFormatting.RED + "Bestiary Level: ", - EnumChatFormatting.GRAY + "" + (float) getBestiaryTiers(profileInfo) / 10, + EnumChatFormatting.GRAY + "" + (float) GuiProfileViewer.getProfile().getBestiaryTiers(profileInfo) / 10, guiLeft + 220, guiTop + 50, 110 @@ -265,38 +265,4 @@ public class BestiaryPage extends GuiProfileViewerPage { yIndex++; } } - - private int getBestiaryTiers(JsonObject profileInfo) { - int beLevel = 0; - for (ItemStack items : BestiaryData.getBestiaryLocations().keySet()) { - List 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; - } } 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 new file mode 100644 index 00000000..ed5a1534 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java @@ -0,0 +1,195 @@ +/* + * 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 . + */ + +package io.github.moulberry.notenoughupdates.profileviewer.level; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NEUOverlay; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.pro