diff options
author | Linnea Gräf <nea@nea.moe> | 2024-04-02 16:01:38 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-04-02 16:01:38 +0200 |
commit | 3e0198e3a803d2dd46988ba0ac445412c7da8390 (patch) | |
tree | 6f08cebe11894769ead7ce7473b27dbdf21523d5 /src/main/kotlin/moe/nea/ledger/BitsDetection.kt | |
parent | 8d26a206297071775e88b99d4b38efcc5577af0a (diff) | |
download | LocalTransactionLedger-3e0198e3a803d2dd46988ba0ac445412c7da8390.tar.gz LocalTransactionLedger-3e0198e3a803d2dd46988ba0ac445412c7da8390.tar.bz2 LocalTransactionLedger-3e0198e3a803d2dd46988ba0ac445412c7da8390.zip |
Add bits stuff
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/BitsDetection.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/BitsDetection.kt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/BitsDetection.kt b/src/main/kotlin/moe/nea/ledger/BitsDetection.kt new file mode 100644 index 0000000..2d26b3d --- /dev/null +++ b/src/main/kotlin/moe/nea/ledger/BitsDetection.kt @@ -0,0 +1,48 @@ +package moe.nea.ledger + +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.time.Instant + +class BitsDetection(val ledger: LedgerLogger) { + + var lastBits = -1 + + val bitScoreboardRegex = "Bits: (?<purse>$SHORT_NUMBER_PATTERN)".toPattern() + + @SubscribeEvent + fun onWorldSwitch(event: LateWorldLoadEvent) { + ScoreboardUtil.getScoreboardStrings().forEach { + bitScoreboardRegex.useMatcher<Unit>(it.unformattedString()) { + val bits = parseShortNumber(group("purse")).toInt() + if (lastBits != bits) { + ledger.logEntry( + LedgerEntry( + "BITS_PURSE_STATUS", + Instant.now(), + 0.0, + null, + bits + ) + ) + lastBits = bits + } + return + } + } + } + + @SubscribeEvent + fun onEvent(event: ChatReceived) { + if (event.message.startsWith("You consumed a Booster Cookie!")) { + ledger.logEntry( + LedgerEntry( + "BOOSTER_COOKIE_ATE", + Instant.now(), + 0.0, + null, + null, + ) + ) + } + } +} |