From 1f220684fc455edfc9f202d8c7ab61dfaf875e1d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:00:50 +0100 Subject: code cleanup --- .../features/garden/visitor/GardenVisitorFeatures.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/main/java') 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> { + private fun drawDisplay() = buildList { if (!config.needs.display) return@buildList + val (requiredItems, newVisitors) = prepareDrawingData() + drawRequiredItems(requiredItems) + drawVisitors(newVisitors, requiredItems) + } + + private fun prepareDrawingData(): Pair, MutableList> { val requiredItems = mutableMapOf() val newVisitors = mutableListOf() for ((visitorName, visitor) in VisitorAPI.getVisitorsMap()) { @@ -129,6 +135,10 @@ class GardenVisitorFeatures { requiredItems[internalName] = old + amount } } + return requiredItems to newVisitors + } + + private fun MutableList>.drawRequiredItems(requiredItems: MutableMap) { 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>.drawVisitors( + newVisitors: MutableList, + requiredItems: MutableMap + ) { if (newVisitors.isNotEmpty()) { if (requiredItems.isNotEmpty()) { addAsSingletonList("") -- cgit