diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-06-23 18:13:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-23 18:13:52 +0200 |
commit | cc291932906c38943e20cee29ee591695a9875b5 (patch) | |
tree | b7290d5ef35cd89fcd8f331ae4d70d0428301b0a /src/main/java/at/hannibal2/skyhanni/features/garden | |
parent | 796bdf65f24057d170b91cc043a7fa8e024905ad (diff) | |
download | skyhanni-cc291932906c38943e20cee29ee591695a9875b5.tar.gz skyhanni-cc291932906c38943e20cee29ee591695a9875b5.tar.bz2 skyhanni-cc291932906c38943e20cee29ee591695a9875b5.zip |
Backend: Usage of TabWidget (#1240)
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
3 files changed, 18 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt index b154a72e0..127ee3f30 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt @@ -4,8 +4,9 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.setCounter import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay import at.hannibal2.skyhanni.features.garden.pests.PestAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -86,8 +87,9 @@ object GardenCropMilestoneFix { } @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { - event.tabList.matchFirst(tabListPattern) { + fun onTabListUpdate(event: WidgetUpdateEvent) { + if (!event.isWidget(TabWidget.CROP_MILESTONE)) return + event.lines.matchFirst(tabListPattern) { val tier = group("tier").toInt() val percentage = group("percentage").toDouble() val cropName = group("crop") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt index bd4c8274c..7c88acfca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt @@ -3,8 +3,9 @@ package at.hannibal2.skyhanni.features.garden.composter import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -53,10 +54,11 @@ object ComposterDisplay { } @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { + fun onTabListUpdate(event: WidgetUpdateEvent) { if (!(config.displayEnabled && GardenAPI.inGarden())) return + if (!event.isWidget(TabWidget.COMPOSTER)) return - readData(event.tabList) + readData(event.lines) if (tabListData.isNotEmpty()) { composterEmptyTime = ComposterAPI.estimateEmptyTimeFromTab() @@ -137,8 +139,7 @@ object ComposterDisplay { storage.informedAboutLowMatter = 5.0.minutes.fromNow() } - if (ComposterAPI.getFuel() <= config.notifyLow.fuel && storage.informedAboutLowFuel.isInPast() - ) { + if (ComposterAPI.getFuel() <= config.notifyLow.fuel && storage.informedAboutLowFuel.isInPast()) { if (config.notifyLow.title) { LorenzUtils.sendTitle("§cYour Fuel is low", 4.seconds) } 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 2914aa1c3..66d03745f 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 @@ -3,13 +3,14 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorRenderEvent import at.hannibal2.skyhanni.events.item.ItemHoverEvent @@ -42,7 +43,7 @@ import kotlin.time.Duration.Companion.seconds object VisitorListener { private val offersAcceptedPattern by RepoPattern.pattern( "garden.visitor.offersaccepted", - "§7Offers Accepted: §a(?<offersAccepted>\\d+)" + "§7Offers Accepted: §a(?<offersAccepted>\\d+)", ) private val config get() = VisitorAPI.config @@ -68,13 +69,14 @@ object VisitorListener { } @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { + fun onTabListUpdate(event: WidgetUpdateEvent) { if (!GardenAPI.inGarden()) return + if (!event.isWidget(TabWidget.VISITORS)) return - val hasVisitorInfo = event.tabList.any { VisitorAPI.visitorCountPattern.matches(it) } + val hasVisitorInfo = event.lines.any { VisitorAPI.visitorCountPattern.matches(it) } if (!hasVisitorInfo) return - val visitorsInTab = VisitorAPI.visitorsInTabList(event.tabList) + val visitorsInTab = VisitorAPI.visitorsInTabList(event.lines) if (LorenzUtils.lastWorldSwitch.passedSince() > 2.seconds) { for (visitor in VisitorAPI.getVisitors()) { |