aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt15
5 files changed, 17 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 839bc8269..2bc382375 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -627,7 +627,7 @@ class SkyHanniMod {
loadModule(MiscFeatures())
loadModule(GardenPlotMenuHighlighting())
loadModule(SkyMartCopperPrice())
- loadModule(GardenVisitorFeatures())
+ loadModule(GardenVisitorFeatures)
loadModule(NPCVisitorFix)
loadModule(GardenInventoryNumbers())
loadModule(GardenVisitorTimer())
diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt
deleted file mode 100644
index 1bee8cff6..000000000
--- a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package at.hannibal2.skyhanni.events.garden.visitor
-
-import at.hannibal2.skyhanni.events.LorenzEvent
-import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI
-import net.minecraft.item.ItemStack
-
-class VisitorToolTipEvent(val visitor: VisitorAPI.Visitor, val itemStack: ItemStack, val toolTip: MutableList<String>) :
- LorenzEvent() \ No newline at end of file
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 f29fd4faf..cfa4fdfb3 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
@@ -18,7 +18,6 @@ import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorRefusedEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorRenderEvent
-import at.hannibal2.skyhanni.events.garden.visitor.VisitorToolTipEvent
import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed
@@ -63,14 +62,13 @@ import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.item.ItemStack
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.round
import kotlin.time.Duration.Companion.seconds
private val config get() = VisitorAPI.config
-class GardenVisitorFeatures {
+object GardenVisitorFeatures {
private var display = emptyList<List<Any>>()
@@ -297,16 +295,13 @@ class GardenVisitorFeatures {
}
}
- @SubscribeEvent(priority = EventPriority.HIGH)
- fun onVisitorTooltip(event: VisitorToolTipEvent) {
- if (event.itemStack.name != "§aAccept Offer") return
+ fun onTooltip(visitor: VisitorAPI.Visitor, itemStack: ItemStack, toolTip: MutableList<String>) {
+ if (itemStack.name != "§aAccept Offer") return
- val visitor = event.visitor
- val toolTip = event.toolTip
toolTip.clear()
if (visitor.lastLore.isEmpty()) {
- readToolTip(visitor, event.itemStack)
+ readToolTip(visitor, itemStack)
}
toolTip.addAll(visitor.lastLore)
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 18bdcb49e..dab1d40e7 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
@@ -26,7 +26,7 @@ object VisitorAPI {
private val logger = LorenzLogger("garden/visitors/api")
val patternGroup = RepoPattern.group("garden.visitor.api")
- private val visitorCountPattern by patternGroup.pattern(
+ val visitorCountPattern by patternGroup.pattern(
"visitor.count",
"§b§lVisitors: §r§f\\((?<info>.*)\\)"
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
index 653290395..8693053ab 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
@@ -12,11 +12,11 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorRenderEvent
-import at.hannibal2.skyhanni.events.garden.visitor.VisitorToolTipEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.VisitorStatus
import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
@@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiContainer
@@ -43,7 +44,6 @@ class VisitorListener {
private val logger = LorenzLogger("garden/visitors/listener")
companion object {
-
private val VISITOR_INFO_ITEM_SLOT = 13
private val VISITOR_ACCEPT_ITEM_SLOT = 29
private val VISITOR_REFUSE_ITEM_SLOT = 33
@@ -70,8 +70,11 @@ class VisitorListener {
@SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
if (!GardenAPI.inGarden()) return
- val visitorsInTab = VisitorAPI.visitorsInTabList(event.tabList)
+ val hasVisitorInfo = event.tabList.any { VisitorAPI.visitorCountPattern.matches(it) }
+ if (!hasVisitorInfo) return
+
+ val visitorsInTab = VisitorAPI.visitorsInTabList(event.tabList)
if (LorenzUtils.lastWorldSwitch.passedSince() > 2.seconds) {
VisitorAPI.getVisitors().forEach {
val name = it.visitorName
@@ -160,6 +163,10 @@ class VisitorListener {
}
VisitorAPI.changeStatus(visitor, VisitorStatus.REFUSED, "refused")
+ // fallback if tab list is disabled
+ DelayedRun.runDelayed(10.seconds) {
+ VisitorAPI.removeVisitor(visitor.visitorName)
+ }
return
}
if (event.slotId == VISITOR_ACCEPT_ITEM_SLOT && event.slot?.stack?.getLore()
@@ -175,7 +182,7 @@ class VisitorListener {
if (!GardenAPI.onBarnPlot) return
if (!VisitorAPI.inInventory) return
val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return
- VisitorToolTipEvent(visitor, event.itemStack, event.toolTip).postAndCatch()
+ GardenVisitorFeatures.onTooltip(visitor, event.itemStack, event.toolTip)
}
@SubscribeEvent