From 35abf8b907c11f534d72314c36d653f7f8e33b7a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:21:54 +0200 Subject: Backend: code cleanup (#1348) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- .../skyhanni/features/nether/KuudraAPI.kt | 67 ---------------------- .../skyhanni/features/nether/kuudra/KuudraAPI.kt | 57 ++++++++++++++++++ .../skyhanni/features/nether/kuudra/KuudraTier.kt | 14 +++++ .../dailyquest/DailyQuestHelper.kt | 4 +- .../dailyquest/quest/KuudraQuest.kt | 2 +- .../kuudra/DailyKuudraBossHelper.kt | 6 +- .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 +- 8 files changed, 79 insertions(+), 75 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/KuudraAPI.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraTier.kt (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c706e6098..e749f688f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -322,7 +322,6 @@ import at.hannibal2.skyhanni.features.misc.trevor.TrevorSolver import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords -import at.hannibal2.skyhanni.features.nether.KuudraAPI import at.hannibal2.skyhanni.features.nether.PabloHelper import at.hannibal2.skyhanni.features.nether.SulphurSkitterBox import at.hannibal2.skyhanni.features.nether.VolcanoExplosivityDisplay @@ -333,6 +332,7 @@ import at.hannibal2.skyhanni.features.nether.ashfang.AshfangGravityOrbs import at.hannibal2.skyhanni.features.nether.ashfang.AshfangHideDamageIndicator import at.hannibal2.skyhanni.features.nether.ashfang.AshfangHideParticles import at.hannibal2.skyhanni.features.nether.ashfang.AshfangNextResetCooldown +import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.area.colosseum.BlobbercystsHighlight diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/KuudraAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/KuudraAPI.kt deleted file mode 100644 index 8bbaa35c9..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/KuudraAPI.kt +++ /dev/null @@ -1,67 +0,0 @@ -package at.hannibal2.skyhanni.features.nether - -import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.events.KuudraCompleteEvent -import at.hannibal2.skyhanni.events.KuudraEnterEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object KuudraAPI { - - private val patternGroup = RepoPattern.group("data.kuudra") - - private val tierPattern by patternGroup.pattern( - "scoreboard.tier", - " §7⏣ §cKuudra's Hollow §8\\(T(?.*)\\)" - ) - private val completePattern by patternGroup.pattern( - "chat.complete", - "§.\\s*(?:§.)*KUUDRA DOWN!" - ) - - var kuudraTier: Int? = null - fun inKuudra() = kuudraTier != null - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (kuudraTier == null) { - for (line in ScoreboardData.sidebarLinesFormatted) { - tierPattern.matchMatcher(line) { - val tier = group("tier").toInt() - kuudraTier = tier - KuudraEnterEvent(tier).postAndCatch() - } - } - } - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - kuudraTier = null - } - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - val message = event.message - completePattern.matchMatcher(message) { - val tier = kuudraTier ?: return - KuudraCompleteEvent(tier).postAndCatch() - } - } - - class KuudraTier( - val name: String, - val displayItem: NEUInternalName, - val location: LorenzVec?, - val tierNumber: Int, - var doneToday: Boolean = false, - ) { - fun getDisplayName() = "Tier $tierNumber ($name)" - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt new file mode 100644 index 000000000..7501cf2b6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt @@ -0,0 +1,57 @@ +package at.hannibal2.skyhanni.features.nether.kuudra + +import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.events.KuudraCompleteEvent +import at.hannibal2.skyhanni.events.KuudraEnterEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object KuudraAPI { + + private val patternGroup = RepoPattern.group("data.kuudra") + + private val tierPattern by patternGroup.pattern( + "scoreboard.tier", + " §7⏣ §cKuudra's Hollow §8\\(T(?.*)\\)" + ) + private val completePattern by patternGroup.pattern( + "chat.complete", + "§.\\s*(?:§.)*KUUDRA DOWN!" + ) + + var kuudraTier: Int? = null + fun inKuudra() = kuudraTier != null + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (kuudraTier != null) return + for (line in ScoreboardData.sidebarLinesFormatted) { + tierPattern.matchMatcher(line) { + val tier = group("tier").toInt() + kuudraTier = tier + KuudraEnterEvent(tier).postAndCatch() + } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + kuudraTier = null + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + val message = event.message + completePattern.matchMatcher(message) { + val tier = kuudraTier ?: return + KuudraCompleteEvent(tier).postAndCatch() + } + } + +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraTier.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraTier.kt new file mode 100644 index 000000000..0c6e91e26 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraTier.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.features.nether.kuudra + +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NEUInternalName + +class KuudraTier( + val name: String, + val displayItem: NEUInternalName, + val location: LorenzVec?, + val tierNumber: Int, + var doneToday: Boolean = false, +) { + fun getDisplayName() = "Tier $tierNumber ($name)" +} 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 ae6850e78..30356b9c9 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 @@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent -import at.hannibal2.skyhanni.features.nether.KuudraAPI +import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.FactionType import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.DojoQuest @@ -263,7 +263,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } } - fun finishKuudra(kuudraTier: KuudraAPI.KuudraTier) { + fun finishKuudra(kuudraTier: KuudraTier) { val kuudraQuest = getQuest() ?: return // TODO make inline method for this two lines if (kuudraQuest.kuudraTier == kuudraTier && kuudraQuest.state == QuestState.ACCEPTED) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt index aadb9f110..4671c5daf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest -import at.hannibal2.skyhanni.features.nether.KuudraAPI.KuudraTier +import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier class KuudraQuest(val kuudraTier: KuudraTier, state: QuestState) : Quest( diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt index 265f59471..8b6a05f38 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson.ReputationQuest import at.hannibal2.skyhanni.events.KuudraCompleteEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.features.nether.KuudraAPI +import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils @@ -20,7 +20,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { - val kuudraTiers = mutableListOf() + val kuudraTiers = mutableListOf() private var kuudraLocation: LorenzVec? = null private var allKuudraDone = true @@ -93,7 +93,7 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH if (location != null) { kuudraLocation = location } - kuudraTiers.add(KuudraAPI.KuudraTier(displayName, displayItem, location, tier)) + kuudraTiers.add(KuudraTier(displayName, displayItem, location, tier)) tier++ } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index a9b72f72c..861530a58 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords -import at.hannibal2.skyhanni.features.nether.KuudraAPI +import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.utils.ChatUtils.lastButtonClicked -- cgit