aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-15 15:00:50 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-15 15:00:50 +0100
commit1f220684fc455edfc9f202d8c7ab61dfaf875e1d (patch)
tree45790f0bcb7089aa104b487dc4ed2edb2720691d
parent391cdb578adf4ba697c6c5e1c89053dad4447663 (diff)
downloadskyhanni-1f220684fc455edfc9f202d8c7ab61dfaf875e1d.tar.gz
skyhanni-1f220684fc455edfc9f202d8c7ab61dfaf875e1d.tar.bz2
skyhanni-1f220684fc455edfc9f202d8c7ab61dfaf875e1d.zip
code cleanup
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index dfe59a64b..135a98459 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -112,9 +112,15 @@ class GardenVisitorFeatures {
display = drawDisplay()
}
- private fun drawDisplay() = buildList<List<Any>> {
+ private fun drawDisplay() = buildList {
if (!config.needs.display) return@buildList
+ val (requiredItems, newVisitors) = prepareDrawingData()
+ drawRequiredItems(requiredItems)
+ drawVisitors(newVisitors, requiredItems)
+ }
+
+ private fun prepareDrawingData(): Pair<MutableMap<NEUInternalName, Int>, MutableList<String>> {
val requiredItems = mutableMapOf<NEUInternalName, Int>()
val newVisitors = mutableListOf<String>()
for ((visitorName, visitor) in VisitorAPI.getVisitorsMap()) {
@@ -129,6 +135,10 @@ class GardenVisitorFeatures {
requiredItems[internalName] = old + amount
}
}
+ return requiredItems to newVisitors
+ }
+
+ private fun MutableList<List<Any>>.drawRequiredItems(requiredItems: MutableMap<NEUInternalName, Int>) {
if (requiredItems.isNotEmpty()) {
var totalPrice = 0.0
addAsSingletonList("§7Visitor items needed:")
@@ -162,6 +172,12 @@ class GardenVisitorFeatures {
this[0] = listOf("§7Visitor items needed: §7(§6$format§7)")
}
}
+ }
+
+ private fun MutableList<List<Any>>.drawVisitors(
+ newVisitors: MutableList<String>,
+ requiredItems: MutableMap<NEUInternalName, Int>
+ ) {
if (newVisitors.isNotEmpty()) {
if (requiredItems.isNotEmpty()) {
addAsSingletonList("")