diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt index 5f01183d6..27bcad12a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt @@ -98,27 +98,7 @@ object FishingProfitTracker { private fun drawDisplay(data: Data): List<List<Any>> = buildList { addAsSingletonList("§e§lFishing Profit Tracker") - val amounts = getCurrentCategories(data) - val list = amounts.keys.toList() - if (currentCategory !in list) { - currentCategory = nameAll - } - addButton( - prefix = "§7Category: ", - getName = currentCategory + " §7(" + amounts[currentCategory] + ")", - onChange = { - val id = list.indexOf(currentCategory) - currentCategory = list[(id + 1) % list.size] - tracker.update() - } - ) - - val filter: (NEUInternalName) -> Boolean = if (currentCategory == nameAll) { - { true } - } else { - val items = itemCategories[currentCategory]!! - { it in items } - } + val filter: (NEUInternalName) -> Boolean = addCategories(data) val profit = tracker.drawItems(data, filter, this) @@ -142,6 +122,31 @@ object FishingProfitTracker { tracker.addPriceFromButton(this) } + private fun MutableList<List<Any>>.addCategories(data: Data): (NEUInternalName) -> Boolean { + val amounts = getCurrentCategories(data) + val list = amounts.keys.toList() + if (currentCategory !in list) { + currentCategory = nameAll + } + addButton( + prefix = "§7Category: ", + getName = currentCategory + " §7(" + amounts[currentCategory] + ")", + onChange = { + val id = list.indexOf(currentCategory) + currentCategory = list[(id + 1) % list.size] + tracker.update() + } + ) + + val filter: (NEUInternalName) -> Boolean = if (currentCategory == nameAll) { + { true } + } else { + val items = itemCategories[currentCategory]!! + { it in items } + } + return filter + } + @SubscribeEvent fun onItemAdd(event: ItemAddEvent) { if (!isEnabled()) return |