diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
7 files changed, 48 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt index 31b85ddd0..c30299e4f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt @@ -1,8 +1,9 @@ package at.hannibal2.skyhanni.features.combat import at.hannibal2.skyhanni.SkyHanniMod +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.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst @@ -20,16 +21,18 @@ object FerocityDisplay { */ private val ferocityPattern by RepoPattern.pattern( "combat.ferocity.tab", - " Ferocity: §r§c⫽(?<stat>.*)" + " Ferocity: §r§c⫽(?<stat>.*)", ) private var display = "" @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { + fun onTabListUpdate(event: WidgetUpdateEvent) { if (!isEnabled()) return + if (!event.isWidget(TabWidget.STATS, TabWidget.DUNGEON_SKILLS_AND_STATS)) return display = "" - val stat = event.tabList.matchFirst(ferocityPattern) { + if (event.isClear()) return + val stat = event.lines.matchFirst(ferocityPattern) { group("stat") } ?: return 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()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt index 6cb7f3bf4..441dac11b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt @@ -2,11 +2,12 @@ package at.hannibal2.skyhanni.features.nether import at.hannibal2.skyhanni.SkyHanniMod 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.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -22,14 +23,21 @@ object VolcanoExplosivityDisplay { */ private val statusPattern by patternGroup.pattern( "tablistline", - " *Volcano: (?<status>(?:§.)*\\S+)" + " *Volcano: (?<status>(?:§.)*\\S+)", ) private var display = "" @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { + fun onTabListUpdate(event: WidgetUpdateEvent) { if (!isEnabled()) return - event.tabList.matchFirst(statusPattern) { + if (!event.isWidget(TabWidget.VOLCANO)) return + + if (event.isClear()) { + display = "" + return + } + // TODO merge widget pattern with statusPattern + statusPattern.matchMatcher(event.lines.first()) { display = "§bVolcano Explosivity§7: ${group("status")}" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index d0b37ffcd..ef7423990 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -65,7 +65,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { */ val minibossAmountPattern by RepoPattern.pattern( "crimson.reputationhelper.quest.minibossamount", - "(?:§7Kill the §c.+ §7|.*)miniboss §a(?<amount>\\d) §7times?!" + "(?:§7Kill the §c.+ §7|.*)miniboss §a(?<amount>\\d) §7times?!", ) private val config get() = SkyHanniMod.feature.crimsonIsle.reputationHelper @@ -87,11 +87,11 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } @SubscribeEvent - fun onTabListWidgetUpdate(event: WidgetUpdateEvent) { - if (event.isWidget(TabWidget.FACTION_QUESTS)) { - if (!isEnabled()) return - questLoader.loadFromTabList() - } + fun onTabListUpdate(event: WidgetUpdateEvent) { + if (!event.isWidget(TabWidget.FACTION_QUESTS)) return + if (!isEnabled()) return + + questLoader.loadFromTabList() } @SubscribeEvent @@ -211,7 +211,8 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } private fun Quest.needsTownBoardLocation(): Boolean = state.let { state -> - state == QuestState.READY_TO_COLLECT || state == QuestState.NOT_ACCEPTED || + state == QuestState.READY_TO_COLLECT || + state == QuestState.NOT_ACCEPTED || (this is RescueMissionQuest && state == QuestState.ACCEPTED) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index 694ebed35..686f46827 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -214,7 +214,8 @@ class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { quest.haveAmount = haveAmount } catch (e: IndexOutOfBoundsException) { ErrorManager.logErrorWithData( - e, "Error loading Crimson Isle Quests from config.", + e, + "Error loading Crimson Isle Quests from config.", "text" to text, ) } |