aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-10 11:19:37 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-04-10 11:19:37 +0200
commitc5c4886ac28d3ed40413ecf88cc26dd72cdc28fe (patch)
tree77c1fe2f861e3f83e309d084a88106988b600e47 /src/main/java/at/hannibal2
parentf541212f286940b7260df85ab419a02228daf1ea (diff)
downloadskyhanni-c5c4886ac28d3ed40413ecf88cc26dd72cdc28fe.tar.gz
skyhanni-c5c4886ac28d3ed40413ecf88cc26dd72cdc28fe.tar.bz2
skyhanni-c5c4886ac28d3ed40413ecf88cc26dd72cdc28fe.zip
fix pricePerCopper being null sometimes, and code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt19
2 files changed, 15 insertions, 11 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 479569961..676c1f492 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
@@ -106,9 +106,14 @@ object GardenVisitorFeatures {
@SubscribeEvent
fun onVisitorOpen(event: VisitorOpenEvent) {
val visitor = event.visitor
- val offerItem = visitor.offer!!.offerItem
+ val offerItem = visitor.offer?.offerItem ?: return
val lore = offerItem.getLore()
+
+ // TODO make this workaround unnecessary (only read non lore info)
+ readToolTip(visitor, offerItem, lore.toMutableList())
+ visitor.lastLore = emptyList()
+
for (line in lore) {
if (line == "ยง7Items Required:") continue
if (line.isEmpty()) break
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 295e3c08e..2a4a8db4b 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
@@ -193,23 +193,22 @@ object VisitorAPI {
return visitorsInTab
}
- fun Visitor.blockReason(): VisitorBlockReason? {
-
- val visitorHasReward = config.rewardWarning.preventRefusing && this.hasReward() != null
+ fun Visitor.blockReason(): VisitorBlockReason? = with(config.rewardWarning) {
+ val visitorHasReward = preventRefusing && hasReward() != null
if (visitorHasReward) {
return VisitorBlockReason.RARE_REWARD
}
- else if (config.rewardWarning.preventRefusingNew && this.offersAccepted == 0) {
+ if (preventRefusingNew && offersAccepted == 0) {
return VisitorBlockReason.NEVER_ACCEPTED
}
- val pricePerCopper = this.pricePerCopper ?: return VisitorBlockReason.EXPENSIVE_COPPER
- return if (config.rewardWarning.preventRefusingCopper && pricePerCopper <= config.rewardWarning.coinsPerCopperPrice) {
- VisitorBlockReason.CHEAP_COPPER
+ val pricePerCopper = pricePerCopper ?: error("pricePerCopper is null")
+ if (preventRefusingCopper && pricePerCopper <= coinsPerCopperPrice) {
+ return VisitorBlockReason.CHEAP_COPPER
}
- else if (config.rewardWarning.preventAcceptingCopper && pricePerCopper > config.rewardWarning.coinsPerCopperPrice) {
- VisitorBlockReason.EXPENSIVE_COPPER
+ if (preventAcceptingCopper && pricePerCopper > coinsPerCopperPrice) {
+ return VisitorBlockReason.EXPENSIVE_COPPER
}
- else null
+ return null
}
enum class VisitorBlockReason(val description: String, val blockRefusing: Boolean) {