diff options
9 files changed, 148 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 009d5fef0..2e034c470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,9 +48,12 @@ + Added **Colored Name** - Show the visitor name in the color of the rarity. + Added **Visitor Item Preview** - Show the base type for the required items next to new visitors (Note that some visitors may require any crop) + Added **Teleport Pad Compact Name** - Hide the 'Warp to' and 'No Destination' texts over teleport pads. -+ Added Money per Hour Advanced stats - Show not only Sell Offer price but also Instant Sell price and NPC Sell price (Suggestion: Enable Compact Price as well for this) -+ Added Anita Medal Profit - Helps to identify profitable items to buy at the Anita item shop and potential profit from selling the item at the auction house. -+ Added Composter Compact Display - Displays the compost data from the tab list in a compact form as gui element. ++ Added **Money per Hour Advanced stats** - Show not only Sell Offer price but also Instant Sell price and NPC Sell price (Suggestion: Enable Compact Price as well for this) ++ Added **Anita Medal Profit** - Helps to identify profitable items to buy at the Anita item shop and potential profit from selling the item at the auction house. ++ Added **Composter Compact Display** - Displays the compost data from the tab list in a compact form as gui element. ++ Added **Composter Upgrade Price** - Show the price for the composter upgrade in the lore ++ Added **Highlight Upgrade** - Highlight Upgrades that can be bought right now. ++ Added **Number Composter Upgrades** - Show the number of upgrades in the composter upgrades inventory. ### Features from other Mods diff --git a/FEATURES.md b/FEATURES.md index 1720b90f5..54098e876 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -199,6 +199,9 @@ + **Money per Hour Advanced stats** - Show not only Sell Offer price but also Instant Sell price and NPC Sell price (Suggestion: Enable Compact Price as well for this) + **Anita Medal Profit** - Helps to identify profitable items to buy at the Anita item shop and potential profit from selling the item at the auction house. + **Composter Compact Display** - Displays the compost data from the tab list in a compact form as gui element. ++ **Composter Upgrade Price** - Show the price for the composter upgrade in the lore ++ **Highlight Upgrade** - Highlight Upgrades that can be bought right now. ++ **Number Composter Upgrades** - Show the number of upgrades in the composter upgrades 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 1fcd4eb68..f8db6d0e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -237,6 +237,7 @@ public class SkyHanniMod { loadModule(new GardenTeleportPadCompactName()); loadModule(new AnitaMedalProfit()); loadModule(new ComposterDisplay()); + loadModule(new GardenComposterInventoryFeatures()); 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 1a46c3785..f6879a86d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -164,6 +164,12 @@ public class Garden { public boolean numberCropUpgrades = true; @Expose + @ConfigOption(name = "Composter Upgrades", desc = "Show the number of upgrades in the composter upgrades inventory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 5) + public boolean numberComposterUpgrades = true; + + @Expose @ConfigOption(name = "Crop Milestones", desc = "") @ConfigEditorAccordion(id = 6) public boolean cropMilestones = false; @@ -686,6 +692,24 @@ public class Garden { public boolean composterDisplayEnabled = true; @Expose + @ConfigOption( + name = "Upgrade Price", + desc = "Show the price for the composter upgrade in the lore." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 17) + public boolean composterUpgradePrice = true; + + @Expose + @ConfigOption( + name = "Highlight Upgrade", + desc = "Highlight Upgrades that can be bought right now." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 17) + public boolean composterHighLightUpgrade = true; + + @Expose public Position composterDisplayPos = new Position(-363, 13, false, true); @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt new file mode 100644 index 000000000..a14d5ac39 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenComposterInventoryFeatures.kt @@ -0,0 +1,82 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GardenComposterInventoryFeatures { + val config get() = SkyHanniMod.feature.garden + + @SubscribeEvent + fun onTooltip(event: ItemTooltipEvent) { + if (!GardenAPI.inGarden()) return + if (!config.composterUpgradePrice) return + + if (InventoryUtils.openInventoryName() != "Composter Upgrades") return + + var next = false + val list = event.toolTip + var i = -1 + var indexFullCost = 0 + var fullPrice = 0.0 + var amountItems = 0 + for (originalLine in list) { + i++ + val line = originalLine.substring(4) + if (line == "§7Upgrade Cost:") { + next = true + indexFullCost = i + continue + } + + if (next) { + if (line.endsWith(" Copper")) continue + if (line == "") break + val (itemName, amount) = ItemUtils.readItemAmount(line) + if (itemName == null) { + LorenzUtils.error("§c[SkyHanni] Could not read item '$line'") + continue + } + val lowestBin = NEUItems.getPrice(NEUItems.getInternalName(itemName)) + val price = lowestBin * amount + fullPrice += price + val format = NumberUtil.format(price) + list[i] = list[i] + " §7(§6$format§7)" + amountItems++ + } + } + + if (amountItems > 1) { + val format = NumberUtil.format(fullPrice) + list[indexFullCost] = list[indexFullCost] + " §7(§6$format§7)" + } + } + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.composterHighLightUpgrade) return + + if (InventoryUtils.openInventoryName() == "Composter Upgrades") { + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + + 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 == "§eClick to upgrade!" }) { + slot highlight LorenzColor.GOLD + } + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt index 6655fdf10..76770e182 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern @@ -12,6 +13,8 @@ class GardenInventoryNumbers { private var patternTierProgress = Pattern.compile("§7Progress to Tier (.*): §e(?:.*)") private var patternUpgradeTier = Pattern.compile("§7Current Tier: §e(.*)§7/§a.*") + private val patternComposterUpgrades = + Pattern.compile("§a(?:Composter Speed|Multi Drop|Fuel Cap|Organic Matter Cap|Cost Reduction) ?(.*)?") @SubscribeEvent fun onRenderItemTip(event: RenderItemTipEvent) { @@ -23,7 +26,6 @@ class GardenInventoryNumbers { event.stack.getLore() .map { patternTierProgress.matcher(it) } .filter { it.matches() } - .map { it.group(1).romanToDecimalIfNeeded() - 1 } .forEach { event.stackTip = "" + it } } @@ -37,5 +39,19 @@ class GardenInventoryNumbers { .map { it.group(1) } .forEach { event.stackTip = "" + it } } + + if (InventoryUtils.openInventoryName() == "Composter Upgrades") { + if (!SkyHanniMod.feature.garden.numberComposterUpgrades) return + + event.stack.name?.let { + val matcher = patternComposterUpgrades.matcher(it) + if (matcher.matches()) { + event.stackTip = if (matcher.groupCount() != 0) { + val group = matcher.group(1) + "" + group.romanToDecimalIfNeeded() + } else "0" + } + } + } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt index 634aa5758..063f17612 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBLockLevelGuideHelper.kt @@ -29,9 +29,7 @@ class SkyBLockLevelGuideHelper { if (slot.slotNumber != slot.slotIndex) continue val name = slot.stack?.name ?: continue - if (name.startsWith("§a✔")) { -// slot highlight LorenzColor.GREEN - } else if (name.startsWith("§c✖")) { + if (name.startsWith("§c✖")) { slot highlight LorenzColor.RED } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index bbd420743..cf0192ca4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -137,7 +137,8 @@ object ItemUtils { fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName() == "SKYBLOCK_MENU" - private val pattern = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?") + private val patternInFront = Pattern.compile("(?: *§8(?<amount>[\\d,]+)x )?(?<name>.*)") + private val patternBehind = Pattern.compile("(?<name>(?:['\\w-]+ ?)+)(?:§8x(?<amount>[\\d,]+))?") private val itemAmountCache = mutableMapOf<String, Pair<String, Int>>() @@ -145,10 +146,20 @@ object ItemUtils { if (itemAmountCache.containsKey(input)) { return itemAmountCache[input]!! } + + var matcher = patternInFront.matcher(input) + if (matcher.matches()) { + val itemName = matcher.group("name") + val amount = matcher.group("amount")?.replace(",", "")?.toInt() ?: 1 + val pair = Pair(itemName, amount) + itemAmountCache[input] = pair + return pair + } + var string = input.trim() val color = string.substring(0, 2) string = string.substring(2) - val matcher = pattern.matcher(string) + matcher = patternBehind.matcher(string) if (!matcher.matches()) return Pair(null, 0) val itemName = color + matcher.group("name").trim() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 8e9b9de9e..921229e05 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -62,6 +62,7 @@ object LorenzUtils { } fun error(message: String) { + println("error: '$message'") internalChat("§c$message") } |