Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Nov 25, 2023
1 parent ea84c15 commit f92544e
Showing 1 changed file with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit f92544e

Please sign in to comment.