From b81197a01853cf819450aeac9c155935e424c5a5 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Mon, 17 Jun 2024 02:17:14 +1000 Subject: Backend: Cleanup some scoreboard event stuff (#1940) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt | 6 +++--- src/main/java/at/hannibal2/skyhanni/data/HotmData.kt | 6 +++--- src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt | 6 +++--- src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt | 6 +++--- src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt | 8 ++++---- .../java/at/hannibal2/skyhanni/events/RawScoreboardUpdateEvent.kt | 3 +++ .../java/at/hannibal2/skyhanni/events/ScoreboardChangeEvent.kt | 3 --- .../java/at/hannibal2/skyhanni/events/ScoreboardRawChangeEvent.kt | 3 --- .../java/at/hannibal2/skyhanni/events/ScoreboardUpdateEvent.kt | 3 +++ .../java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt | 6 +++--- .../features/rift/area/stillgorechateau/RiftBloodEffigies.kt | 6 +++--- .../at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt | 8 ++++---- 12 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/events/RawScoreboardUpdateEvent.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/events/ScoreboardChangeEvent.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/events/ScoreboardRawChangeEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/ScoreboardUpdateEvent.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index c7c8925c7..72928fd25 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.data.FameRanks.getFameRankByNameOrNull import at.hannibal2.skyhanni.events.BitsUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter @@ -143,9 +143,9 @@ object BitsAPI { ) @SubscribeEvent - fun onScoreboardChange(event: ScoreboardChangeEvent) { + fun onScoreboardChange(event: ScoreboardUpdateEvent) { if (!isEnabled()) return - for (line in event.newList) { + for (line in event.scoreboard) { val message = line.trimWhiteSpace().removeResets() bitsScoreboardPattern.matchMatcher(message) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt index d232e49bb..3f2d54b31 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt @@ -11,7 +11,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager @@ -644,10 +644,10 @@ enum class HotmData( } @SubscribeEvent - fun onScoreboardUpdate(event: ScoreboardChangeEvent) { + fun onScoreboardUpdate(event: ScoreboardUpdateEvent) { if (!LorenzUtils.inSkyBlock) return - event.newList.matchFirst(ScoreboardPattern.powderPattern) { + event.scoreboard.matchFirst(ScoreboardPattern.powderPattern) { val type = HotmAPI.Powder.entries.firstOrNull { it.lowName == group("type") } ?: return val amount = group("amount").formatLong() val difference = amount - type.getCurrent() diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt index 289c9c58b..47d38ef74 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PlaySoundEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.mining.OreMinedEvent import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern @@ -102,8 +102,8 @@ object MiningAPI { fun inColdIsland() = inAnyIsland(IslandType.DWARVEN_MINES, IslandType.MINESHAFT) @SubscribeEvent - fun onScoreboardChange(event: ScoreboardChangeEvent) { - val newCold = event.newList.matchFirst(ScoreboardPattern.coldPattern) { + fun onScoreboardChange(event: ScoreboardUpdateEvent) { + val newCold = event.scoreboard.matchFirst(ScoreboardPattern.coldPattern) { group("cold").toInt().absoluteValue } ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index 5c7f94aed..a5a8eb184 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.NumberUtil.million @@ -36,8 +36,8 @@ object PurseAPI { } @SubscribeEvent - fun onScoreboardChange(event: ScoreboardChangeEvent) { - event.newList.matchFirst(coinsPattern) { + fun onScoreboardChange(event: ScoreboardUpdateEvent) { + event.scoreboard.matchFirst(coinsPattern) { val newPurse = group("coins").formatDouble() val diff = newPurse - currentPurse if (diff == 0.0) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 72abf6bab..b24f08b04 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent -import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent +import at.hannibal2.skyhanni.events.RawScoreboardUpdateEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -74,14 +74,14 @@ object ScoreboardData { val list = fetchScoreboardLines().reversed() val semiFormatted = list.map { cleanSB(it) } if (semiFormatted != sidebarLines) { - ScoreboardRawChangeEvent(sidebarLines, semiFormatted).postAndCatch() + RawScoreboardUpdateEvent(semiFormatted).postAndCatch() sidebarLines = semiFormatted } sidebarLinesRaw = list val new = formatLines(list) if (new != sidebarLinesFormatted) { - ScoreboardChangeEvent(sidebarLinesFormatted, new).postAndCatch() + ScoreboardUpdateEvent(new).postAndCatch() sidebarLinesFormatted = new } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/RawScoreboardUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RawScoreboardUpdateEvent.kt new file mode 100644 index 000000000..ac11a5bcb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/RawScoreboardUpdateEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.events + +class RawScoreboardUpdateEvent(val rawScoreboard: List) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/ScoreboardChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ScoreboardChangeEvent.kt deleted file mode 100644 index a9fa81a41..000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/ScoreboardChangeEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package at.hannibal2.skyhanni.events - -class ScoreboardChangeEvent(val oldList: List, val newList: List) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/ScoreboardRawChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ScoreboardRawChangeEvent.kt deleted file mode 100644 index c1f667ee3..000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/ScoreboardRawChangeEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package at.hannibal2.skyhanni.events - -class ScoreboardRawChangeEvent(val oldList: List, val newList: List) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/ScoreboardUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ScoreboardUpdateEvent.kt new file mode 100644 index 000000000..9480e8061 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/ScoreboardUpdateEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.events + +class ScoreboardUpdateEvent(val scoreboard: List) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt index 2ac40e252..02b62c0fb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.events.ItemInHandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.garden.pests.PestSpawnEvent import at.hannibal2.skyhanni.events.garden.pests.PestUpdateEvent @@ -219,10 +219,10 @@ object PestAPI { } @SubscribeEvent - fun onScoreboardChange(event: ScoreboardChangeEvent) { + fun onScoreboardChange(event: ScoreboardUpdateEvent) { if (!GardenAPI.inGarden()) return if (!firstScoreboardCheck) return - checkScoreboardLines(event.newList) + checkScoreboardLines(event.scoreboard) } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt index 123748a53..647b2280b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.RiftEffigiesJson import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.RawScoreboardUpdateEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -80,10 +80,10 @@ object RiftBloodEffigies { } @SubscribeEvent - fun onScoreboardChange(event: ScoreboardRawChangeEvent) { + fun onScoreboardChange(event: RawScoreboardUpdateEvent) { if (!isEnabled()) return - val line = event.newList.firstOrNull { it.startsWith("Effigies:") } ?: return + val line = event.rawScoreboard.firstOrNull { it.startsWith("Effigies:") } ?: return val hearts = heartsPattern.matchMatcher(line) { group("hearts") } ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 92d4872c7..188283fbd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.ItemClickEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -42,9 +42,9 @@ object SlayerQuestWarning { } @SubscribeEvent - fun onScoreboardChange(event: ScoreboardChangeEvent) { - val slayerType = event.newList.nextAfter("Slayer Quest") - val slayerProgress = event.newList.nextAfter("Slayer Quest", skip = 2) ?: "no slayer" + fun onScoreboardChange(event: ScoreboardUpdateEvent) { + val slayerType = event.scoreboard.nextAfter("Slayer Quest") + val slayerProgress = event.scoreboard.nextAfter("Slayer Quest", skip = 2) ?: "no slayer" val new = slayerProgress.removeColor() val slayerData = getSlayerData() -- cgit