aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAlexia Luna <me@alexia.lol>2024-03-21 17:19:27 +0100
committerGitHub <noreply@github.com>2024-03-21 17:19:27 +0100
commit8ce4327242ec7c0e0f55a32c50d0ebf2884ff85c (patch)
treef95783c03761136dc24bfa1d03fc49a880722a10 /src/main
parentd67ebf595c7a7f62ae103a384c90f9ca73f5e05e (diff)
downloadskyhanni-8ce4327242ec7c0e0f55a32c50d0ebf2884ff85c.tar.gz
skyhanni-8ce4327242ec7c0e0f55a32c50d0ebf2884ff85c.tar.bz2
skyhanni-8ce4327242ec7c0e0f55a32c50d0ebf2884ff85c.zip
Fix: Visitor status not updating in some cases (#1224)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt1
2 files changed, 21 insertions, 20 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 e051520f2..7f31b2640 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
@@ -133,14 +133,11 @@ class GardenVisitorFeatures {
readToolTip(visitor, offerItem)
- if (visitor.status == VisitorAPI.VisitorStatus.NEW) {
- val alreadyReady = offerItem.getLore().any { it == "§eClick to give!" }
- if (alreadyReady) {
- VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.READY, "inSacks")
- visitor.inSacks = true
- } else {
- VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.WAITING, "firstContact")
- }
+ val alreadyReady = offerItem.getLore().any { it == "§eClick to give!" }
+ if (alreadyReady) {
+ VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.READY, "tooltipClickToGive")
+ } else {
+ VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.WAITING, "tooltipMissingItems")
}
update()
}
@@ -505,12 +502,14 @@ class GardenVisitorFeatures {
}
}
- if (!visitor.inSacks) {
- val status = visitor.status
- if (status == VisitorAPI.VisitorStatus.WAITING || status == VisitorAPI.VisitorStatus.READY) {
- val newStatus =
- if (hasItemsInInventory(visitor)) VisitorAPI.VisitorStatus.READY else VisitorAPI.VisitorStatus.WAITING
- VisitorAPI.changeStatus(visitor, newStatus, "hasItemsInInventory")
+ if (visitor.status in setOf(VisitorAPI.VisitorStatus.WAITING, VisitorAPI.VisitorStatus.READY)) {
+ var newStatus: VisitorAPI.VisitorStatus
+ if (hasItems(visitor)) {
+ newStatus = VisitorAPI.VisitorStatus.READY
+ VisitorAPI.changeStatus(visitor, newStatus, "hasItems")
+ } else {
+ newStatus = VisitorAPI.VisitorStatus.WAITING
+ VisitorAPI.changeStatus(visitor, newStatus, "noLongerHasItems")
}
}
@@ -538,10 +537,16 @@ class GardenVisitorFeatures {
}
}
- private fun hasItemsInInventory(visitor: VisitorAPI.Visitor): Boolean {
+ private fun hasItems(visitor: VisitorAPI.Visitor): Boolean {
var ready = true
for ((internalName, required) in visitor.shoppingList) {
- val having = InventoryUtils.getAmountOfItemInInventory(internalName)
+ val inventoryAmount = InventoryUtils.getAmountOfItemInInventory(internalName)
+
+ val sackItemData = SackAPI.fetchSackItem(internalName)
+ val sacksAmount = sackItemData.amount
+
+ val having = inventoryAmount + sacksAmount
+
if (having < required) {
ready = false
}
@@ -622,9 +627,6 @@ class GardenVisitorFeatures {
add(" ")
add("visitorName: '${visitor.visitorName}'")
add("status: '${visitor.status}'")
- if (visitor.inSacks) {
- add("inSacks!")
- }
if (visitor.shoppingList.isNotEmpty()) {
add("shoppingList: '${visitor.shoppingList}'")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
index cfd32e5e0..18bdcb49e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
@@ -121,7 +121,6 @@ object VisitorAPI {
var entityId: Int = -1,
var nameTagEntityId: Int = -1,
var status: VisitorStatus,
- var inSacks: Boolean = false,
val shoppingList: MutableMap<NEUInternalName, Int> = mutableMapOf(),
var offer: VisitorOffer? = null,
) {