diff options
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.java | 108 |
1 files changed, 91 insertions, 17 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 a0a78938..9ef9e474 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -66,6 +66,7 @@ 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 { @@ -74,6 +75,13 @@ public class BasicPage extends GuiProfileViewerPage { private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1); public EntityOtherPlayerMP entityPlayer = null; private ResourceLocation playerLocationSkin = null; + private final GuiProfileViewer guiProfileViewer; + + private final String[] medalNames = { + "§cBronze", + "§fSilver", + "§6Gold" + }; private ResourceLocation playerLocationCape = null; private String skinType = null; private boolean loadingProfile = false; @@ -82,6 +90,7 @@ public class BasicPage extends GuiProfileViewerPage { public BasicPage(GuiProfileViewer instance) { super(instance); + this.guiProfileViewer = instance; } @Override @@ -154,6 +163,8 @@ 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; if (entityPlayer != null && profile.getHypixelProfile() != null) { String playerName = null; @@ -201,8 +212,11 @@ public class BasicPage extends GuiProfileViewerPage { playerName = EnumChatFormatting.GRAY + name; if (rankName != null) { + String icon = getIcon(getGameModeType(profileInfo)); playerName = - "\u00A7" + rankColor + "[" + rankName + rankPlusColor + rankPlus + "\u00A7" + rankColor + "] " + name; + "\u00A7" + rankColor + "[" + rankName + rankPlusColor + rankPlus + "\u00A7" + rankColor + "] " + name + + (icon.equals("") ? "" : " " + icon); + ; } } } @@ -404,9 +418,6 @@ public class BasicPage extends GuiProfileViewerPage { entityPlayer.getDataWatcher().updateObject(10, b); } - JsonObject profileInfo = profile.getProfileInformation(profileId); - if (profileInfo == null) return; - Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(profileId); JsonObject inventoryInfo = profile.getInventoryInfo(profileId); @@ -636,42 +647,85 @@ public class BasicPage extends GuiProfileViewerPage { String skillName = entry.getValue().getDisplayName(); - float level = skyblockInfo.get(entry.getKey()).level; - int levelFloored = (int) Math.floor(level); + ProfileViewer.Level level = skyblockInfo.get(entry.getKey()); + int levelFloored = (int) Math.floor(level.level); int x = guiLeft + 237 + 86 * xPosition; int y = guiTop + 24 + 21 * yPosition; Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, 60); - if (skyblockInfo.get(entry.getKey()).maxed) { + if (level.maxed) { getInstance().renderGoldBar(x, y + 6, 80); } else { - getInstance().renderBar(x, y + 6, 80, level % 1); + getInstance().renderBar(x, y + 6, 80, level.level % 1); } if (mouseX > x && mouseX < x + 80) { if (mouseY > y - 4 && mouseY < y + 13) { getInstance().tooltipToDisplay = new ArrayList<>(); - getInstance().tooltipToDisplay.add(skillName); - if (skyblockInfo.get(entry.getKey()).maxed) { - getInstance().tooltipToDisplay.add( + List<String> tooltipToDisplay = getInstance().tooltipToDisplay; + tooltipToDisplay.add(skillName); + if (level.maxed) { + tooltipToDisplay.add( EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.GOLD + "MAXED!"); } else { - int maxXp = (int) skyblockInfo.get(entry.getKey()).maxXpForLevel; + int maxXp = (int) level.maxXpForLevel; getInstance() .tooltipToDisplay.add( EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.DARK_PURPLE + - StringUtils.shortNumberFormat(Math.round((level % 1) * maxXp)) + + StringUtils.shortNumberFormat(Math.round((level.level % 1) * maxXp)) + "/" + - StringUtils.shortNumberFormat(maxXp) + StringUtils.shortNumberFormat(maxXp)); + } + String totalXpS = GuiProfileViewer.numberFormat.format((int) level.totalXp); + tooltipToDisplay.add(EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + totalXpS + + EnumChatFormatting.DARK_GRAY + " (" + + DECIMAL_FORMAT.format(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); + + if (doubleDrops == 15) { + tooltipToDisplay.add("§7Double Drops: §6" + (doubleDrops * 2) + "%"); + } else tooltipToDisplay.add("§7Double Drops: §5" + (doubleDrops * 2) + "%"); + + tooltipToDisplay.add("§7Pelts: §e" + peltCount); + + // medals + JsonObject medals_inv = Utils.getElement(profileInfo, "jacob2.medals_inv").getAsJsonObject(); + tooltipToDisplay.add(" "); + for (String medalName : medalNames) { + String textWithoutFormattingCodes = + EnumChatFormatting.getTextWithoutFormattingCodes(medalName.toLowerCase()); + if (medals_inv.has(textWithoutFormattingCodes)) { + int medalAmount = medals_inv.get(textWithoutFormattingCodes).getAsInt(); + tooltipToDisplay.add(EnumChatFormatting.GRAY + WordUtils.capitalize(medalName) + ": " + + EnumChatFormatting.WHITE + medalAmount); + } else { + tooltipToDisplay.add(EnumChatFormatting.GRAY + WordUtils.capitalize(medalName) + ": " + + EnumChatFormatting.WHITE + "0"); + } + } + } + + String slayerNameLower = entry.getKey().toLowerCase(); + if (ExtraPage.slayers.containsKey(slayerNameLower)) { + int maxLevel = ExtraPage.slayers.get(slayerNameLower); + 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), + 0 ); + tooltipToDisplay.add(EnumChatFormatting.GRAY + "T" + (i + 1) + " Kills: " + + EnumChatFormatting.RED + (int) tier); + } } - String totalXpS = GuiProfileViewer.numberFormat.format((int) skyblockInfo.get(entry.getKey()).totalXp); - getInstance() - .tooltipToDisplay.add(EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE + totalXpS); } } @@ -697,6 +751,19 @@ public class BasicPage extends GuiProfileViewerPage { renderWeight(mouseX, mouseY, skyblockInfo, profileInfo); } + private String getIcon(String gameModeType) { + switch (gameModeType) { + case "island": + return "§a☀"; + case "bingo": + return "§7Ⓑ"; + case "ironman": + return "§7♲"; + default: + return ""; + } + } + @Override public void resetCache() { entityPlayer = null; @@ -887,4 +954,11 @@ public class BasicPage extends GuiProfileViewerPage { GlStateManager.disableTexture2D(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } + + public String getGameModeType(JsonObject profileInfo) { + if (profileInfo != null && profileInfo.has("game_mode")) { + return profileInfo.get("game_mode").getAsString(); + } + return ""; + } } |
