diff options
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt | 19 |
1 files changed, 9 insertions, 10 deletions
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<List<Any>>() - private val chestItems = mutableMapOf<NEUInternalName, Item>() + private val chestItems = mutableMapOf<String, Item>() 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<Item> { - 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<List<Any>>) { newDisplay.addButton("§7Sorted By: ", @@ -194,11 +192,12 @@ class ChestValue { val list = mutableListOf<String>() 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) |