From 92b52ca61f8786a89c11eaa1d9c0ac1a66c6c2d8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 13:37:58 +0100 Subject: Show new visitors and fixed bugs. --- .../features/garden/GardenVisitorFeatures.kt | 84 +++++++++++++++------- .../skyhanni/features/garden/GardenVisitorTimer.kt | 6 +- 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 06dbd10ab..3d58a9714 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -2,10 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.PacketEvent -import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -16,7 +13,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.network.play.client.C02PacketUseEntity -import net.minecraft.network.play.server.S13PacketDestroyEntities import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -70,17 +66,33 @@ class GardenVisitorFeatures { display.clear() val requiredItems = mutableMapOf() - for ((_, visitor) in visitors) { - for ((itemName, amount) in visitor.items) { + val newVisitors = mutableListOf() + for ((visitorName, visitor) in visitors) { + val items = visitor.items + if (items.isEmpty()) { + newVisitors.add(visitorName) + } + for ((itemName, amount) in items) { val old = requiredItems.getOrDefault(itemName, 0) requiredItems[itemName] = old + amount } } - if (requiredItems.isEmpty()) return - - display.add("Visitor Items Needed:") - for ((name, amount) in requiredItems) { - display.add(" -$name §8x$amount") + if (requiredItems.isNotEmpty()) { + display.add("Visitor items needed:") + for ((name, amount) in requiredItems) { + display.add(" -$name §8x$amount") + } + } + if (newVisitors.isNotEmpty()) { + if (requiredItems.isNotEmpty()) { + display.add("") + } + val amount = newVisitors.size + val visitorLabel = if (amount == 1) "visitor" else "visitors" + display.add("$amount new $visitorLabel:") + for (visitor in newVisitors) { + display.add(" -$visitor") + } } } @@ -158,6 +170,39 @@ class GardenVisitorFeatures { } } + @SubscribeEvent + fun onTick(event: TabListUpdateEvent) { + if (!isEnabled()) return + var found = false + val visitorsInTab = mutableListOf() + for (line in event.tabList) { + if (line.startsWith("§b§lVisitors:")) { + found = true + continue + } + if (found) { + if (line.isEmpty()) { + found = false + continue + } + val name = line.substring(3) + visitorsInTab.add(name) + } + } + if (visitors.keys.removeIf { it !in visitorsInTab }) { + println("removed an npc") + update() + } + for (name in visitorsInTab) { + if (!visitors.containsKey(name)) { + visitors[name] = Visitor(-1) + // todo notification? (check world age first) + println("found an npc: '$name'") + update() + } + } + } + private fun checkVisitorsReady() { for (visitor in visitors.values) { var ready = true @@ -181,21 +226,6 @@ class GardenVisitorFeatures { } } - @SubscribeEvent - fun onReceiveEvent(event: PacketEvent.ReceiveEvent) { - val packet = event.packet - if (packet is S13PacketDestroyEntities) { - for (entityID in packet.entityIDs) { - for ((name, visitor) in visitors.toMutableMap()) { - if (visitor.entityId == entityID) { - visitors.remove(name) - update() - } - } - } - } - } - // TODO make event @SubscribeEvent fun onSendEvent(event: PacketEvent.SendEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt index d8bbe2d6f..9ca5c4b13 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt @@ -15,6 +15,7 @@ class GardenVisitorTimer { private val patternVisitors = Pattern.compile("§b§lVisitors: §r§f\\((\\d)\\)") private var render = "" private var lastMillis = 0L + private var lastVisitors = 0 @SubscribeEvent fun onTick(event: TabListUpdateEvent) { @@ -36,15 +37,16 @@ class GardenVisitorTimer { } val diff = lastMillis - millis - if (diff == 0L) return + if (diff == 0L && visitorsAmount == lastVisitors) return lastMillis = millis + lastVisitors = visitorsAmount val extraSpeed = if (diff in 1001..10_000) { val factor = diff / 1000 "§f/§e" + TimeUtils.formatDuration(millis / factor) } else "" - val visitorLabel = if (visitorsAmount == 1) "Visitor" else "Visitors" + val visitorLabel = if (visitorsAmount == 1) "visitor" else "visitors" val formatDuration = TimeUtils.formatDuration(millis) render = "§b$visitorsAmount $visitorLabel §f(Next in §e$formatDuration$extraSpeed§f)" } -- cgit From 6a0dfe3d571e7b003873609e1fa7f39cdd5059db Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 13:58:20 +0100 Subject: Show new visitors and fixed bugs. --- CHANGELOG.md | 1 + FEATURES.md | 1 + src/main/java/at/hannibal2/skyhanni/config/features/Garden.java | 6 ++++++ .../hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 8 +++++--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec268ef3..a0e774348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ + Added **Crop Milestone** Number - Show the number of the crop milestone in the inventory. + Added **Crop Upgrades** Number - Show the number of upgrades in the crop upgrades inventory. + Added **Visitor Timer** - Timer when the next visitor will appear, and a number how many visitors are already waiting. ++ Added **Visitor Notification** - Show as title and in chat when a new visitor is visiting your island. ### Features from other Mods > *The following features are only there because I want them when testing SkyHanni features without other mods present.* diff --git a/FEATURES.md b/FEATURES.md index 7a8c1c211..ff1389a80 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -166,6 +166,7 @@ + **Crop Milestone** Number - Show the number of the crop milestone in the inventory. + **Crop Upgrades** Number - Show the number of upgrades in the crop upgrades inventory. + **Visitor Timer** - Timer when the next visitor will appear, and a number how many visitors are already waiting. ++ **Visitor Notification** - Show as title and in chat when a new visitor is visiting your island. ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 967c2487b..78ddb5e37 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -71,6 +71,12 @@ public class Garden { @ConfigAccordionId(id = 3) public boolean visitorNeedsOnlyWhenClose = false; + @Expose + @ConfigOption(name = "Notification", desc = "Show as title and in chat when a new visitor is visiting your island.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean visitorNotification = true; + @Expose @ConfigOption(name = "Highlight Ready", desc = "Highlight the visitor when the required items are in the inventory.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 3d58a9714..c3d26c90f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.* @@ -190,14 +191,15 @@ class GardenVisitorFeatures { } } if (visitors.keys.removeIf { it !in visitorsInTab }) { - println("removed an npc") update() } for (name in visitorsInTab) { if (!visitors.containsKey(name)) { visitors[name] = Visitor(-1) - // todo notification? (check world age first) - println("found an npc: '$name'") + if (SkyHanniMod.feature.garden.visitorNotification) { + SendTitleHelper.sendTitle("§eNew Visitor", 5_000) + LorenzUtils.chat("§e[SkyHanni] $name §eis visiting your garden!") + } update() } } -- cgit From 06812d1fef9875ae704c119b8caa3eb4f15d5066 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:19:20 +0100 Subject: Queue full support --- .../at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 2 ++ .../at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index c3d26c90f..6567397cc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -66,6 +66,8 @@ class GardenVisitorFeatures { private fun update() { display.clear() + if (!SkyHanniMod.feature.garden.visitorNeedsDisplay) return + val requiredItems = mutableMapOf() val newVisitors = mutableListOf() for ((visitorName, visitor) in visitors) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt index 9ca5c4b13..6f39c3b63 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt @@ -23,11 +23,14 @@ class GardenVisitorTimer { var visitorsAmount = 0 var millis = 15 * 60_000L + var queueFull = false for (line in event.tabList) { var matcher = patternNextVisitor.matcher(line) if (matcher.matches()) { val rawTime = matcher.group(1) millis = TimeUtils.getMillis(rawTime) + } else if (line == " Next Visitor: §r§c§lQueue Full!") { + queueFull = true } matcher = patternVisitors.matcher(line) @@ -48,7 +51,8 @@ class GardenVisitorTimer { val visitorLabel = if (visitorsAmount == 1) "visitor" else "visitors" val formatDuration = TimeUtils.formatDuration(millis) - render = "§b$visitorsAmount $visitorLabel §f(Next in §e$formatDuration$extraSpeed§f)" + val next = if (queueFull) "§cQueue Full!" else "Next in §e$formatDuration$extraSpeed" + render = "§b$visitorsAmount $visitorLabel §f($next§f)" } @SubscribeEvent -- cgit From 92e7ac557fa10803c9e9dfd0e2eedcd34adc1090 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:20:46 +0100 Subject: Queue full support --- .../at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt index 6f39c3b63..3794e50d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorTimer.kt @@ -49,9 +49,11 @@ class GardenVisitorTimer { "§f/§e" + TimeUtils.formatDuration(millis / factor) } else "" - val visitorLabel = if (visitorsAmount == 1) "visitor" else "visitors" val formatDuration = TimeUtils.formatDuration(millis) - val next = if (queueFull) "§cQueue Full!" else "Next in §e$formatDuration$extraSpeed" + val next = if (queueFull) "§cQueue Full!" else { + "Next in §e$formatDuration$extraSpeed" + } + val visitorLabel = if (visitorsAmount == 1) "visitor" else "visitors" render = "§b$visitorsAmount $visitorLabel §f($next§f)" } -- cgit From c0f98bc777149c8cd361dbb039501cf9f18bb256 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:41:53 +0100 Subject: Added skill and collection level as item stack. --- CHANGELOG.md | 1 + FEATURES.md | 2 +- .../skyhanni/config/features/Inventory.java | 8 +++--- .../inventory/ItemDisplayOverlayFeatures.kt | 30 +++++++++++++++++++++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e774348..d4e6236c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Features + Added **Time to Kill** - Show the time it takes to kill the Slayer boss. ++ Added skill and collection level as item stack. ### Garden Features + Added **Copper Price** - Show copper to coin prices inside the Sky Mart inventory. diff --git a/FEATURES.md b/FEATURES.md index ff1389a80..b04fb1a3b 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -46,7 +46,7 @@ ## Inventory - Not Clickable Items: Mark items gray in your inventory when they are not supposed to be moved in certain GUIs, and make green lines around items that meet that requirement. (in NPC sell inventories, ender chests and backpacks, salvaging in the dungeon hub, player trade, bazaar, action house, accessory bag, sack of sacks, fishing bag, potion bag, chests on the private island, attribute fusion and equipment GUI) - Option to change the gray-out opacity for 'Not Clickable Items'. -- Set stack number for specific items (stars for crimson armor, minion tier, pet level, new year cake, for golden and diamond dungeon heads the floor number, the tier of master skull and master star, kuudra keys) +- Set stack number for specific items (stars for crimson armor, minion tier, pet level, new year cake, for golden and diamond dungeon heads the floor number, the tier of master skull and master star, kuudra keys, skill level, and collection level) - Sack name (show short name of sacks) - Anvil Combine Helper (When putting an enchanted book into the first slot of the anvil, all items with the same enchantment are highlighted in the inventory) - Added compact star counter on all items (not only on items with dungeon stars and master stars but also on crimson armors, cloaks and fishing rods) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index d1a42c252..f4df59580 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.config.core.config.annotations.*; import com.google.gson.annotations.Expose; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.List; public class Inventory { @@ -103,10 +103,12 @@ public class Inventory { "§bMinion Tier", "§bCrimson Armor", "§bWishing Compass", - "§bKuudra Key" + "§bKuudra Key", + "§bSkill Level", + "§bCollection Level" } ) - public List itemNumberAsStackSize = new ArrayList<>(Collections.singletonList(3)); + public List itemNumberAsStackSize = new ArrayList<>(Arrays.asList(3, 9)); @Expose @ConfigOption(name = "Sack Name", desc = "Show an abbreviation of the Sack name.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index a8825354b..2fe34d105 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -6,8 +6,10 @@ import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils.between import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -104,7 +106,7 @@ class ItemDisplayOverlayFeatures { } } - if (SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(7)) { + if (SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(8)) { if (name.contains("Kuudra Key")) { return when (name) { "Kuudra Key" -> "§a1" @@ -116,6 +118,32 @@ class ItemDisplayOverlayFeatures { } } } + + if (SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(9)) { + if (InventoryUtils.openInventoryName() == "Your Skills") { + if (item.getLore().any { it.contains("Click to view!") }) { + item.name?.let { + if (!it.contains("Dungeon")) { + val text = it.split(" ").last() + return "" + text.romanToDecimalIfNeeded() + } + } + } + } + } + + if (SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(10)) { + if (InventoryUtils.openInventoryName().endsWith(" Collections")) { + if (item.getLore().any { it.contains("Click to view!") }) { + item.name?.let { + if (it.startsWith("§e")) { + val text = it.split(" ").last() + return "" + text.romanToDecimalIfNeeded() + } + } + } + } + } return "" } -- cgit From 09f580c62ad7abb6eb0a1455f89d48ec1bd04901 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 15:04:40 +0100 Subject: Added Plot Price. --- CHANGELOG.md | 1 + FEATURES.md | 1 + .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 6 +-- .../hannibal2/skyhanni/config/features/Garden.java | 5 +++ .../features/garden/GardenNextPlotPrice.kt | 50 ++++++++++++++++++++++ .../features/garden/GardenVisitorFeatures.kt | 3 +- 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d4e6236c6..0920dc8a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ + Added **Crop Upgrades** Number - Show the number of upgrades in the crop upgrades inventory. + Added **Visitor Timer** - Timer when the next visitor will appear, and a number how many visitors are already waiting. + Added **Visitor Notification** - Show as title and in chat when a new visitor is visiting your island. ++ Added **Plot Price** - Show the price of the plot in coins when inside the Configure Plots inventory. ### Features from other Mods > *The following features are only there because I want them when testing SkyHanni features without other mods present.* diff --git a/FEATURES.md b/FEATURES.md index b04fb1a3b..913a32087 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -167,6 +167,7 @@ + **Crop Upgrades** Number - Show the number of upgrades in the crop upgrades inventory. + **Visitor Timer** - Timer when the next visitor will appear, and a number how many visitors are already waiting. + **Visitor Notification** - Show as title and in chat when a new visitor is visiting your island. ++ **Plot Price** - Show the price of the plot in coins when inside the Configure Plots inventory. ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 52f696542..c07feba3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -23,10 +23,7 @@ import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper; import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder; import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow; import at.hannibal2.skyhanni.features.fishing.*; -import at.hannibal2.skyhanni.features.garden.GardenInventoryNumbers; -import at.hannibal2.skyhanni.features.garden.GardenVisitorFeatures; -import at.hannibal2.skyhanni.features.garden.GardenVisitorTimer; -import at.hannibal2.skyhanni.features.garden.SkyMartBestProfit; +import at.hannibal2.skyhanni.features.garden.*; import at.hannibal2.skyhanni.features.inventory.*; import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles; import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown; @@ -206,6 +203,7 @@ public class SkyHanniMod { loadModule(new GardenVisitorFeatures()); loadModule(new GardenInventoryNumbers()); loadModule(new GardenVisitorTimer()); + loadModule(new GardenNextPlotPrice()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 78ddb5e37..b2684880d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -105,4 +105,9 @@ public class Garden { @ConfigEditorBoolean @ConfigAccordionId(id = 4) public boolean numberCropUpgrades = true; + + @Expose + @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") + @ConfigEditorBoolean + public boolean plotPrice = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt new file mode 100644 index 000000000..0612faaf7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt @@ -0,0 +1,50 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.name +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GardenNextPlotPrice { + + @SubscribeEvent + fun onTooltip(event: ItemTooltipEvent) { + if (!isEnabled()) return + if (!SkyHanniMod.feature.garden.plotPrice) return + + if (InventoryUtils.openInventoryName() != "Configure Plots") return + + val name = event.itemStack.name ?: return + if (!name.startsWith("§ePlot")) return + + var next = false + val list = event.toolTip + var i = -1 + for (l in list) { + i++ + val line = l.substring(4) + if (line.contains("Cost")) { + next = true + continue + } + + if (next) { + val (itemName, amount) = ItemUtils.readItemAmount(line) + if (itemName != null) { + val internalName = NEUItems.getInternalNameByName(itemName) + val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager + val lowestBin = auctionManager.getBazaarOrBin(internalName, false) + val price = lowestBin * amount + val format = NumberUtil.format(price) + list[i] = list[i] + " §f(§6$format§f)" + } + break + } + } + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 6567397cc..b20c699cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -15,7 +15,6 @@ import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.network.play.client.C02PacketUseEntity import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -101,7 +100,7 @@ class GardenVisitorFeatures { var tick = 0 - @SubscribeEvent(priority = EventPriority.LOW) + @SubscribeEvent fun onTooltip(event: ItemTooltipEvent) { if (!isEnabled()) return if (!nearby) return -- cgit From 872b7da36b75fe5772616941b2adf4049a40a351 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 15:53:53 +0100 Subject: Added Auction Highlighter. --- CHANGELOG.md | 1 + FEATURES.md | 1 + .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../skyhanni/config/features/Inventory.java | 6 ++++ .../skyhanni/features/bazaar/BazaarOrderHelper.kt | 3 ++ .../features/inventory/AuctionsHighlighter.kt | 36 ++++++++++++++++++++++ 6 files changed, 48 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 0920dc8a5..f42e652d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features + Added **Time to Kill** - Show the time it takes to kill the Slayer boss. + Added skill and collection level as item stack. ++ Added **Auction Highlighter** - Highlight own items that are sold in green. ### Garden Features + Added **Copper Price** - Show copper to coin prices inside the Sky Mart inventory. diff --git a/FEATURES.md b/FEATURES.md index 913a32087..59fbfe4cf 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -57,6 +57,7 @@ + Show the type of stats for the tuning point templates. + Highlight depleted Bonzo's Masks in your inventory. + Highlight stuff that is missing in the skyblock level guide inventory. ++ **Auction Highlighter** - Highlight own items that are sold in green. ## Item Abilities - Show the cooldown of items in the inventory. diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index c07feba3b..78644dad0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -116,6 +116,7 @@ public class SkyHanniMod { //features loadModule(new BazaarOrderHelper()); + loadModule(new AuctionsHighlighter()); loadModule(new ChatFilter()); loadModule(new PlayerChatModifier()); loadModule(new DungeonChatFilter()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index f4df59580..912e09531 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -137,4 +137,10 @@ public class Inventory { desc = "Highlight stuff that is missing in the skyblock level guide inventory.") @ConfigEditorBoolean public boolean highlightMissingSkyBlockLevelGuide = true; + + @Expose + @ConfigOption(name = "Highlight Auctions", + desc = "Highlight own items that are sold in green.") + @ConfigEditorBoolean + public boolean highlightAuctions = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt index 7f0e86598..bd9ef0a79 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOrderHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -23,8 +24,10 @@ class BazaarOrderHelper { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return if (!SkyHanniMod.feature.bazaar.orderHelper) return if (event.gui !is GuiChest) return + val guiChest = event.gui val chest = guiChest.inventorySlots as ContainerChest val inventoryName = chest.getInventoryName() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt new file mode 100644 index 000000000..ba1d3a680 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -0,0 +1,36 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class AuctionsHighlighter { + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.inventory.highlightAuctions) return + if (event.gui !is GuiChest) return + + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + if (chest.getInventoryName() != "Manage Auctions") return + + for (slot in chest.inventorySlots) { + if (slot == null) continue + if (slot.slotNumber != slot.slotIndex) continue + val stack = slot.stack ?: continue + + if (stack.getLore().any { it == "§7Status: §aSold!" }) { + slot highlight LorenzColor.GREEN + } + } + } +} \ No newline at end of file -- cgit From fabfab64dd11b1e00daff536aeca225cb53b654f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 22 Feb 2023 14:22:05 +0100 Subject: Auction Highlighter now shows expired items as well. --- CHANGELOG.md | 2 +- FEATURES.md | 2 +- src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java | 2 +- .../at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f42e652d9..84c266ee7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Features + Added **Time to Kill** - Show the time it takes to kill the Slayer boss. + Added skill and collection level as item stack. -+ Added **Auction Highlighter** - Highlight own items that are sold in green. ++ Added **Auction Highlighter** - Highlight own items that are sold in green and that are expired in red. ### Garden Features + Added **Copper Price** - Show copper to coin prices inside the Sky Mart inventory. diff --git a/FEATURES.md b/FEATURES.md index 59fbfe4cf..ad7556efb 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -57,7 +57,7 @@ + Show the type of stats for the tuning point templates. + Highlight depleted Bonzo's Masks in your inventory. + Highlight stuff that is missing in the skyblock level guide inventory. -+ **Auction Highlighter** - Highlight own items that are sold in green. ++ **Auction Highlighter** - Highlight own items that are sold in green and that are expired in red. ## Item Abilities - Show the cooldown of items in the inventory. diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java index 912e09531..5f2b46ca8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Inventory.java @@ -140,7 +140,7 @@ public class Inventory { @Expose @ConfigOption(name = "Highlight Auctions", - desc = "Highlight own items that are sold in green.") + desc = "Highlight own items that are sold in green and that are expired in red.") @ConfigEditorBoolean public boolean highlightAuctions = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt index ba1d3a680..453707c5b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -28,9 +28,13 @@ class AuctionsHighlighter { if (slot.slotNumber != slot.slotIndex) continue val stack = slot.stack ?: continue - if (stack.getLore().any { it == "§7Status: §aSold!" }) { + val lore = stack.getLore() + if (lore.any { it == "§7Status: §aSold!" }) { slot highlight LorenzColor.GREEN } + if (lore.any { it == "§7Status: §cExpired!" }) { + slot highlight LorenzColor.RED + } } } } \ No newline at end of file -- cgit From 3e8adba4d3605549f9d21752fb3bf6103e99eeaf Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:52:52 +0100 Subject: Show additionally the bin price and copper price for every item. --- .../java/at/hannibal2/skyhanni/config/features/Garden.java | 6 ++++++ .../skyhanni/features/garden/SkyMartBestProfit.kt | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index b2684880d..2343773de 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -17,6 +17,12 @@ public class Garden { @ConfigAccordionId(id = 0) public boolean skyMartCopperPrice = true; + @Expose + @ConfigOption(name = "Advanced stats", desc = "Show additionally the bin price and copper price for every item.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean skyMartCopperPriceAdvancedStats = false; + @Expose @ConfigOption(name = "Copper Price Position", desc = "") @ConfigEditorButton(runnableId = "skyMartCopperPrice", buttonText = "Edit") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt index ead2f6832..83d46e1ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt @@ -22,6 +22,7 @@ class SkyMartBestProfit { private val pattern = Pattern.compile("§c(.*) Copper") private val display = mutableListOf() + private val config get() = SkyHanniMod.feature.garden @SubscribeEvent fun onChatPacket(event: InventoryOpenEvent) { @@ -53,14 +54,17 @@ class SkyMartBestProfit { name = "§9Sunder I" } - val pair = Pair("$name§f:", "§6§l$perFormat §f(§6$priceFormat §f/ §c$amountFormat copper§f)") + val advancedStats = if (config.skyMartCopperPriceAdvancedStats) { + " §f(§6$priceFormat §f/ §c$amountFormat Copper§f)" + } else "" + val pair = Pair("$name§f:", "§6§l$perFormat$advancedStats") priceMap[pair] = factor } } display.clear() - display.add("Coins per §ccopper§f:") + display.add("Coins per §cCopper§f:") display.add(" ") val keys = priceMap.sortedDesc().keys @@ -84,12 +88,10 @@ class SkyMartBestProfit { @SubscribeEvent fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) { if (isEnabled()) { - SkyHanniMod.feature.garden.skyMartCopperPricePos.renderStrings(display) + config.skyMartCopperPricePos.renderStrings(display) } } private fun isEnabled() = - LorenzUtils.inSkyBlock && - SkyHanniMod.feature.garden.skyMartCopperPrice && - LorenzUtils.skyBlockIsland == IslandType.GARDEN + LorenzUtils.inSkyBlock && config.skyMartCopperPrice && LorenzUtils.skyBlockIsland == IslandType.GARDEN } \ No newline at end of file -- cgit From fdc48248991d503b7d6f58507f4f5069a81f7b4b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 24 Feb 2023 17:04:19 +0100 Subject: Using the newest version of neu. --- build.gradle.kts | 4 +- .../skyhanni/utils/ItemResolutionQuery.java | 200 --------------------- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 4 +- .../java/at/hannibal2/skyhanni/utils/NEUItems.kt | 20 +-- 4 files changed, 7 insertions(+), 221 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/utils/ItemResolutionQuery.java diff --git a/build.gradle.kts b/build.gradle.kts index fcf749b24..3121ed4fa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,8 +62,8 @@ dependencies { // If you don't want to log in with your real minecraft account, remove this line modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0") - implementation("com.github.notenoughupdates:notenoughupdates:e603cf2:all") - devenvMod("com.github.notenoughupdates:notenoughupdates:e603cf2:all") + implementation("com.github.notenoughupdates:notenoughupdates:df945f9:all") + devenvMod("com.github.notenoughupdates:notenoughupdates:df945f9:all") } // Minecraft configuration: diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemResolutionQuery.java b/src/main/java/at/hannibal2/skyhanni/utils/ItemResolutionQuery.java deleted file mode 100644 index 548db2f08..000000000 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemResolutionQuery.java +++ /dev/null @@ -1,200 +0,0 @@ -package at.hannibal2.skyhanni.utils; - -import at.hannibal2.skyhanni.config.ConfigManager; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.init.Items; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ItemResolutionQuery { - - private static final Pattern ENCHANTED_BOOK_NAME_PATTERN = Pattern.compile("^((?:§.)+)([^§]+) ([IVXL]+)$"); - private static final String EXTRA_ATTRIBUTES = "ExtraAttributes"; - private static final List PET_RARITIES = Arrays.asList( - "COMMON", - "UNCOMMON", - "RARE", - "EPIC", - "LEGENDARY", - "MYTHIC" - ); - private ItemStack stack; - private Item itemType; - private int stackSize = -1; - private Gui guiContext; - private String knownInternalName; - - public ItemResolutionQuery withItemStack(ItemStack stack) { - if (stack == null) return this; - this.itemType = stack.getItem(); - this.stack = stack; - this.stackSize = stack.stackSize; - return this; - } - - public ItemResolutionQuery withGuiContext(Gui gui) { - this.guiContext = gui; - return this; - } - - public ItemResolutionQuery withCurrentGuiContext() { - this.guiContext = Minecraft.getMinecraft().currentScreen; - return this; - } - - public ItemResolutionQuery withKnownInternalName(String knownInternalName) { - this.knownInternalName = knownInternalName; - return this; - } - - @Nullable - public String resolveInternalName() { - if (knownInternalName != null) { - return knownInternalName; - } - String resolvedName = resolveFromSkyblock(); - if (resolvedName == null) { - resolvedName = resolveContextualName(); - } else { - switch (resolvedName.intern()) { - case "PET": - resolvedName = resolvePetName(); - break; - case "RUNE": - resolvedName = resolveRuneName(); - break; - case "ENCHANTED_BOOK": - resolvedName = resolveEnchantedBookNameFromNBT(); - break; - case "PARTY_HAT_CRAB": - resolvedName = resolveCrabHatName(); - break; - } - } - - return resolvedName; - } - - // - private boolean isBazaar(IInventory chest) { - if (chest.getDisplayName().getFormattedText().startsWith("Bazaar ➜ ")) { - return true; - } - int bazaarSlot = chest.getSizeInventory() - 5; - if (bazaarSlot < 0) return false; - ItemStack stackInSlot = chest.getStackInSlot(bazaarSlot); - if (stackInSlot == null || stackInSlot.stackSize == 0) return false; - // NBT lore, we do not care about rendered lore - List lore = ItemUtils.INSTANCE.getLore(stackInSlot); - return lore.contains("§7To Bazaar"); - } - - private String resolveContextualName() { - if (!(guiContext instanceof GuiChest)) { - return null; - } - GuiChest chest = (GuiChest) guiContext; - ContainerChest inventorySlots = (ContainerChest) chest.inventorySlots; - String guiName = inventorySlots.getLowerChestInventory().getDisplayName().getUnformattedText(); - boolean isOnBazaar = isBazaar(inventorySlots.getLowerChestInventory()); - String displayName = ItemUtils.INSTANCE.getName(stack); - if (displayName == null) return null; - if (itemType == Items.enchanted_book && isOnBazaar) { - return resolveEnchantmentByName(displayName); - } - if (displayName.endsWith("Enchanted Book") && guiName.startsWith("Superpairs")) { - for (String loreLine : ItemUtils.INSTANCE.getLore(stack)) { - String enchantmentIdCandidate = resolveEnchantmentByName(loreLine); - if (enchantmentIdCandidate != null) return enchantmentIdCandidate; - } - return null; - } - return null; - } - - private String getDisplayName(NBTTagCompound compound) { - if (compound == null) return null; - String string = compound.getCompoundTag("display").getString("Name"); - if (string == null || string.isEmpty()) - return null; - return string; - } - - private String resolveEnchantmentByName(String name) { - Matcher matcher = ENCHANTED_BOOK_NAME_PATTERN.matcher(name); - if (!matcher.matches()) return null; - String format = matcher.group(1).toLowerCase(Locale.ROOT); - String enchantmentName = matcher.group(2).trim(); - String romanLevel = matcher.group(3); - boolean ultimate = (format.contains("§l")); - - return (ultimate ? "ULTIMATE_" : "") - + enchantmentName.replace(" ", "_").toUpperCase(Locale.ROOT) - + ";" + NumberUtil.INSTANCE.romanToDecimal(romanLevel); - } - - private String resolveCrabHatName() { - String color = getExtraAttributes().getString("party_hat_color"); - return "PARTY_HAT_CRAB_" + color.toUpperCase(Locale.ROOT); - } - - private String resolveEnchantedBookNameFromNBT() { - NBTTagCompound enchantments = getExtraAttributes().getCompoundTag("enchantments"); - String enchantName = IteratorUtils.INSTANCE.getOnlyElement(enchantments.getKeySet(), null); - if (enchantName == null || enchantName.isEmpty()) return null; - return enchantName.toUpperCase(Locale.ROOT) + ";" + enchantments.getInteger(enchantName); - } - - private String resolveRuneName() { - NBTTagCompound runes = getExtraAttributes().getCompoundTag("runes"); - String runeName = IteratorUtils.INSTANCE.getOnlyElement(runes.getKeySet(), null); - if (runeName == null || runeName.isEmpty()) return null; - return runeName.toUpperCase(Locale.ROOT) + "_RUNE;" + runes.getInteger(runeName); - } - - private String resolvePetName() { - String petInfo = getExtraAttributes().getString("petInfo"); - if (petInfo == null || petInfo.isEmpty()) return null; - try { - JsonObject petInfoObject = ConfigManager.Companion.getGson().fromJson(petInfo, JsonObject.class); - String petId = petInfoObject.get("type").getAsString(); - String petTier = petInfoObject.get("tier").getAsString(); - int rarityIndex = PET_RARITIES.indexOf(petTier); - return petId.toUpperCase(Locale.ROOT) + ";" + rarityIndex; - } catch (JsonParseException | ClassCastException ex) { - /* This happens if Hypixel changed the pet json format; - I still log this exception, since this case *is* exceptional and cannot easily be recovered from */ - ex.printStackTrace(); - return null; - } - } - - private NBTTagCompound getExtraAttributes() { - NBTTagCompound compound = stack.getTagCompound(); - if (compound == null) return new NBTTagCompound(); - return compound.getCompoundTag(EXTRA_ATTRIBUTES); - } - - private String resolveFromSkyblock() { - String internalName = getExtraAttributes().getString("id"); - if (internalName == null || internalName.isEmpty()) return null; - return internalName.toUpperCase(Locale.ROOT); - } - - // - -} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 00ffdaefd..714adcec4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -4,6 +4,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.GsonBuilder import com.google.gson.JsonObject +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery import net.minecraft.client.Minecraft import net.minecraft.init.Items import net.minecraft.item.ItemStack @@ -114,7 +116,7 @@ object ItemUtils { } fun ItemStack.getInternalName(): String { - return ItemResolutionQuery() + return ItemResolutionQuery(NotEnoughUpdates.INSTANCE.manager) .withCurrentGuiContext() .withItemStack(this) .resolveInternalName() ?: "" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 8c127fac8..ecbcc9c93 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.utils -import at.hannibal2.skyhanni.utils.StringUtils.removeColor import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Items @@ -10,25 +10,9 @@ import net.minecraft.item.ItemStack object NEUItems { private val itemCache = mutableMapOf() - private val itemNameCache = mutableMapOf() // display name -> internal name fun getInternalNameByName(rawName: String): String? { - val itemName = rawName.removeColor() - if (itemNameCache.containsKey(itemName)) { - return itemNameCache[itemName] - } - val manager = NotEnoughUpdates.INSTANCE.manager - for ((internalId, b) in manager.itemInformation) { - if (b.has("displayname")) { - val name = b.get("displayname").asString - if (name.contains(itemName)) { - itemNameCache[itemName] = internalId - return internalId - } - } - } - - return null + return ItemResolutionQuery.findInternalNameByDisplayName(rawName, false) } fun readItemFromRepo(internalName: String): ItemStack { -- cgit From 9f35d437fdc4282dd5f1c1b7abd1a7c98c244a6b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 24 Feb 2023 17:28:33 +0100 Subject: Used new neu method. --- .../features/garden/GardenNextPlotPrice.kt | 5 +--- .../features/garden/GardenVisitorFeatures.kt | 5 +--- .../skyhanni/features/garden/SkyMartBestProfit.kt | 5 ++-- .../skyhanni/features/minion/MinionCraftHelper.kt | 13 ++++---- .../dailykuudra/DailyKuudraBossHelper.kt | 2 +- .../dailyquest/DailyQuestHelper.kt | 2 +- .../miniboss/DailyMiniBossHelper.kt | 2 +- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 9 +----- .../java/at/hannibal2/skyhanni/utils/NEUItems.kt | 35 ++++++++++++++-------- 9 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt index 0612faaf7..096683798 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt @@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.name -import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -34,9 +33,7 @@ class GardenNextPlotPrice { if (next) { val (itemName, amount) = ItemUtils.readItemAmount(line) if (itemName != null) { - val internalName = NEUItems.getInternalNameByName(itemName) - val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager - val lowestBin = auctionManager.getBazaarOrBin(internalName, false) + val lowestBin = NEUItems.getPrice(NEUItems.getInternalName(itemName)) val price = lowestBin * amount val format = NumberUtil.format(price) list[i] = list[i] + " §f(§6$format§f)" diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index b20c699cd..3f3784951 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.network.play.client.C02PacketUseEntity @@ -126,9 +125,7 @@ class GardenVisitorFeatures { if (i > 1) { val (itemName, amount) = ItemUtils.readItemAmount(line) if (itemName != null) { - val internalName = NEUItems.getInternalNameByName(itemName) - val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager - val lowestBin = auctionManager.getBazaarOrBin(internalName, false) + val lowestBin = NEUItems.getPrice(NEUItems.getInternalName(itemName)) val price = lowestBin * amount totalPrice += price val format = NumberUtil.format(price) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt index 83d46e1ff..2623b63a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt @@ -9,10 +9,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.client.Minecraft import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -33,14 +33,13 @@ class SkyMartBestProfit { val priceMap = mutableMapOf, Double>() - val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager for (stack in inventory.items.values) { for (line in stack.getLore()) { val matcher = pattern.matcher(line) if (!matcher.matches()) continue val internalName = stack.getInternalName() - val lowestBin = auctionManager.getBazaarOrBin(internalName, false) + val lowestBin = NEUItems.getPrice(internalName) if (lowestBin == -1.0) continue val amount = matcher.group(1).replace(",", "").toInt() diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt index 898c7f34c..742a665f9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt @@ -1,12 +1,13 @@ package at.hannibal2.skyhanni.features.minion import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe import io.github.moulberry.notenoughupdates.recipes.NeuRecipe import net.minecraft.client.Minecraft @@ -49,9 +50,7 @@ class MinionCraftHelper { for (item in mainInventory) { val name = item?.name?.removeColor() ?: continue - val rawId = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery() - .withItemStack(item) - .resolveInternalName() ?: continue + val rawId = item.getInternalName() if (name.contains(" Minion ")) { minions[name] = rawId } else { @@ -79,7 +78,7 @@ class MinionCraftHelper { ) { val nextNumber = minionNumber + 1 display.add("$minionName Minion $minionNumber -> $nextNumber") - val recipes: List = NotEnoughUpdates.INSTANCE.manager.getAvailableUsagesFor(minionId) + val recipes: List = NEUItems.manager.getAvailableUsagesFor(minionId) for (recipe in recipes) { if (recipe !is CraftingRecipe) continue val output = recipe.output @@ -100,9 +99,7 @@ class MinionCraftHelper { val needAmount = need * multiplier val have = otherItems.getOrDefault(itemId, 0) val percentage = have.toDouble() / needAmount - val itemName = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery() - .withKnownInternalName(rawId) - .resolveToItemStack()?.name ?: "§cName??§f" + val itemName = NEUItems.getItemStack(rawId).name ?: "§cName??§f" if (percentage >= 1) { display.add(" $itemName§8: §aDONE") display.add(" ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt index e5754e1a7..f93a57551 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt @@ -79,7 +79,7 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH } else { val lineList = mutableListOf() lineList.add(" ") - lineList.add(NEUItems.readItemFromRepo(displayItem)) + lineList.add(NEUItems.getItemStack(displayItem)) lineList.add("$displayName: $result") display.add(lineList) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index 2d7092b1c..abac83c25 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -271,7 +271,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { result.add(" $stateText$type: §f$displayName$multipleText$sacksText") } else { result.add(" $stateText$type: ") - result.add(NEUItems.readItemFromRepo(item)) + result.add(NEUItems.getItemStack(item)) result.add("§f$displayName$multipleText$sacksText") } return result diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index 24aeefdf1..f52d038ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -87,7 +87,7 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel } else { val lineList = mutableListOf() lineList.add(" ") - lineList.add(NEUItems.readItemFromRepo(displayItem)) + lineList.add(NEUItems.getItemStack(displayItem)) lineList.add("$displayName: $result") display.add(lineList) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 714adcec4..62546ee81 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -4,8 +4,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.GsonBuilder import com.google.gson.JsonObject -import io.github.moulberry.notenoughupdates.NotEnoughUpdates -import io.github.moulberry.notenoughupdates.util.ItemRe