diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-29 11:20:28 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-29 11:20:28 +0200 |
commit | 4cbac9ae9548f2d6fa26096301e6ea578d6f68aa (patch) | |
tree | 4d57c96615797be6f94e9e9354c0ba99f5424239 /src/main/java/at/hannibal2/skyhanni | |
parent | 0209b85505dbdf0a5403081bb04f0dbc01ca2357 (diff) | |
download | skyhanni-4cbac9ae9548f2d6fa26096301e6ea578d6f68aa.tar.gz skyhanni-4cbac9ae9548f2d6fa26096301e6ea578d6f68aa.tar.bz2 skyhanni-4cbac9ae9548f2d6fa26096301e6ea578d6f68aa.zip |
code cleanup (ty nea)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 |
2 files changed, 3 insertions, 4 deletions
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<Int, Unit>() private var itemLogCategory = "" + private var baseSlayerType = "" private var display = emptyList<List<Any>>() 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> T.conditionalTransform(condition: Boolean, ifTrue: T.() -> Any, ifFalse: T.() -> Any) = if (condition) ifTrue(this) else ifFalse(this) - - fun <K, V> Map<K, V>.get(function: (K) -> Boolean) = entries.firstOrNull { function(it.key) }?.value } |