diff options
author | Linnea Gräf <nea@nea.moe> | 2024-02-15 18:19:25 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-02-15 18:19:25 +0100 |
commit | e5d2966e05fcaca533c09ab5ec5bfd825848be02 (patch) | |
tree | cca954e984af21d3a8b346f803d9c7b1da657f14 /src/main/java/moe/nea/ledger/BazaarDetection.kt | |
parent | ee5d205578117d6fab9b2f89871e5442e480644f (diff) | |
download | money-ledger-e5d2966e05fcaca533c09ab5ec5bfd825848be02.tar.gz money-ledger-e5d2966e05fcaca533c09ab5ec5bfd825848be02.tar.bz2 money-ledger-e5d2966e05fcaca533c09ab5ec5bfd825848be02.zip |
Add insta sell support
Diffstat (limited to 'src/main/java/moe/nea/ledger/BazaarDetection.kt')
-rw-r--r-- | src/main/java/moe/nea/ledger/BazaarDetection.kt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/ledger/BazaarDetection.kt b/src/main/java/moe/nea/ledger/BazaarDetection.kt new file mode 100644 index 0000000..aa3aeba --- /dev/null +++ b/src/main/java/moe/nea/ledger/BazaarDetection.kt @@ -0,0 +1,39 @@ +package moe.nea.ledger + +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +class BazaarDetection(val ledger: LedgerLogger) { + + val instaBuyPattern = + Pattern.compile("\\[Bazaar\\] Bought (?<count>[0-9]+)x (?<what>.*) for (?<coins>$SHORT_NUMBER_PATTERN) coins!") + val instaSellPattern = + Pattern.compile("\\[Bazaar\\] Sold (?<count>[0-9]+)x (?<what>.*) for (?<coins>$SHORT_NUMBER_PATTERN) coins!") + + + @SubscribeEvent + fun onInstSellChat(event: ChatReceived) { + instaBuyPattern.useMatcher(event.message) { + ledger.logEntry( + LedgerEntry( + "BAZAAR_BUY_INSTANT", + event.timestamp, + parseShortNumber(group("coins")), + group("what"), + group("count").toInt(), + ) + ) + } + instaSellPattern.useMatcher(event.message) { + ledger.logEntry( + LedgerEntry( + "BAZAAR_SELL_INSTANT", + event.timestamp, + parseShortNumber(group("coins")), + group("what"), + group("count").toInt(), + ) + ) + } + } +} |