Skip to content

Commit

Permalink
migrate PurseAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed Jan 1, 2024
1 parent f83cea4 commit db09cf4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.NumberUtil.milion
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

class PurseAPI {
// TODO USE SH-REPO
private val pattern = "(Piggy|Purse): §6(?<coins>[\\d,]*).*".toPattern()
private val coinsPattern by RepoPattern.pattern(
"data.purse.coins",
"(Piggy|Purse): §6(?<coins>[\\d,]+).*"
)

private var currentPurse = 0.0
private var inventoryCloseTime = 0L

Expand All @@ -25,7 +29,7 @@ class PurseAPI {
fun onTick(event: LorenzTickEvent) {

for (line in ScoreboardData.sidebarLinesFormatted) {
val newPurse = pattern.matchMatcher(line) {
val newPurse = coinsPattern.matchMatcher(line) {
group("coins").formatNumber().toDouble()
} ?: continue
val diff = newPurse - currentPurse
Expand Down

0 comments on commit db09cf4

Please sign in to comment.