aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/nea')
-rw-r--r--src/main/java/moe/nea/ledger/BazaarDetection.kt39
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(),
+ )
+ )
+ }
+ }
+}