From 6dd90af204bbb5859529b362909130e6c9767929 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 10 Sep 2023 10:41:56 +0200 Subject: code cleanup --- .../java/at/hannibal2/skyhanni/data/SackAPI.kt | 2 +- .../skyhanni/features/inventory/SackDisplay.kt | 29 ++++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 4534e49a5..e2102c6ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -195,7 +195,7 @@ object SackAPI { @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!event.message.removeColor().startsWith("[Sacks]")) return - + val sackAddText = event.chatComponent.siblings.firstNotNullOfOrNull { sibling -> sibling.chatStyle?.chatHoverEvent?.value?.formattedText?.removeColor()?.takeIf { it.startsWith("Added") 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 260d4bb9e..fcb258d21 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -41,18 +41,19 @@ object SackDisplay { var rendered = 0 SackAPI.getSacksData(savingSacks) - if (SackAPI.sackItem.isNotEmpty()) { + val saclItems = SackAPI.sackItem.toList() + if (saclItems.isNotEmpty()) { val sortedPairs: MutableMap = when (config.sortingType) { - 0 -> SackAPI.sackItem.toList().sortedByDescending { it.second.stored.formatNumber() }.toMap().toMutableMap() - 1 -> SackAPI.sackItem.toList().sortedBy { it.second.stored.formatNumber() }.toMap().toMutableMap() - 2 -> SackAPI.sackItem.toList().sortedByDescending { it.second.price }.toMap().toMutableMap() - 3 -> SackAPI.sackItem.toList().sortedBy { it.second.price }.toMap().toMutableMap() - else -> SackAPI.sackItem.toList().sortedByDescending { it.second.stored.formatNumber() }.toMap().toMutableMap() - } - - sortedPairs.toList().forEach { - if (it.second.stored == "0" && !config.showEmpty) { - sortedPairs.remove(it.first) + 0 -> saclItems.sortedByDescending { it.second.stored.formatNumber() } + 1 -> saclItems.sortedBy { it.second.stored.formatNumber() } + 2 -> saclItems.sortedByDescending { it.second.price } + 3 -> saclItems.sortedBy { it.second.price } + else -> saclItems.sortedByDescending { it.second.stored.formatNumber() } + }.toMap().toMutableMap() + + sortedPairs.forEach { (k, v) -> + if (v.stored == "0" && !config.showEmpty) { + sortedPairs.remove(k) } } @@ -152,11 +153,13 @@ object SackDisplay { STORED_DESC("Stored D", "Stored Descending"), STORED_ASC("Stored A", "Stored Ascending"), PRICE_DESC("Price D", "Price Descending"), - PRICE_ASC("Price A", "Price Ascending"),; + PRICE_ASC("Price A", "Price Ascending"), + ; } enum class PriceFrom(val displayName: String) { BAZAAR("Bazaar Price"), - NPC("Npc Price"),; + NPC("Npc Price"), + ; } } \ No newline at end of file -- cgit