From 33b5429348dc5f274bf1cfaf530a77343eaf3fb6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:40:23 +0100 Subject: No longer merging same items with different prices in Chest Value together. --- .../skyhanni/features/inventory/ChestValue.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index 449464952..b7b8ae7f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addButton -import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -34,7 +33,7 @@ class ChestValue { private val config get() = SkyHanniMod.feature.inventory.chestValueConfig private var display = emptyList>() - private val chestItems = mutableMapOf() + private val chestItems = mutableMapOf() private val inInventory get() = isValidStorage() @SubscribeEvent @@ -115,6 +114,7 @@ class ChestValue { val sortedList = sortedList() var totalPrice = 0.0 var rendered = 0 + val amountShowing = if (config.itemToShow > sortedList.size) sortedList.size else config.itemToShow newDisplay.addAsSingletonList("§7Estimated Chest Value: §o(Showing $amountShowing of ${sortedList.size} items)") for ((index, amount, stack, total, tips) in sortedList) { @@ -145,13 +145,11 @@ class ChestValue { newDisplay.addAsSingletonList("§6Total value : §b${totalPrice.formatPrice()}") } - private fun sortedList(): MutableList { - return when (config.sortingType) { - 0 -> chestItems.values.sortedByDescending { it.total } - 1 -> chestItems.values.sortedBy { it.total } - else -> chestItems.values.sortedByDescending { it.total } - }.toMutableList() - } + private fun sortedList() = when (config.sortingType) { + 0 -> chestItems.values.sortedByDescending { it.total } + 1 -> chestItems.values.sortedBy { it.total } + else -> chestItems.values.sortedByDescending { it.total } + }.toMutableList() private fun addButton(newDisplay: MutableList>) { newDisplay.addButton("§7Sorted By: ", @@ -194,11 +192,12 @@ class ChestValue { val list = mutableListOf() val pair = EstimatedItemValue.getEstimatedItemPrice(stack, list) var (total, _) = pair + val key = "$internalName+$total" if (stack.item == Items.enchanted_book) total /= 2 list.add("§aTotal: §6§l${total.formatPrice()}") if (total == 0.0) continue - val item = chestItems.getOrPut(internalName) { + val item = chestItems.getOrPut(key) { Item(mutableListOf(), 0, stack, 0.0, list) } item.index.add(i) -- cgit