From 4cbac9ae9548f2d6fa26096301e6ea578d6f68aa Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 29 Sep 2023 11:20:28 +0200 Subject: code cleanup (ty nea) --- .../at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt | 5 +++-- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index d2b122d7f..8f996fef0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -22,7 +22,6 @@ import at.hannibal2.skyhanni.utils.LorenzLogger 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.LorenzUtils.get import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getNpcPrice @@ -49,6 +48,7 @@ object SlayerItemProfitTracker { private var collectedCache = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.SECONDS).build() private var itemLogCategory = "" + private var baseSlayerType = "" private var display = emptyList>() private val logger = LorenzLogger("slayer/item_profit_tracker") private var inventoryOpen = false @@ -92,6 +92,7 @@ object SlayerItemProfitTracker { fun onSlayerChange(event: SlayerChangeEvent) { val newSlayer = event.newSlayer itemLogCategory = newSlayer.removeColor() + baseSlayerType = itemLogCategory.substringBeforeLast(" ") update() } @@ -199,7 +200,7 @@ object SlayerItemProfitTracker { } private fun isAllowedItem(internalName: NEUInternalName): Boolean { - val allowedList = allowedItems.get { itemLogCategory.startsWith(it) } ?: return false + val allowedList = allowedItems[baseSlayerType] ?: return false return internalName in allowedList } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 5275b9196..3ad8e3fe9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -540,6 +540,4 @@ object LorenzUtils { fun T.conditionalTransform(condition: Boolean, ifTrue: T.() -> Any, ifFalse: T.() -> Any) = if (condition) ifTrue(this) else ifFalse(this) - - fun Map.get(function: (K) -> Boolean) = entries.firstOrNull { function(it.key) }?.value } -- cgit