From 445d0c69f3eb384aba032e3cf0e379bb53ea61df Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 20 Aug 2022 09:21:21 +1000 Subject: Make be level show without island selected (#228) Co-authored-by: jani270 --- .../moulberry/notenoughupdates/NotEnoughUpdates.java | 4 ++-- .../notenoughupdates/miscfeatures/updater/AutoUpdater.java | 4 ++-- .../profileviewer/bestiary/BestiaryPage.java | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index d22b93f5..dd4c01af 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -112,8 +112,8 @@ import java.util.Set; public class NotEnoughUpdates { public static final String MODID = "notenoughupdates"; public static final String VERSION = "2.1.0-REL"; - public static final int VERSION_ID = 20000; - public static final int PRE_VERSION_ID = 1; + public static final int VERSION_ID = 20100; + public static final int PRE_VERSION_ID = 0; public static final int HOTFIX_VERSION_ID = 0; /** * Registers the biomes for the crystal hollows here so optifine knows they exists diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java index 7869225d..e7ada16f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java @@ -179,8 +179,8 @@ public class AutoUpdater { public void displayUpdateMessageIfOutOfDate() { File repo = neu.manager.repoLocation; - if (repo.exists()) { - File updateJson = new File(repo, "update.json"); + File updateJson = new File(repo, "update.json"); + if (updateJson.exists()) { try { JsonObject o = neu.manager.getJsonFromFile(updateJson); 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 7ca3e6a8..b37aa73f 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 @@ -112,6 +112,13 @@ public class BestiaryPage extends GuiProfileViewerPage { List mobs = BestiaryData.getBestiaryLocations().get(selectedBestiaryLocation); Color color = new Color(128, 128, 128, 255); + Utils.renderAlignedString( + EnumChatFormatting.RED + "Bestiary Level: ", + EnumChatFormatting.GRAY + "" + (float) getBestiaryTiers(profileInfo) / 10, + guiLeft + 220, + guiTop + 50, + 110 + ); if (mobs != null) { for (int i = 0; i < mobs.size(); i++) { String mob = mobs.get(i); @@ -218,13 +225,6 @@ public class BestiaryPage extends GuiProfileViewerPage { ); } } - Utils.renderAlignedString( - EnumChatFormatting.RED + "Bestiary Level: ", - EnumChatFormatting.GRAY + "" + (float) getBestiaryTiers(profileInfo) / 10, - guiLeft + 220, - guiTop + 50, - 110 - ); } } if (tooltipToDisplay != null) { -- cgit From 5908643f22674f68ad5f48edae01133b61e593a7 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Sat, 20 Aug 2022 03:15:59 +0200 Subject: Skill overlay example strings (#235) * Fix Skill Overlay example strings * typing is hard --- .../notenoughupdates/options/seperateSections/SkillOverlays.java | 4 ++-- .../io/github/moulberry/notenoughupdates/overlays/OverlayManager.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java index 54e17fcf..8b7002f9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java @@ -75,7 +75,7 @@ public class SkillOverlays { exampleText = { "\u00a7bCounter: \u00a7e37,547,860", "\u00a7bCrops/m: \u00a7e38.29", - "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", + "\u00a7bFarming: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", "\u00a7bCurrent XP: \u00a7e6,734", "\u00a7bRemaining XP: \u00a7e3,265", "\u00a7bXP/h: \u00a7e238,129", @@ -145,7 +145,7 @@ public class SkillOverlays { exampleText = { "\u00a7bCompact: \u00a7e547,860", "\u00a7bBlocks/m: \u00a7e38.29", - "\u00a7bMine: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", + "\u00a7bMining: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", "\u00a7bCurrent XP: \u00a7e6,734", "\u00a7bRemaining XP: \u00a7e3,265", "\u00a7bXP/h: \u00a7e238,129", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index d73c71dc..fef11a45 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -100,7 +100,7 @@ public class OverlayManager { List farmingDummy = Lists.newArrayList( "\u00a7bCounter: \u00a7e37,547,860", "\u00a7bCrops/m: \u00a7e38.29", - "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", + "\u00a7bFarming: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", "\u00a7bCurrent XP: \u00a7e6,734", "\u00a7bRemaining XP: \u00a7e3,265", "\u00a7bXP/h: \u00a7e238,129", @@ -122,7 +122,7 @@ public class OverlayManager { List miningSkillDummy = Lists.newArrayList( "\u00a7bCompact: \u00a7e547,860", "\u00a7bBlocks/m: \u00a7e38.29", - "\u00a7bMine: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", + "\u00a7bMining: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", "\u00a7bCurrent XP: \u00a7e6,734", "\u00a7bRemaining XP: \u00a7e3,265", "\u00a7bXP/h: \u00a7e238,129", -- cgit From 46e99cbaac7e999048c18ee8f310b1b1b5d333af Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 20 Aug 2022 03:20:08 +0200 Subject: more friendly drop chance format (#231) --- .../notenoughupdates/recipes/MobLootRecipe.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/main/java') 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 0d891071..7702f365 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java @@ -26,6 +26,7 @@ import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.miscfeatures.entityviewer.EntityViewer; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; +import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.Panorama; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.JsonUtils; @@ -64,11 +65,28 @@ public class MobLootRecipe implements NeuRecipe { if (itemStack == null) { itemStack = drop.getItemStack().copy(); List arrayList = new ArrayList<>(extra); - arrayList.add("§r§e§lDrop Chance: §6" + chance); + arrayList.add("§r§e§lDrop Chance: §6" + formatDropChance()); ItemUtils.appendLore(itemStack, arrayList); } return itemStack; } + + private String formatDropChance() { + if (!chance.endsWith("%")) { + return chance + " §cInvalid repo data!"; + } + + String chanceText = chance.substring(0, chance.length() - 1); + int chanceIn; + try { + chanceIn = (int) (100.0 / Double.parseDouble(chanceText)); + } catch (NumberFormatException e) { + return chance + " §cInvalid repo data!"; + } + + String format = GuiProfileViewer.numberFormat.format(chanceIn); + return "1/" + format + " (" + chance + ")"; + } } public static ResourceLocation BACKGROUND = new ResourceLocation( -- cgit From 70812dc80f10143fc49dd3710af764f8975b61ca Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 20 Aug 2022 13:14:16 +0200 Subject: removing the warnings in the lore in the mob loot recipe gui from neu mod when the chance from the repo does not meet simple percentage formatting (#239) --- .../io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java') 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 7702f365..82d56363 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java @@ -73,7 +73,7 @@ public class MobLootRecipe implements NeuRecipe { private String formatDropChance() { if (!chance.endsWith("%")) { - return chance + " §cInvalid repo data!"; + return chance; } String chanceText = chance.substring(0, chance.length() - 1); @@ -81,7 +81,7 @@ public class MobLootRecipe implements NeuRecipe { try { chanceIn = (int) (100.0 / Double.parseDouble(chanceText)); } catch (NumberFormatException e) { - return chance + " §cInvalid repo data!"; + return chance; } String format = GuiProfileViewer.numberFormat.format(chanceIn); -- cgit From 38771c209e98c8e0a5325798c0c99101d00f0762 Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Sat, 20 Aug 2022 15:20:56 +0200 Subject: enchanting book name remapping (#237) * enchanting book name remapping (omg remapping, minecraft obfuscation reference) * Fix gui resetting --- .../moulberry/notenoughupdates/auction/APIManager.java | 14 +++++++++++++- .../moulberry/notenoughupdates/miscgui/GuiItemRecipe.java | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 3fc34d10..c3999fb6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -59,6 +59,8 @@ import java.util.TreeMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class APIManager { private final NEUManager manager; @@ -702,6 +704,16 @@ public class APIManager { ); } + private static final Pattern BAZAAR_ENCHANTMENT_PATTERN = Pattern.compile("ENCHANTMENT_(\\D*)_(\\d+)"); + + public String transformHypixelBazaarToNEUItemId(String hypixelId) { + Matcher matcher = BAZAAR_ENCHANTMENT_PATTERN.matcher(hypixelId); + if (matcher.matches()) { + return matcher.group(1) + ";" + matcher.group(2); + } + return hypixelId.replace(":", "-"); + } + public void updateBazaar() { manager.hypixelApi.getHypixelApiAsync( NotEnoughUpdates.INSTANCE.config.apiData.apiKey, @@ -738,7 +750,7 @@ public class APIManager { } } - bazaarJson.add(entry.getKey().replace(":", "-"), productInfo); + bazaarJson.add(transformHypixelBazaarToNEUItemId(entry.getKey()), productInfo); } } GuiPriceGraph.addToCache(bazaarJson, true); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java index 69343e99..e06c271f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java @@ -89,13 +89,13 @@ public class GuiItemRecipe extends GuiScreen { if (!tabs.contains(recipe.getType())) tabs.add(recipe.getType()); } + changeRecipe(0, 0); } @Override public void initGui() { this.guiLeft = (width - this.xSize) / 2; this.guiTop = (height - this.ySize) / 2; - changeRecipe(0, 0); } public NeuRecipe getCurrentRecipe() { -- cgit From 013abf6525c39b99afdeba62d33dbeac9b9f766e Mon Sep 17 00:00:00 2001 From: efefury <69400149+efefury@users.noreply.github.com> Date: Sun, 21 Aug 2022 10:37:00 +0000 Subject: misc dungeon profit changes (#240) --- .../notenoughupdates/listener/RenderListener.java | 42 ++++++++++++++++++++-- .../options/seperateSections/Dungeons.java | 9 +++++ .../moulberry/notenoughupdates/util/SBInfo.java | 23 +++++++++++- 3 files changed, 70 insertions(+), 4 deletions(-) (limited to 'src/main/java') 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 31480016..3aeee590 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -23,6 +23,7 @@ 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.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonPrimitive; @@ -140,6 +141,7 @@ public class RenderListener { private String correctingItem; private boolean typing; private HashMap cachedDefinitions; + private boolean inDungeonPage = false; public RenderListener(NotEnoughUpdates neu) { this.neu = neu; @@ -528,6 +530,12 @@ public class RenderListener { x -= 25; } } + if (inDungeonPage) { + if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && + y < guiTop + 100) { + x += 185; + } + } GlStateManager.color(1, 1, 1, 1f); @@ -650,6 +658,13 @@ public class RenderListener { } } + if (inDungeonPage) { + if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && + y < guiTop + 100) { + x += 185; + } + } + if (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) { disableCraftingText = true; } @@ -697,7 +712,6 @@ public class RenderListener { private void renderDungeonChestOverlay(GuiScreen gui) { if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return; - if (gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) { try { int xSize = ((AccessorGuiContainer) gui).getXSize(); @@ -709,8 +723,9 @@ public class RenderListener { IInventory lower = cc.getLowerChestInventory(); ItemStack rewardChest = lower.getStackInSlot(31); - if (rewardChest != null && rewardChest.getDisplayName().endsWith( - EnumChatFormatting.GREEN + "Open Reward Chest")) { + this.inDungeonPage = rewardChest != null && rewardChest.getDisplayName().endsWith( + EnumChatFormatting.GREEN + "Open Reward Chest"); + if (inDungeonPage) { int chestCost = 0; try { String line6 = Utils.cleanColour(neu.manager.getLoreFromNBT(rewardChest.getTagCompound())[6]); @@ -906,6 +921,21 @@ public class RenderListener { 160 ); } + JsonObject mayorJson = SBInfo.getInstance().getMayorJson(); + JsonElement mayor = mayorJson.get("mayor"); + if (mayorJson.has("mayor") && mayor != null && mayor.getAsJsonObject().has("name") && + mayor.getAsJsonObject().get("name").getAsString().equals("Derpy") + && NotEnoughUpdates.INSTANCE.config.dungeons.shouldWarningDerpy) { + Utils.drawStringScaled( + EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "shMayor Derpy active!", + Minecraft.getMinecraft().fontRendererObj, + guiLeft + xSize + 4 + 10, + guiTop + 85, + true, + 0, + 1.3f + ); + } } } catch (Exception e) { e.printStackTrace(); @@ -1070,6 +1100,12 @@ public class RenderListener { x -= 25; } } + if (inDungeonPage) { + if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && + y < guiTop + 100) { + x += 185; + } + } if (mouseX >= x && mouseX <= x + 18 && mouseY >= y && mouseY <= y + 18) { if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java index fead6780..e080db7d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java @@ -114,6 +114,15 @@ public class Dungeons { @ConfigAccordionId(id = 1) public boolean useKismetOnDungeonProfit = true; + @Expose + @ConfigOption( + name = "Warning if Derpy active", + desc = "Shows a warning if the mayor Derpy is active" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean shouldWarningDerpy = true; + @ConfigOption( name = "Dungeon Win Overlay", desc = "" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 74409648..4e920aea 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -61,6 +61,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -87,6 +89,8 @@ public class SBInfo { public Date currentTimeDate = null; + private JsonObject mayorJson = new JsonObject(); + /** * Use Utils.getOpenChestName() instead */ @@ -97,6 +101,7 @@ public class SBInfo { private long lastManualLocRaw = -1; private long lastLocRaw = -1; public long joinedWorld = -1; + private long lastMayorUpdate; public long unloadedWorld = -1; private JsonObject locraw = null; public boolean isInDungeon = false; @@ -297,7 +302,10 @@ public class SBInfo { lastLocRaw = System.currentTimeMillis(); NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw"); } - + if (currentTime - lastMayorUpdate > 300 * 1000) { + updateMayor(); + lastMayorUpdate = currentTime; + } try { for (NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); @@ -421,4 +429,17 @@ public class SBInfo { e.printStackTrace(); } } + + public void updateMayor() { + NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync( + NotEnoughUpdates.INSTANCE.config.apiData.apiKey, + "resources/skyblock/election", + new HashMap<>() + ).thenAcceptAsync(newJson -> mayorJson = newJson); + } + + + public JsonObject getMayorJson() { + return mayorJson; + } } -- cgit From b97dd13100f36dc64560067c707081af5bc8ff0c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 23 Aug 2022 02:19:35 +0200 Subject: Fix Crash in Navigation.java (#244) --- .../io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java index 9cc872b7..541a76e8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java @@ -390,7 +390,7 @@ public class Navigation { && NotEnoughUpdates.INSTANCE.config.misc.untrackCloseWaypoints && island.equals(SBInfo.getInstance().mode)) { EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (thePlayer.getDistanceSq(position) < 16) + if (thePlayer != null && thePlayer.getDistanceSq(position) < 16) untrackWaypoint(); } } -- cgit From c3845685bbb3a2a7fde25476eed0f788e038dc93 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 24 Aug 2022 13:48:53 +0200 Subject: Neuah save search (#243) * saving the last search in neuah * default enabled * saving jani's desk --- .../moulberry/notenoughupdates/auction/CustomAH.java | 15 ++++++++++++++- .../notenoughupdates/commands/misc/AhCommand.java | 7 ++++++- .../options/seperateSections/NeuAuctionHouse.java | 11 ++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java index f0ef1ec6..7b4542d0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -133,6 +133,8 @@ public class CustomAH extends Gui { public int guiLeft = -1; public int guiTop = -1; + private String lastSearch = ""; + private final Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword"); private final Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate"); private final Category CATEGORY_BOWS = new Category("bow", "Bows", "bow"); @@ -275,7 +277,11 @@ public class CustomAH extends Gui { } public void setSearch(String search) { - searchField.setText(search); + if (search == null) { + searchField.setText(lastSearch); + } else { + searchField.setText(search); + } updateSearch(); } @@ -1487,8 +1493,15 @@ public class CustomAH extends Gui { auctionIdsNew.add(entry.getKey()); } } + if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.saveLastSearch) { + lastSearch = ""; + } } else { String query = searchField.getText(); + + if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.saveLastSearch) { + lastSearch = query; + } Set dontMatch = new HashSet<>(); HashSet allMatch = new HashSet<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java index 1cd6bcce..bd8abf1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java @@ -50,8 +50,13 @@ public class AhCommand extends ClientCommandBase { NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.clearSearch(); NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.updateSearch(); - if (args.length > 0) + if (args.length > 0) { NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(StringUtils.join(args, " ")); + } else { + if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.saveLastSearch) { + NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(null); + } + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java index 44f3454a..6c55fd09 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java @@ -24,7 +24,8 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; -public class NeuAuctionHouse { +public class +NeuAuctionHouse { @Expose @ConfigOption( name = "Enable NeuAH", @@ -61,4 +62,12 @@ public class NeuAuctionHouse { ) @ConfigEditorBoolean public boolean priceFiltering = false; + + @Expose + @ConfigOption( + name = "Save Last Search", + desc = "Saving the last query when closing the neuah" + ) + @ConfigEditorBoolean + public boolean saveLastSearch = true; } -- cgit From dfd2f6b05bce74d7feb5d28e7a388dbb871ecf6a Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Fri, 26 Aug 2022 13:24:35 +0200 Subject: Of course you have pronouns in pv (#234) --- .../moulberry/notenoughupdates/BuildFlags.java | 72 +++++ .../notenoughupdates/commands/Commands.java | 2 + .../commands/dev/DevTestCommand.java | 15 ++ .../commands/misc/PronounsCommand.java | 94 +++++++ .../notenoughupdates/core/util/StringUtils.java | 11 + .../options/seperateSections/ProfileViewer.java | 15 +- .../notenoughupdates/profileviewer/BasicPage.java | 294 +++++++++++++-------- .../notenoughupdates/profileviewer/ExtraPage.java | 17 +- .../profileviewer/GuiProfileViewer.java | 169 +++++++----- .../util/AsyncDependencyLoader.java | 55 ++++ .../util/AsyncDependencyLoaderImpl.java | 59 +++++ .../notenoughupdates/util/MinecraftExecutor.java | 37 +++ .../moulberry/notenoughupdates/util/PronounDB.java | 221 ++++++++++++++++ .../moulberry/notenoughupdates/util/Utils.java | 19 +- 14 files changed, 904 insertions(+), 176 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/AsyncDependencyLoader.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/AsyncDependencyLoaderImpl.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/MinecraftExecutor.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/PronounDB.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java b/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java new file mode 100644 index 00000000..d997d980 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2022 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; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * For storage of compile-time configuration flags + */ +public class BuildFlags { + + private static final Properties properties = new Properties(); + + static { + try { + properties.load(BuildFlags.class.getResourceAsStream("/buildflags.properties")); + } catch (IOException | NullPointerException e) { + System.out.println("Failed to load build properties: " + e); + } + } + + private static boolean getBuildFlag(String flag) { + return Boolean.parseBoolean(properties.getProperty("neu.buildflags." + flag)); + } + + public static Map getAllFlags() { + return Holder.ALL_FLAGS; + } + + public static final boolean ENABLE_PRONOUNS_IN_PV_BY_DEFAULT = getBuildFlag("pronouns"); + + private static class Holder { + static Map ALL_FLAGS = new HashMap<>(); + + static { + for (Field declaredField : BuildFlags.class.getDeclaredFields()) { + if (Boolean.TYPE.equals(declaredField.getType()) + && (declaredField.getModifiers() & Modifier.STATIC) != 0) { + try { + declaredField.setAccessible(true); + ALL_FLAGS.put(declaredField.getName(), (Boolean) declaredField.get(null)); + } catch (IllegalAccessException | ClassCastException | SecurityException e) { + System.err.println("Failed to access BuildFlag: " + e); + } + } + } + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java index 917185ab..fcb2aaf9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java @@ -42,6 +42,7 @@ import io.github.moulberry.notenoughupdates.commands.misc.CalculatorCommand; import io.github.moulberry.notenoughupdates.commands.misc.CalendarCommand; import io.github.moulberry.notenoughupdates.commands.misc.CosmeticsCommand; import io.github.moulberry.notenoughupdates.commands.misc.CustomizeCommand; +import io.github.moulberry.notenoughupdates.commands.misc.PronounsCommand; import io.github.moulberry.notenoughupdates.commands.misc.UpdateCommand; import io.github.moulberry.notenoughupdates.commands.profile.CataCommand; import io.github.moulberry.notenoughupdates.commands.profile.PeekCommand; @@ -97,6 +98,7 @@ public class Commands { ClientCommandHandler.instance.registerCommand(new CalculatorCommand()); ClientCommandHandler.instance.registerCommand(new CalendarCommand()); ClientCommandHandler.instance.registerCommand(new UpdateCommand(NotEnoughUpdates.INSTANCE)); + ClientCommandHandler.instance.registerCommand(new PronounsCommand()); // Fairy Soul Commands ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand()); 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 7cca9d3b..fdf59bb0 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 @@ -19,6 +19,7 @@ package io.github.moulberry.notenoughupdates.commands.dev; +import io.github.moulberry.notenoughupdates.BuildFlags; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; @@ -27,6 +28,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.Custom import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.SpecialBlockZone; import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph; +import io.github.moulberry.notenoughupdates.util.PronounDB; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -40,6 +42,7 @@ import net.minecraftforge.common.MinecraftForge; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class DevTestCommand extends ClientCommandBase { @@ -118,6 +121,14 @@ public class DevTestCommand extends ClientCommandBase { " with the mode " + gamemode)); } + if (args.length >= 1 && args[0].equalsIgnoreCase("buildflags")) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + "BuildFlags: \n" + + BuildFlags.getAllFlags().entrySet().stream() + .map(it -> " + " + it.getKey() + " - " + it.getValue()) + .collect(Collectors.joining("\n")))); + return; + } if (args.length >= 1 && args[0].equalsIgnoreCase("pricetest")) { if (args.length == 1) { NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar(); @@ -163,6 +174,10 @@ public class DevTestCommand extends ClientCommandBase { "I would never search")); return; } + if (args.length == 1 && args[0].equalsIgnoreCase("bluehair")) { + PronounDB.test(); + return; + } if (args.length == 2 && args[0].equalsIgnoreCase("openGui")) { try { NotEnoughUpdates.INSTANCE.openGui = (GuiScreen) Class.forName(args[1]).newInstance(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java new file mode 100644 index 00000000..6d0ee88d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2022 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.commands.misc; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; +import io.github.moulberry.notenoughupdates.util.MinecraftExecutor; +import io.github.moulberry.notenoughupdates.util.PronounDB; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.GuiNewChat; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import java.util.Optional; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class PronounsCommand extends ClientCommandBase { + public PronounsCommand() { + super("neupronouns"); + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "/neupronouns [platform]"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + switch (args.length) { + case 1: + fetchPronouns("minecraft", args[0]); + break; + case 2: + fetchPronouns(args[1], args[0]); + break; + default: + sender.addChatMessage(new ChatComponentText("§4" + getCommandUsage(sender))); + } + } + + private void fetchPronouns(String platform, String user) { + GuiNewChat nc = Minecraft.getMinecraft().ingameGUI.getChatGUI(); + int id = new Random().nextInt(); + nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] Fetching Pronouns..."), id); + + CompletableFuture> pronouns; + if ("minecraft".equals(platform)) { + CompletableFuture c = new CompletableFuture<>(); + NotEnoughUpdates.profileViewer.getPlayerUUID(user, uuidString -> { + if (uuidString == null) { + c.completeExceptionally(new NullPointerException()); + } else { + c.complete(Utils.parseDashlessUUID(uuidString)); + } + }); + pronouns = c.thenApplyAsync(PronounDB::getPronounsFor); + } else { + pronouns = CompletableFuture.supplyAsync(() -> PronounDB.getPronounsFor(platform, user)); + } + pronouns.handleAsync((pronounChoice, throwable) -> { + if (throwable != null || !pronounChoice.isPresent()) { + nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] §4Failed to fetch pronouns."), id); + return null; + } + PronounDB.PronounChoice betterPronounChoice = pronounChoice.get(); + nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] Pronouns for §b" + user + " §eon §b" + platform + "§e:"), id); + betterPronounChoice.render().forEach(it -> nc.printChatMessage(new ChatComponentText("§e[NEU] §a" + it))); + return null; + }, MinecraftExecutor.INSTANCE); + + } +} 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 d52f9ba1..ecb4cd8b 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 @@ -23,6 +23,9 @@ import com.google.common.collect.Sets; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Set; public class StringUtils { @@ -63,4 +66,12 @@ public class StringUtils { str = str.replace(",", ""); return Integer.parseInt(str); } + + 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 + } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java index ee1abf46..673e1015 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java @@ -20,7 +20,12 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.*; +import io.github.moulberry.notenoughupdates.BuildFlags; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; @@ -81,4 +86,12 @@ public class ProfileViewer { ) @ConfigEditorBoolean public boolean alwaysShowBingoTab = false; + + @Expose + @ConfigOption( + name = "Show Pronouns in /pv", + desc = "Shows the pronouns of a player in /pv. Data sourced from pronoundb.org" + ) + @ConfigEditorBoolean + public boolean showPronounsInPv = BuildFlags.ENABLE_PRONOUNS_IN_PV_BY_DEFAULT; } 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 30ffcdd9..dcbcb9e4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -19,8 +19,6 @@ package io.github.moulberry.notenoughupdates.profileviewer; -import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt; - import com.google.common.base.Splitter; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -30,17 +28,9 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; 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; +import io.github.moulberry.notenoughupdates.util.PronounDB; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.gui.FontRenderer; @@ -63,6 +53,19 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; + +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"); @@ -117,7 +120,8 @@ public class BasicPage extends GuiProfileViewerPage { String panoramaIdentifier = "day"; if (SBInfo.getInstance().currentTimeDate != null) { - if (SBInfo.getInstance().currentTimeDate.getHours() <= 6 || SBInfo.getInstance().currentTimeDate.getHours() >= 20) { + if (SBInfo.getInstance().currentTimeDate.getHours() <= 6 || + SBInfo.getInstance().currentTimeDate.getHours() >= 20) { panoramaIdentifier = "night"; } } @@ -133,19 +137,36 @@ public class BasicPage extends GuiProfileViewerPage { Panorama.getPanoramasForLocation(location == null ? "unknown" : location, panoramaIdentifier) ); + if (Utils.isWithinRect(mouseX, mouseY, guiLeft + 23, guiTop + 44, 81, 108)) { + Optional pronounChoice = + GuiProfileViewer.pronouns + .peekValue() + .flatMap(it -> it); // Flatten: First optional is whether it loaded, second optional is whether it was successful + if (pronounChoice.isPresent()) { + PronounDB.PronounChoice pronouns = pronounChoice.get(); + if (pronouns.isConsciousChoice()) { + getInstance().tooltipToDisplay = pronouns.render(); + } + } + } + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_basic); Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST); if (entityPlayer != null && profile.getHypixelProfile() != null) { String playerName = null; if (profile.getHypixelProfile().has("prefix")) { - playerName = Utils.getElementAsString(profile.getHypixelProfile().get("prefix"), "") + " " + entityPlayer.getName(); + playerName = Utils.getElementAsString(profile.getHypixelProfile().get("prefix"), "") + " " + + entityPlayer.getName(); } else { String rank = Utils.getElementAsString( profile.getHypixelProfile().get("rank"), Utils.getElementAsString(profile.getHypixelProfile().get("newPackageRank"), "NONE") ); - String monthlyPackageRank = Utils.getElementAsString(profile.getHypixelProfile().get("monthlyPackageRank"), "NONE"); + String monthlyPackageRank = Utils.getElementAsString( + profile.getHypixelProfile().get("monthlyPackageRank"), + "NONE" + ); if (!rank.equals("YOUTUBER") && !monthlyPackageRank.equals("NONE")) { rank = monthlyPackageRank; } @@ -191,7 +212,13 @@ public class BasicPage extends GuiProfileViewerPage { int x = guiLeft + 63; int y = guiTop + 54; - GuiScreen.drawRect(x - halfRankPrefixLen - 1, y - 1, x + halfRankPrefixLen + 1, y + 8, new Color(0, 0, 0, 64).getRGB()); + GuiScreen.drawRect( + x - halfRankPrefixLen - 1, + y - 1, + x + halfRankPrefixLen + 1, + y + 8, + new Color(0, 0, 0, 64).getRGB() + ); fr.drawString(playerName, x - halfRankPrefixLen, y, 0, true); } @@ -200,7 +227,8 @@ public class BasicPage extends GuiProfileViewerPage { long networth = profile.getNetWorth(profileId); if (networth > 0) { Utils.drawStringCentered( - EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(networth), + EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(networth), fr, guiLeft + 63, guiTop + 38, @@ -211,31 +239,38 @@ public class BasicPage extends GuiProfileViewerPage { double networthInCookies = ( networth / - NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("BOOSTER_COOKIE").get("avg_buy").getAsDouble() + NotEnoughUpdates.INSTANCE.manager.auctionManager + .getBazaarInfo("BOOSTER_COOKIE") + .get("avg_buy") + .getAsDouble() ); String networthIRLMoney = Long.toString(Math.round(((networthInCookies * 325) / 675) * 4.99)); if ( mouseX > guiLeft + 8 && - mouseX < guiLeft + 8 + fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)) + mouseX < guiLeft + 8 + fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)) ) { if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + fr.FONT_HEIGHT) { getInstance().tooltipToDisplay = new ArrayList<>(); getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Net worth in IRL money: " + - EnumChatFormatting.DARK_GREEN + - "$" + - EnumChatFormatting.GOLD + - networthIRLMoney + "Net worth in IRL money: " + + EnumChatFormatting.DARK_GREEN + + "$" + + EnumChatFormatting.GOLD + + networthIRLMoney ); getInstance().tooltipToDisplay.add(""); if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { 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"); - getInstance().tooltipToDisplay.add(EnumChatFormatting.RED + "for cookies using gems, then the price of gems"); - getInstance().tooltipToDisplay.add(EnumChatFormatting.RED + "is where we get the amount of IRL money you"); - getInstance().tooltipToDisplay.add(EnumChatFormatting.RED + "theoretically have on skyblock in net worth."); + getInstance().tooltipToDisplay.add( + EnumChatFormatting.RED + "price of booster cookies on bazaar and the price"); + getInstance().tooltipToDisplay.add( + EnumChatFormatting.RED + "for cookies using gems, then the price of gems"); + getInstance().tooltipToDisplay.add( + EnumChatFormatting.RED + "is where we get the amount of IRL money you"); + getInstance().tooltipToDisplay.add( + EnumChatFormatting.RED + "theoretically have on skyblock in net worth."); } else { getInstance().tooltipToDisplay.add(EnumChatFormatting.GRAY + "[SHIFT for Info]"); } @@ -245,7 +280,8 @@ public class BasicPage extends GuiProfileViewerPage { } } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } if (status != null) { @@ -261,9 +297,17 @@ public class BasicPage extends GuiProfileViewerPage { NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("POTATO_CROWN") ); potato_crown.addEnchantment(Enchantment.unbreaking, 1656638942); // this number may be useful - Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(new ItemStack(Items.potato), guiLeft + 35, guiTop + 160); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI( + new ItemStack(Items.potato), + guiLeft + 35, + guiTop + 160 + ); Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(potato_crown, guiLeft + 50, guiTop + 162); - Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(new ItemStack(Items.potato), guiLeft + 63, guiTop + 160); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI( + new ItemStack(Items.potato), + guiLeft + 63, + guiTop + 160 + ); } else if (online) { locationStr = NotEnoughUpdates.INSTANCE.navigation.getNameForAreaModeOrUnknown(location); } @@ -370,7 +414,8 @@ public class BasicPage extends GuiProfileViewerPage { }, false ); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } GlStateManager.color(1, 1, 1, 1); @@ -388,9 +433,9 @@ public class BasicPage extends GuiProfileViewerPage { int x = guiLeft + 20; float y = guiTop + - 82 + - 15 * - (float) Math.sin(((getInstance().currentTime - getInstance().startTime) / 800f) % (2 * Math.PI)); + 82 + + 15 * + (float) Math.sin(((getInstance().currentTime - getInstance().startTime) / 800f) % (2 * Math.PI)); GlStateManager.translate(x, y, 0); ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false); @@ -410,7 +455,14 @@ public class BasicPage extends GuiProfileViewerPage { } } if (entityPlayer != null) { - drawEntityOnScreen(guiLeft + 63, guiTop + 128 + 7, 36, guiLeft + 63 - mouseX, guiTop + 129 - mouseY, entityPlayer); + drawEntityOnScreen( + guiLeft + 63, + guiTop + 128 + 7, + 36, + guiLeft + 63 - mouseX, + guiTop + 129 - mouseY, + entityPlayer + ); } PlayerStats.Stats stats = profile.getStats(profileId); @@ -426,7 +478,12 @@ public class BasicPage extends GuiProfileViewerPage { 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); + 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, @@ -445,49 +502,49 @@ public class BasicPage extends GuiProfileViewerPage { getInstance() .tooltipToDisplay.add( EnumChatFormatting.GRAY + - "Base " + - split.get(1) + - ": " + - EnumChatFormatting.GREEN + - base + - " " + - split.get(0) + "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) + "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) + "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) + "Final " + + split.get(1) + + ": +" + + EnumChatFormatting.RED + + finalStat + + " " + + split.get(0) ); } } @@ -551,17 +608,18 @@ public class BasicPage extends GuiProfileViewerPage { getInstance().tooltipToDisplay = new ArrayList<>(); getInstance().tooltipToDisplay.add(skillName); if (skyblockInfo.get(entry.getKey()).maxed) { - getInstance().tooltipToDisplay.add(EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.GOLD + "MAXED!"); + getInstance().tooltipToDisplay.add( + EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.GOLD + "MAXED!"); } else { int maxXp = (int) skyblockInfo.get(entry.getKey()).maxXpForLevel; getInstance() .tooltipToDisplay.add( EnumChatFormatting.GRAY + - "Progress: " + - EnumChatFormatting.DARK_PURPLE + - GuiProfileViewer.shortNumberFormat(Math.round((level % 1) * maxXp), 0) + - "/" + - GuiProfileViewer.shortNumberFormat(maxXp, 0) + "Progress: " + + EnumChatFormatting.DARK_PURPLE + + GuiProfileViewer.shortNumberFormat(Math.round((level % 1) * maxXp), 0) + + "/" + + GuiProfileViewer.shortNumberFormat(maxXp, 0) ); } String totalXpS = GuiProfileViewer.numberFormat.format((int) skyblockInfo.get(entry.getKey()).totalXp); @@ -605,23 +663,29 @@ public class BasicPage extends GuiProfileViewerPage { return ( uuidStr.substring(0, 8) + - "-" + - uuidStr.substring(8, 12) + - "-" + - uuidStr.substring(12, 16) + - "-" + - uuidStr.substring(16, 20) + - "-" + - uuidStr.substring(20, 32) + "-" + + uuidStr.substring(8, 12) + + "-" + + uuidStr.substring(12, 16) + + "-" + + uuidStr.substring(16, 20) + + "-" + + uuidStr.substring(20, 32) ); } - private void renderWeight(int mouseX, int mouseY, Map skyblockInfo, JsonObject profileInfo) { + private void renderWeight( + int mouseX, + int mouseY, + Map skyblockInfo, + JsonObject profileInfo + ) { if (skyblockInfo == null) { return; } - if (Constants.WEIGHT == null || Utils.getElement(Constants.WEIGHT, "lily.skills.overall") == null || !Utils.getElement(Constants.WEIGHT, "lily.skills.overall").isJsonPrimitive()) { + if (Constants.WEIGHT == null || Utils.getElement(Constants.WEIGHT, "lily.skills.overall") == null || + !Utils.getElement(Constants.WEIGHT, "lily.skills.overall").isJsonPrimitive()) { Utils.showOutdatedRepoNotification(); return; } @@ -635,9 +699,9 @@ public class BasicPage extends GuiProfileViewerPage { Utils.drawStringCentered( EnumChatFormatting.GREEN + - "Senither Weight: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())), + "Senither Weight: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())), fr, guiLeft + 63, guiTop + 18, @@ -646,7 +710,8 @@ public class BasicPage extends GuiProfileViewerPage { ); int textWidth = fr.getStringWidth( - "Senither Weight: " + GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())) + "Senither Weight: " + + GuiProfileViewer.numberFormat.format(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) { @@ -654,34 +719,40 @@ public class BasicPage extends GuiProfileViewerPage { getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Skills: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getSkillsWeight().getWeightStruct().getRaw())) + "Skills: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight + .getSkillsWeight() + .getWeightStruct() + .getRaw())) ); getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Slayer: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getSlayerWeight().getWeightStruct().getRaw())) + "Slayer: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight + .getSlayerWeight() + .getWeightStruct() + .getRaw())) ); getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Dungeons: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format( - roundToNearestInt(senitherWeight.getDungeonsWeight().getWeightStruct().getRaw()) - ) + "Dungeons: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format( + roundToNearestInt(senitherWeight.getDungeonsWeight().getWeightStruct().getRaw()) + ) ); } } Utils.drawStringCentered( EnumChatFormatting.GREEN + - "Lily Weight: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())), + "Lily Weight: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())), fr, guiLeft + 63, guiTop + 28, @@ -698,23 +769,32 @@ public class BasicPage extends GuiProfileViewerPage { getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Skills: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getSkillsWeight().getWeightStruct().getRaw())) + "Skills: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight + .getSkillsWeight() + .getWeightStruct() + .getRaw())) ); getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Slayer: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getSlayerWeight().getWeightStruct().getRaw())) + "Slayer: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight + .getSlayerWeight() + .getWeightStruct() + .getRaw())) ); getInstance() .tooltipToDisplay.add( EnumChatFormatting.GREEN + - "Dungeons: " + - EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getDungeonsWeight().getWeightStruct().getRaw())) + "Dungeons: " + + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight + .getDungeonsWeight() + .getWeightStruct() + .getRaw())) ); } } 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 758ea6e8..3cbd944d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java @@ -22,7 +22,9 @@ package io.github.moulberry.notenoughupdates.profileviewer; 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.util.Constants; +import io.github.moulberry.notenoughupdates.util.PronounDB; import io.github.moulberry.notenoughupdates.util.Utils; import java.time.Instant; import java.time.LocalDateTime; @@ -32,6 +34,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TimeZone; import java.util.TreeMap; @@ -113,9 +116,10 @@ public class ExtraPage extends GuiProfileViewerPage { ); } } + JsonObject guildInfo = profile.getGuildInformation(null); + boolean shouldRenderGuild = guildInfo != null && guildInfo.has("name"); { - JsonObject guildInfo = profile.getGuildInformation(null); - if (guildInfo != null && guildInfo.has("name")) { + if (shouldRenderGuild) { Utils.renderAlignedString( EnumChatFormatting.AQUA + "Guild", EnumChatFormatting.WHITE + guildInfo.get("name").getAsString(), @@ -125,6 +129,15 @@ public class ExtraPage extends GuiProfileViewerPage { ); } } + { + GuiProfileViewer.pronouns.peekValue().flatMap(it -> it).ifPresent(choice -> Utils.renderAlignedString( + EnumChatFormatting.GREEN + "Pronouns", + EnumChatFormatting.WHITE + String.join(" / ", choice.render()), + guiLeft + xStart, + guiTop + yStartTop + yOffset * (shouldRenderGuild ? 5 : 4), + 76 + )); + } float fairySouls = Utils.getElementAsFloat(Utils.getElement(profileInfo, "fairy_souls_collected"), 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 09eed1cf..59373952 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -19,7 +19,6 @@ package io.github.moulberry.notenoughupdates.profileviewer; -import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -29,7 +28,9 @@ import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.profileviewer.bestiary.BestiaryPage; import io.github.moulberry.notenoughupdates.profileviewer.trophy.TrophyFishPage; +import io.github.moulberry.notenoughupdates.util.AsyncDependencyLoader; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.PronounDB; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; @@ -53,6 +54,7 @@ import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL20; import java.awt.*; +import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -63,6 +65,8 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; +import java.util.UUID; +import java.util.concurren