diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/Misc.java | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt) | 35 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt | 62 |
4 files changed, 92 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 555761bbe..ef7d6b6ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -43,6 +43,8 @@ import at.hannibal2.skyhanni.features.minion.MinionCollectLogic import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.* import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager +import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue +import at.hannibal2.skyhanni.features.misc.items.EstimatedWardrobePrice import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadCompactName import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadInventoryNumber import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayHelper @@ -252,7 +254,8 @@ class SkyHanniMod { loadModule(GardenComposterInventoryFeatures()) loadModule(MinionCollectLogic()) loadModule(PasteIntoSigns()) - loadModule(EstimatedItemValue()) + loadModule(EstimatedItemValue) + loadModule(EstimatedWardrobePrice()) loadModule(ComposterInventoryNumbers()) loadModule(FarmingFortuneDisplay()) loadModule(ToolTooltipTweaks()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index f5ad1513c..6dd895023 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -232,6 +232,12 @@ public class Misc { public boolean estimatedIemValueAlwaysEnabled = true; @Expose + @ConfigOption(name = "Show Armor Value", desc = "Show the value of the full armor in the wardrobe inventory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 11) + public boolean estimatedIemValueArmor = true; + + @Expose public Position itemPriceDataPos = new Position(140, 90, false, true); @ConfigOption(name = "Discord Rich Presence", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 981795da7..70980a715 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -42,7 +42,7 @@ import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class EstimatedItemValue { +object EstimatedItemValue { private val config get() = SkyHanniMod.feature.misc private var display = listOf<List<Any>>() private val cache = mutableMapOf<ItemStack, List<List<Any>>>() @@ -90,9 +90,6 @@ class EstimatedItemValue { } private fun draw(stack: ItemStack): List<List<Any>> { - val list = mutableListOf<String>() - list.add("§aEstimated Item Value:") - val internalName = stack.getInternalName() if (internalName == "") return listOf() @@ -113,6 +110,23 @@ class EstimatedItemValue { return listOf() } + val list = mutableListOf<String>() + list.add("§aEstimated Item Value:") + val pair = getEstimatedItemPrice(stack, list) + val (totalPrice, basePrice) = pair + + if (basePrice == totalPrice) return listOf() + + list.add("§aTotal: §6§l" + NumberUtil.format(totalPrice)) + + val newDisplay = mutableListOf<List<Any>>() + for (line in list) { + newDisplay.addAsSingletonList(line) + } + return newDisplay + } + + fun getEstimatedItemPrice(stack: ItemStack, list: MutableList<String>): Pair<Double, Double> { var totalPrice = 0.0 val basePrice = addBaseItem(stack, list) totalPrice += basePrice @@ -146,16 +160,7 @@ class EstimatedItemValue { totalPrice += addDrillUpgrades(stack, list) totalPrice += addGemstones(stack, list) totalPrice += addEnchantments(stack, list) - - if (basePrice == totalPrice) return listOf() - - list.add("§aTotal: §6§l" + NumberUtil.format(totalPrice)) - - val newDisplay = mutableListOf<List<Any>>() - for (line in list) { - newDisplay.addAsSingletonList(line) - } - return newDisplay + return Pair(totalPrice, basePrice) } private fun addReforgeStone(stack: ItemStack, list: MutableList<String>): Double { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt new file mode 100644 index 000000000..7dd8ca20a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt @@ -0,0 +1,62 @@ +package at.hannibal2.skyhanni.features.misc.items + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +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.NumberUtil +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class EstimatedWardrobePrice { + private val config get() = SkyHanniMod.feature.misc + var data = mutableMapOf<Int, MutableList<ItemStack>>() + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.estimatedIemValueArmor) return + + val slot = event.slot.slotNumber + val id = slot % 9 + // Only showing in the armor select line + if (slot - id != 36) return + val items = data[id] ?: return + + var index = 3 + val toolTip = event.toolTip + toolTip.add(index++, "") + toolTip.add(index++, "§aEstimated Armor Value:") + + var totalPrice = 0.0 + for (item in items) { + val name = item.name + val price = EstimatedItemValue.getEstimatedItemPrice(item, mutableListOf()).first + totalPrice += price + + toolTip.add(index++, " §7-$name: §6${NumberUtil.format(price)}") + } + toolTip.add(index++, " §aTotal Value: §6§l${NumberUtil.format(totalPrice)}") + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.estimatedIemValueArmor) return + if (!event.inventoryName.startsWith("Wardrobe")) return + + val map = mutableMapOf<Int, MutableList<ItemStack>>() + + for ((slot, item) in event.inventoryItems) { + if (item.getInternalName() == "") continue + val price = EstimatedItemValue.getEstimatedItemPrice(item, mutableListOf()).first + if (price == 0.0) continue + val id = slot % 9 + val list = map.getOrPut(id) { mutableListOf() } + list.add(item) + } + data = map + } +}
\ No newline at end of file |