Skip to content

Commit

Permalink
Backend: Cleanup some scoreboard event stuff (#1940)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
CalMWolfs and hannibal002 authored Jun 16, 2024
1 parent cb828a9 commit b81197a
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/HotmData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package at.hannibal2.skyhanni.events

class RawScoreboardUpdateEvent(val rawScoreboard: List<String>) : LorenzEvent()

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package at.hannibal2.skyhanni.events

class ScoreboardUpdateEvent(val scoreboard: List<String>) : LorenzEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit b81197a

Please sign in to comment.