diff options
15 files changed, 156 insertions, 140 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index fa2f07038..d17a3dc6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.gui.inventory.GuiChest @@ -22,10 +21,7 @@ class BazaarApi { var inBazaarInventory = false private var currentSearchedItem = "" - fun getBazaarDataByName(name: String): BazaarData? = - NEUItems.getRawInternalNameOrNull(name)?.let { getBazaarDataByInternalName(it) } - - fun getBazaarDataByInternalName(internalName: String) = internalName.asInternalName().getBazaarData() + fun getBazaarDataByName(name: String): BazaarData? = NEUItems.getInternalNameOrNull(name)?.getBazaarData() fun NEUInternalName.getBazaarData() = if (isBazaarItem()) { holder.getData(this) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt index e37d14df8..d6145fb63 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt @@ -2,8 +2,9 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old -import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment +import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getNameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil @@ -39,25 +40,25 @@ class BazaarBestSellMethod { if (buyInstantly == null || buyInstantly.displayName != "§aBuy Instantly") return "" val bazaarItem = inv.getStackInSlot(13) ?: return "" - val internalName = NEUItems.getRawInternalNameOrNull(bazaarItem.displayName) ?: return "" + val internalName = NEUItems.getInternalNameOrNull(bazaarItem.displayName) ?: return "" var having = 0 for (slot in chest.inventorySlots) { if (slot == null) continue if (slot.slotNumber == slot.slotIndex) continue val stack = slot.stack ?: continue - if (internalName == stack.getInternalName_old()) { + if (internalName == stack.getInternalName()) { having += stack.stackSize } } if (having <= 0) return "" - val data = BazaarApi.getBazaarDataByInternalName(internalName) ?: return "" + val data = internalName.getBazaarData() ?: return "" val totalDiff = (data.buyPrice - data.sellPrice) * having val result = NumberUtil.format(totalDiff.toInt()) - val name = NEUItems.getItemStack(internalName).nameWithEnchantment + val name = internalName.getNameWithEnchantment() return "$name§7 sell difference: §6$result coins" } catch (e: Error) { e.printStackTrace() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index 20b9cacdb..ca1cd732f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -5,14 +5,12 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures -import at.hannibal2.skyhanni.utils.ItemUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -47,7 +45,7 @@ class AnitaMedalProfit { inInventory = true - val table = mutableMapOf<Pair<String, String>, Pair<Double, String>>() + val table = mutableMapOf<Pair<String, String>, Pair<Double, NEUInternalName>>() for ((_, item) in event.inventoryItems) { try { readItem(item, table) @@ -63,7 +61,7 @@ class AnitaMedalProfit { display = newList } - private fun readItem(item: ItemStack, table: MutableMap<Pair<String, String>, Pair<Double, String>>) { + private fun readItem(item: ItemStack, table: MutableMap<Pair<String, String>, Pair<Double, NEUInternalName>>) { val itemName = item.nameWithEnchantment ?: return if (itemName == " ") return if (itemName == "§cClose") return @@ -76,12 +74,12 @@ class AnitaMedalProfit { val (name, amount) = ItemUtils.readItemAmount(itemName) if (name == null) return - var internalName = NEUItems.getRawInternalNameOrNull(name) + var internalName = NEUItems.getInternalNameOrNull(name) if (internalName == null) { - internalName = item.getInternalName_old() + internalName = item.getInternalName() } - val itemPrice = NEUItems.getPrice(internalName) * amount + val itemPrice = internalName.getPrice() * amount if (itemPrice < 0) return val profit = itemPrice - fullCost diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt index c9350e6c8..86b7f5251 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.Companion.getAbilityFortune import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName @@ -138,8 +138,8 @@ class ToolTooltipTweaks { } } - // Fixing a hypixel bug. TODO remove once hypixel fixes it. - if (itemStack.getInternalName_old().contains("LOTUS")) { + // Fixing a hypixel bug. TODO remove once hypixel fixes it. use disabled features repo maybe? + if (itemStack.getInternalName().contains("LOTUS")) { event.toolTip.replaceAll { it.replace("Kills:", "Visitors:") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt index 287c1d4bb..cde25d493 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -44,7 +45,7 @@ class GardenComposterInventoryFeatures { LorenzUtils.error("§c[SkyHanni] Could not read item '$line'") continue } - val internalName = NEUItems.getRawInternalNameOrNull(itemName) + val internalName = NEUItems.getInternalNameOrNull(itemName) if (internalName == null) { LorenzUtils.chat( "§c[SkyHanni] Error reading internal name for item '$itemName§c' " + @@ -52,7 +53,7 @@ class GardenComposterInventoryFeatures { ) continue } - val lowestBin = NEUItems.getPrice(internalName) + val lowestBin = internalName.getPrice() val price = lowestBin * amount fullPrice += price val format = NumberUtil.format(price) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index efb5b64e4..f33ae9070 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent -import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.isBazaarItem import at.hannibal2.skyhanni.features.bazaar.BazaarData @@ -22,6 +21,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.moveEntryToTop import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName @@ -113,15 +113,15 @@ object CropMoneyDisplay { toolHasBountiful?.put(it, reforgeName == "bountiful") if (GardenAPI.mushroomCowPet && it != CropType.MUSHROOM && config.moneyPerHourMooshroom) { + val redMushroom = "ENCHANTED_RED_MUSHROOM".asInternalName() + val brownMushroom = "ENCHANTED_BROWN_MUSHROOM".asInternalName() val (redPrice, brownPrice) = if (LorenzUtils.noTradeMode) { - val redPrice = - (BazaarApi.getBazaarDataByInternalName("ENCHANTED_RED_MUSHROOM")?.npcPrice ?: 160.0) / 160 - val brownPrice = - (BazaarApi.getBazaarDataByInternalName("ENCHANTED_BROWN_MUSHROOM")?.npcPrice ?: 160.0) / 160 + val redPrice = (redMushroom.getBazaarData()?.npcPrice ?: 160.0) / 160 + val brownPrice = (brownMushroom.getBazaarData()?.npcPrice ?: 160.0) / 160 redPrice to brownPrice } else { - val redPrice = NEUItems.getPrice("ENCHANTED_RED_MUSHROOM") / 160 - val brownPrice = NEUItems.getPrice("ENCHANTED_BROWN_MUSHROOM") / 160 + val redPrice = redMushroom.getPrice() / 160 + val brownPrice = brownMushroom.getPrice() / 160 redPrice to brownPrice } @@ -135,11 +135,11 @@ object CropMoneyDisplay { var bazaarData: BazaarData? = null if (it == CropType.MELON) { dicerDrops = GardenCropSpeed.latestMelonDicer - bazaarData = BazaarApi.getBazaarDataByInternalName("ENCHANTED_MELON") + bazaarData = "ENCHANTED_MELON".asInternalName().getBazaarData() } if (it == CropType.PUMPKIN) { dicerDrops = GardenCropSpeed.latestPumpkinDicer - bazaarData = BazaarApi.getBazaarDataByInternalName("ENCHANTED_PUMPKIN") + bazaarData = "ENCHANTED_PUMPKIN".asInternalName().getBazaarData() } if (bazaarData != null) { val price = diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index 7b88c5cec..363d1c127 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt @@ -5,12 +5,13 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -31,12 +32,12 @@ class SkyMartCopperPrice { if (event.inventoryName != "SkyMart") return inInventory = true - val table = mutableMapOf<Pair<String, String>, Pair<Double, String>>() + val table = mutableMapOf<Pair<String, String>, Pair<Double, NEUInternalName>>() for (stack in event.inventoryItems.values) { for (line in stack.getLore()) { - val internalName = stack.getInternalName_old() - val lowestBin = NEUItems.getPrice(internalName) - if (lowestBin == -1.0) continue + val internalName = stack.getInternalName() + val lowestBin = internalName.getPriceOrNull() ?: continue + pattern.matchMatcher(line) { val amount = group("amount").replace(",", "").toInt() val factor = lowestBin / amount diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index b590cbbe2..4be642f6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -5,15 +5,20 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName 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.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber @@ -42,30 +47,30 @@ class SackDisplay { private val sackPattern = "^(.* Sack|Enchanted .* Sack)$".toPattern() private val stackList = mutableMapOf<Int, ItemStack>() private val gemstoneMap = mapOf( - "Jade Gemstones" to "ROUGH_JADE_GEM", - "Amber Gemstones" to "ROUGH_AMBER_GEM", - "Topaz Gemstones" to "ROUGH_TOPAZ_GEM", - "Sapphire Gemstones" to "ROUGH_SAPPHIRE_GEM", - "Amethyst Gemstones" to "ROUGH_AMETHYST_GEM", - "Jasper Gemstones" to "ROUGH_JASPER_GEM", - "Ruby Gemstones" to "ROUGH_RUBY_GEM", - "Opal Gemstones" to "ROUGH_OPAL_GEM" + "Jade Gemstones" to "ROUGH_JADE_GEM".asInternalName(), + "Amber Gemstones" to "ROUGH_AMBER_GEM".asInternalName(), + "Topaz Gemstones" to "ROUGH_TOPAZ_GEM".asInternalName(), + "Sapphire Gemstones" to "ROUGH_SAPPHIRE_GEM".asInternalName(), + "Amethyst Gemstones" to "ROUGH_AMETHYST_GEM".asInternalName(), + "Jasper Gemstones" to "ROUGH_JASPER_GEM".asInternalName(), + "Ruby Gemstones" to "ROUGH_RUBY_GEM".asInternalName(), + "Opal Gemstones" to "ROUGH_OPAL_GEM".asInternalName(), ) private val numPattern = - "(?:(?:§[0-9a-f](?<level>I{1,3})§7:)?|(?:§7Stored:)?) (?<color>§[0-9a-f])(?<stored>[0-9.,kKmMbB]+)§7/(?<total>\\d+(?:[0-9.,]+)?[kKmMbB]?)".toPattern() + "(?:(?:§[0-9a-f](?<level>I{1,3})§7:)?|(?:§7Stored:)?) (?<color>§[0-9a-f])(?<stored>[0-9.,kKmMbB]+)§7/(?<total>\\d+(?:[0-9.,]+)?[kKmMbB]?)".toPattern() private val gemstonePattern = - " §[0-9a-f](?<gemrarity>[A-z]*): §[0-9a-f](?<stored>\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?".toPattern() + " §[0-9a-f](?<gemrarity>[A-z]*): §[0-9a-f](?<stored>\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?".toPattern() @SubscribeEvent fun onBackgroundDraw(event: GuiRenderEvent.ChestBackgroundRenderEvent) { if (inInventory) { config.position.renderStringsAndItems( - display, - extraSpace = config.extraSpace, - itemScale = 1.3, - posLabel = "Sacks Items" + display, + extraSpace = config.extraSpace, + itemScale = 1.3, + posLabel = "Sacks Items" ) } } @@ -86,10 +91,11 @@ class SackDisplay { gemstonePattern.matchMatcher(line) { val rarity = group("gemrarity") val stored = group("stored") - gem.internalName = gemstoneMap[name.removeColor()].toString() + gem.internalName = gemstoneMap[name.removeColor()] ?: NEUInternalName.NONE if (gemstoneMap.containsKey(name.removeColor())) { - val internalName = - "${rarity.uppercase()}_${name.uppercase().split(" ")[0].removeColor()}_GEM" + val internalName = "${rarity.uppercase()}_${ + name.uppercase().split(" ")[0].removeColor() + }_GEM".asInternalName() when (rarity) { "Rough" -> { @@ -119,19 +125,24 @@ class SackDisplay { numPattern.matchMatcher(line) { val stored = group("stored") val total = group("total") - val internalName = stack.getInternalName_old() + val internalName = stack.getInternalName() item.internalName = internalName item.colorCode = group("color") item.stored = stored item.total = total if (isTrophySack) { - val trophyName = internalName.lowercase() - .substringBeforeLast("_").replace("_", "") - val filletValue = TrophyFishManager.getInfoByName(trophyName)?.getFilletValue(sackRarity!!) ?: 0 + val trophyName = + internalName.asString().lowercase().substringBeforeLast("_").replace("_", "") + val filletValue = + TrophyFishManager.getInfoByName(trophyName)?.getFilletValue(sackRarity!!) ?: 0 val storedNumber = stored.formatNumber().toInt() - item.price = calculatePrice("MAGMA_FISH", (filletValue * storedNumber).toString()) + item.price = + calculatePrice("MAGMA_FISH".asInternalName(), (filletValue * storedNumber).toString()) } else { - item.price = if (calculatePrice(internalName, stored) < 0) 0 else calculatePrice(internalName, stored) + item.price = if (calculatePrice(internalName, stored) < 0) 0 else calculatePrice( + internalName, + stored + ) } if (isRuneSack) { val level = group("level") @@ -185,7 +196,7 @@ class SackDisplay { totalPrice += price if (rendered >= config.itemToShow) continue if (stored == "0" && !config.showEmpty) continue - val itemStack = NEUItems.getItemStack(internalName) + val itemStack = internalName.getItemStack() newDisplay.add(buildList { add(" §7- ") add(itemStack) @@ -197,12 +208,12 @@ class SackDisplay { add("${itemName.replace("§k", "")}: ") add( - when (config.numberFormat) { - 0 -> "$colorCode${stored}§7/§b${total}" - 1 -> "$colorCode${NumberUtil.format(stored.formatNumber())}§7/§b${total}" - 2 -> "$colorCode${stored}§7/§b${total.formatNumber().toInt().addSeparators()}" - else -> "$colorCode${stored}§7/§b${total}" - } + when (config.numberFormat) { + 0 -> "$colorCode${stored}§7/§b${total}" + 1 -> "$colorCode${NumberUtil.format(stored.formatNumber())}§7/§b${total}" + 2 -> "$colorCode${stored}§7/§b${total.formatNumber().toInt().addSeparators()}" + else -> "$colorCode${stored}§7/§b${total}" + } ) if (colorCode == "§a") @@ -257,7 +268,7 @@ class SackDisplay { val (internalName, rough, flawed, fine, flawless, roughprice, flawedprice, fineprice, flawlessprice) = gem newDisplay.add(buildList { add(" §7- ") - add(NEUItems.getItemStack(internalName)) + add(internalName.getItemStack()) add(Renderable.optionalLink("$name: ", { BazaarApi.searchForBazaarItem(name.dropLast(1)) }) { !NEUItems.neuHasFocus() }) @@ -307,38 +318,38 @@ class SackDisplay { data class Gemstone( - var internalName: String = "", - var rough: String = "0", - var flawed: String = "0", - var fine: String = "0", - var flawless: String = "0", - var roughPrice: Int = 0, - var flawedPrice: Int = 0, - var finePrice: Int = 0, - var flawlessPrice: Int = 0, + var internalName: NEUInternalName = NEUInternalName.NONE, + var rough: String = "0", + var flawed: String = "0", + var fine: String = "0", + var flawless: String = "0", + var roughPrice: Int = 0, + var flawedPrice: Int = 0, + var finePrice: Int = 0, + var flawlessPrice: Int = 0, ) data class Rune( - var stack: ItemStack? = null, - var lvl1: String = "0", - var lvl2: String = "0", - var lvl3: String = "0", + var stack: ItemStack? = null, + var lvl1: String = "0", + var lvl2: String = "0", + var lvl3: String = "0", ) data class Item( - var internalName: String = "", - var colorCode: String = "", - var stored: String = "0", - var total: String = "0", - var price: Int = 0, + var internalName: NEUInternalName = NEUInternalName.NONE, + var colorCode: String = "", + var stored: String = "0", + var total: String = "0", + var price: Int = 0, ) private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled private fun isRuneDisplayEnabled() = config.showRunes - private fun calculatePrice(internalName: String, stored: String) = when (config.priceFrom) { + private fun calculatePrice(internalName: NEUInternalName, stored: String) = when (config.priceFrom) { 0 -> { - (NEUItems.getPrice(internalName, true) * stored.formatNumber()).toInt().let { + (internalName.getPrice(true) * stored.formatNumber()).toInt().let { if (it < 0) 0 else it @@ -346,7 +357,7 @@ class SackDisplay { } 1 -> try { - val npcPrice = BazaarApi.getBazaarDataByInternalName(internalName)?.npcPrice ?: 0.0 + val npcPrice = internalName.getBazaarData()?.npcPrice ?: 0.0 (npcPrice * stored.formatNumber()).toInt() } catch (e: Exception) { 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index 7074f38a5..09a1ed991 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.between import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraft.client.Minecraft @@ -92,10 +93,10 @@ class ItemAbilityCooldown { if (event.soundName == "mob.wolf.howl") { if (event.volume == 0.5f) { val recentItems = InventoryUtils.recentItemsInHand.values - if ("WEIRD_TUBA" in recentItems) { + if ("WEIRD_TUBA".asInternalName() in recentItems) { ItemAbility.WEIRD_TUBA.sound() } - if ("WEIRDER_TUBA" in recentItems) { + if ("WEIRDER_TUBA".asInternalName() in recentItems) { ItemAbility.WEIRDER_TUBA.sound() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt index e9d374f91..301dc65e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt @@ -1,30 +1,33 @@ package at.hannibal2.skyhanni.features.misc +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName + enum class EnderNode( - val internalName: String, + val internalName: NEUInternalName, val displayName: String, - ) { +) { - ENCHANTED_ENDSTONE("ENCHANTED_ENDSTONE","§aEnchanted End Stone"), - ENCHANTED_OBSIDIAN("ENCHANTED_OBSIDIAN","§aEnchanted Obsidian"), - ENCHANTED_ENDER_PEARL("ENCHANTED_ENDER_PEARL","§aEnchanted Ender Pearl"), - GRAND_EXP_BOTTLE("GRAND_EXP_BOTTLE","§aGrand Experience Bottle"), - TITANIC_EXP_BOTTLE("TITANIC_EXP_BOTTLE", "§9Titanic Experience Bottle"), - END_STONE_SHULKER("END_STONE_SHULKER","§9End Stone Shulker"), - ENDSTONE_GEODE("ENDSTONE_GEODE","§9End Stone Geode"), - MAGIC_RUNE("MAGIC_RUNE;1", "§d◆ Magical Rune I"), - ENDER_GAUNTLET("ENDER_GAUNTLET","§5Ender Gauntlet"), - MITE_GEL("MITE_GEL", "§5Mite Gel"), - SHRIMP_THE_FISH("SHRIMP_THE_FISH", "§cShrimp the Fish"), + ENCHANTED_ENDSTONE("ENCHANTED_ENDSTONE".asInternalName(), "§aEnchanted End Stone"), + ENCHANTED_OBSIDIAN("ENCHANTED_OBSIDIAN".asInternalName(), "§aEnchanted Obsidian"), + ENCHANTED_ENDER_PEARL("ENCHANTED_ENDER_PEARL".asInternalName(), "§aEnchanted Ender Pearl"), + GRAND_EXP_BOTTLE("GRAND_EXP_BOTTLE".asInternalName(), "§aGrand Experience Bottle"), + TITANIC_EXP_BOTTLE("TITANIC_EXP_BOTTLE".asInternalName(), "§9Titanic Experience Bottle"), + END_STONE_SHULKER("END_STONE_SHULKER".asInternalName(), "§9End Stone Shulker"), + ENDSTONE_GEODE("ENDSTONE_GEODE".asInternalName(), "§9End Stone Geode"), + MAGIC_RUNE("MAGIC_RUNE;1".asInternalName(), "§d◆ Magical Rune I"), + ENDER_GAUNTLET("ENDER_GAUNTLET".asInternalName(), "§5Ender Gauntlet"), + MITE_GEL("MITE_GEL".asInternalName(), "§5Mite Gel"), + SHRIMP_THE_FISH("SHRIMP_THE_FISH".asInternalName(), "§cShrimp the Fish"), - END_HELMET("END_HELMET", "§5Ender Helmet"), - END_CHESTPLATE("END_CHESTPLATE", "§5Ender Chestplate"), - END_LEGGINGS("END_LEGGINGS", "§5Ender Leggings"), - END_BOOTS("END_BOOTS", "§5Ender Boots"), - ENDER_NECKLACE("ENDER_NECKLACE", "§5Ender Necklace"), - COMMON_ENDERMAN_PET("ENDERMAN;0", "§fEnderman"), - UNCOMMON_ENDERMAN_PET("ENDERMAN;1", "§aEnderman"), - RARE_ENDERMAN_PET("ENDERMAN;2", "§9Enderman"), - EPIC_ENDERMAN_PET("ENDERMAN;3", "§5Enderman"), - LEGENDARY_ENDERMAN_PET("ENDERMAN;4", "§6Enderman") + END_HELMET("END_HELMET".asInternalName(), "§5Ender Helmet"), + END_CHESTPLATE("END_CHESTPLATE".asInternalName(), "§5Ender Chestplate"), + END_LEGGINGS("END_LEGGINGS".asInternalName(), "§5Ender Leggings"), + END_BOOTS("END_BOOTS".asInternalName(), "§5Ender Boots"), + ENDER_NECKLACE("ENDER_NECKLACE".asInternalName(), "§5Ender Necklace"), + COMMON_ENDERMAN_PET("ENDERMAN;0".asInternalName(), "§fEnderman"), + UNCOMMON_ENDERMAN_PET("ENDERMAN;1".asInternalName(), "§aEnderman"), + RARE_ENDERMAN_PET("ENDERMAN;2".asInternalName(), "§9Enderman"), + EPIC_ENDERMAN_PET("ENDERMAN;3".asInternalName(), "§5Enderman"), + LEGENDARY_ENDERMAN_PET("ENDERMAN;4".asInternalName(), "§6Enderman") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt index f0509161f..549776a40 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt @@ -8,12 +8,12 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PlaySoundEvent -import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.afterChange import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems @@ -114,24 +114,22 @@ class EnderNodeTracker { private fun calculateProfit(): Map<EnderNode, Double> { val newProfit = mutableMapOf<EnderNode, Double>() - lootCount.forEach { - val price = if (isEnderArmor(it.key.displayName)) { + lootCount.forEach { (key, _) -> + val price = if (isEnderArmor(key.displayName)) { 10_000.0 } else { - val bzData = BazaarApi.getBazaarDataByInternalName(it.key.internalName) + val internalName = key.internalName + val bzData = internalName.getBazaarData() if (LorenzUtils.noTradeMode) { - bzData?.npcPrice ?: georgePrice(it.key) ?: 0.0 + bzData?.npcPrice ?: georgePrice(key) ?: 0.0 } else { - bzData?.npcPrice ?.coerceAtLeast(bzData.sellPrice) - ?.coerceAtLeast(georgePrice(it.key) ?: 0.0) - ?: NEUItems.getPrice(it.key.internalName) - + ?.coerceAtLeast(georgePrice(key) ?: 0.0) + ?: internalName.getPrice() } - } - newProfit[it.key] = price * (lootCount[it.key] ?: 0) + newProfit[key] = price * (lootCount[key] ?: 0) } return newProfit } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt index 2cbab2a26..580fc7691 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.SkillExperience import at.hannibal2.skyhanni.events.* -import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData.Option.* import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData.bestiaryData import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.formatBestiary @@ -29,6 +29,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.chat import at.hannibal2.skyhanni.utils.LorenzUtils.clickableChat +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal @@ -223,10 +224,10 @@ object GhostCounter { addAsSingletonList(etaFormatting.base.formatText(eta).formatText(killETA)) val rate = 0.12 * (1 + (avgMagicFind.toDouble() / 100)) - val sorrowValue = (BazaarApi.getBazaarDataByInternalName("SORROW")?.buyPrice ?: 0).toLong() + val sorrowValue = ("SORROW".asInternalName().getBazaarData()?.buyPrice ?: 0).toLong() val final: String = (killInterp * sorrowValue * (rate / 100)).toLong().addSeparators() - val plasmaValue = (BazaarApi.getBazaarDataByInternalName("PLASMA")?.buyPrice ?: 0).toLong() - val voltaValue = (BazaarApi.getBazaarDataByInternalName("VOLTA")?.buyPrice ?: 0).toLong() + val plasmaValue = ("PLASMA".asInternalName().getBazaarData()?.buyPrice ?: 0).toLong() + val voltaValue = ("VOLTA".asInternalName().getBazaarData()?.buyPrice ?: 0).toLong() var moneyMade: Long = 0 val priceMap = listOf( Triple("Sorrow", SORROWCOUNT.getInt(), sorrowValue), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index c055ff42b..d90c16ded 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -226,4 +226,11 @@ object ItemUtils { fun NEUInternalName.getItemNameOrNull() = getItemStack().name fun NEUInternalName.getItemName() = getItemNameOrNull() ?: error("No item name found for $this") + + fun NEUInternalName.getNameWithEnchantment(): String { + if (equals("WISP_POTION")) { + return "§fWisp's Ice-Flavored Water" + } + return getItemStack().nameWithEnchantment ?: error("Could not find item name for $this") + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 9c02fc1cd..6a2dd34fc 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.features.dungeon.DungeonData import at.hannibal2.skyhanni.test.TestBingo +import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -196,7 +197,7 @@ object LorenzUtils { } // (key -> value) -> (sorting value -> key item icon) - fun fillTable(list: MutableList<List<Any>>, data: MutableMap<Pair<String, String>, Pair<Double, String>>) { + fun fillTable(list: MutableList<List<Any>>, data: MutableMap<Pair<String, String>, Pair<Double, NEUInternalName>>) { val keys = data.mapValues { (_, v) -> v.first }.sortedDesc().keys val renderer = Minecraft.getMinecraft().fontRendererObj val longest = keys.map { it.first }.maxOfOrNull { renderer.getStringWidth(it.removeColor()) } ?: 0 @@ -208,7 +209,7 @@ object LorenzUtils { displayName += " " } - NEUItems.getItemStackOrNull(data[pair]!!.second)?.let { + data[pair]!!.second.getItemStackOrNull()?.let { list.add(listOf(it, "$displayName $second")) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index d530e79df..ce44e3d64 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -83,9 +83,6 @@ object NEUItems { return map } - // TODO remove - fun getRawInternalNameOrNull(itemName: String) = getInternalNameOrNull(itemName)?.asString() - fun getInternalNameOrNull(itemName: String): NEUInternalName? { val lowercase = itemName.lowercase() if (itemNameCache.containsKey(lowercase)) { |