From e5d2966e05fcaca533c09ab5ec5bfd825848be02 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 15 Feb 2024 18:19:25 +0100 Subject: Add insta sell support --- src/main/java/moe/nea/ledger/BazaarDetection.kt | 39 +++++++++++++++++++++++++ src/main/kotlin/moe/nea/ledger/BankDetection.kt | 7 ----- src/main/kotlin/moe/nea/ledger/Ledger.kt | 1 + 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 src/main/java/moe/nea/ledger/BazaarDetection.kt (limited to 'src') 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 (?[0-9]+)x (?.*) for (?$SHORT_NUMBER_PATTERN) coins!") + val instaSellPattern = + Pattern.compile("\\[Bazaar\\] Sold (?[0-9]+)x (?.*) for (?$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(), + ) + ) + } + } +} diff --git a/src/main/kotlin/moe/nea/ledger/BankDetection.kt b/src/main/kotlin/moe/nea/ledger/BankDetection.kt index 6e54539..3e37658 100644 --- a/src/main/kotlin/moe/nea/ledger/BankDetection.kt +++ b/src/main/kotlin/moe/nea/ledger/BankDetection.kt @@ -4,13 +4,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern class BankDetection(val ledger: LedgerLogger) { - - /* - You have withdrawn 1M coins! You now have 518M coins in your account! - You have deposited 519M coins! You now have 519M coins in your account! - */ - - val withdrawPattern = Pattern.compile("^You have withdrawn (?$SHORT_NUMBER_PATTERN) coins?! You now have (?$SHORT_NUMBER_PATTERN) coins? in your account!$") val depositPattern = diff --git a/src/main/kotlin/moe/nea/ledger/Ledger.kt b/src/main/kotlin/moe/nea/ledger/Ledger.kt index 63be626..773f90e 100644 --- a/src/main/kotlin/moe/nea/ledger/Ledger.kt +++ b/src/main/kotlin/moe/nea/ledger/Ledger.kt @@ -40,6 +40,7 @@ class Ledger { listOf( this, BankDetection(ledger), + BazaarDetection(ledger) ).forEach(MinecraftForge.EVENT_BUS::register) } -- cgit