aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt122
1 files changed, 67 insertions, 55 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 ccac68803..3902b5ded 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
@@ -182,68 +182,80 @@ object GardenVisitorFeatures {
}
private fun MutableList<List<Any>>.drawShoppingList(shoppingList: MutableMap<NEUInternalName, Int>) {
- if (shoppingList.isNotEmpty()) {
- var totalPrice = 0.0
- addAsSingletonList("§7Visitor Shopping List:")
- for ((internalName, amount) in shoppingList) {
- val name = internalName.itemName
- val itemStack = internalName.getItemStack()
+ if (shoppingList.isEmpty()) return
- val list = mutableListOf<Any>()
- list.add(" §7- ")
- list.add(itemStack)
+ var totalPrice = 0.0
+ addAsSingletonList("§7Visitor Shopping List:")
+ for ((internalName, amount) in shoppingList) {
+ val name = internalName.itemName
+ val itemStack = internalName.getItemStack()
+
+ val list = mutableListOf<Any>()
+ list.add(" §7- ")
+ list.add(itemStack)
+
+ list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", {
+ if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
+ LorenzUtils.setTextIntoSign("$amount")
+ } else {
+ BazaarApi.searchForBazaarItem(name, amount)
+ }
+ }) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() })
- list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", {
- if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
- LorenzUtils.setTextIntoSign("$amount")
- } else {
- BazaarApi.searchForBazaarItem(name, amount)
- }
- }) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() })
+ if (config.shoppingList.showPrice) {
+ val price = internalName.getPrice() * amount
+ totalPrice += price
+ val format = NumberUtil.format(price)
+ list.add(" §7(§6$format§7)")
+ }
- if (config.shoppingList.showPrice) {
- val price = internalName.getPrice() * amount
- totalPrice += price
- val format = NumberUtil.format(price)
- list.add(" §7(§6$format§7)")
- }
+ addSackData(internalName, amount, list)
- if (config.shoppingList.showSackCount) {
- var amountInSacks = 0
- internalName.getAmountInSacksOrNull()?.let {
- amountInSacks = it
- val textColour = if (it >= amount) "a" else "e"
- list.add(" §7(§${textColour}x${it.addSeparators()} §7in sacks)")
- }
- val ingredients = NEUItems.getRecipes(internalName)
- // TODO describe what this line does
- .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") }
- ?.allIngredients() ?: return
- val requiredIngredients = mutableMapOf<String, Int>()
- for (ingredient in ingredients) {
- val key = ingredient.internalItemId
- requiredIngredients[key] = requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt()
- }
- var hasIngredients = true
- for ((key, value) in requiredIngredients) {
- val sackItem = key.asInternalName().getAmountInSacks()
- if (sackItem < value * (amount - amountInSacks)) {
- hasIngredients = false
- break
- }
- }
- if (hasIngredients) {
- list.add(" §7(§aCraftable!§7)")
- }
- }
+ add(list)
+ }
+ if (totalPrice > 0) {
+ val format = NumberUtil.format(totalPrice)
+ this[0] = listOf("§7Visitor Shopping List: §7(§6$format§7)")
+ }
+ }
- add(list)
- }
- if (totalPrice > 0) {
- val format = NumberUtil.format(totalPrice)
- this[0] = listOf("§7Visitor Shopping List: §7(§6$format§7)")
+ private fun addSackData(
+ internalName: NEUInternalName,
+ amount: Int,
+ list: MutableList<Any>
+ ) {
+ if (!config.shoppingList.showSackCount) return
+
+ var amountInSacks = 0
+ internalName.getAmountInSacksOrNull()?.let {
+ amountInSacks = it
+ val textColour = if (it >= amount) "a" else "e"
+ list.add(" §7(§${textColour}x${it.addSeparators()} §7in sacks)")
+ }
+
+ val ingredients = NEUItems.getRecipes(internalName)
+ // TODO describe what this line does
+ .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") }
+ ?.allIngredients() ?: emptySet()
+ if (ingredients.isEmpty()) return
+
+ val requiredIngredients = mutableMapOf<String, Int>()
+ for (ingredient in ingredients) {
+ val key = ingredient.internalItemId
+ requiredIngredients[key] =
+ requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt()
+ }
+ var hasIngredients = true
+ for ((key, value) in requiredIngredients) {
+ val sackItem = key.asInternalName().getAmountInSacks()
+ if (sackItem < value * (amount - amountInSacks)) {
+ hasIngredients = false
+ break
}
}
+ if (hasIngredients) {
+ list.add(" §7(§aCraftable!§7)")
+ }
}
private fun MutableList<List<Any>>.drawVisitors(