aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/BankDetection.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-02-15 18:05:28 +0100
committerLinnea Gräf <nea@nea.moe>2024-02-15 18:05:28 +0100
commitee5d205578117d6fab9b2f89871e5442e480644f (patch)
tree60753f880972e85e39ed9c1e98bb534253cbd535 /src/main/kotlin/moe/nea/ledger/BankDetection.kt
downloadLocalTransactionLedger-ee5d205578117d6fab9b2f89871e5442e480644f.tar.gz
LocalTransactionLedger-ee5d205578117d6fab9b2f89871e5442e480644f.tar.bz2
LocalTransactionLedger-ee5d205578117d6fab9b2f89871e5442e480644f.zip
Initial commit
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/BankDetection.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/BankDetection.kt40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/BankDetection.kt b/src/main/kotlin/moe/nea/ledger/BankDetection.kt
new file mode 100644
index 0000000..6e54539
--- /dev/null
+++ b/src/main/kotlin/moe/nea/ledger/BankDetection.kt
@@ -0,0 +1,40 @@
+package moe.nea.ledger
+
+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 (?<amount>$SHORT_NUMBER_PATTERN) coins?! You now have (?<newtotal>$SHORT_NUMBER_PATTERN) coins? in your account!$")
+ val depositPattern =
+ Pattern.compile("^You have deposited (?<amount>$SHORT_NUMBER_PATTERN) coins?! You now have (?<newtotal>$SHORT_NUMBER_PATTERN) coins? in your account!$")
+ @SubscribeEvent
+ fun onChat(event: ChatReceived) {
+ withdrawPattern.useMatcher(event.message) {
+ ledger.logEntry(
+ LedgerEntry(
+ "BANK_WITHDRAW",
+ event.timestamp,
+ parseShortNumber(group("amount")),
+ )
+ )
+ }
+ depositPattern.useMatcher(event.message) {
+ ledger.logEntry(
+ LedgerEntry(
+ "BANK_DEPOSIT",
+ event.timestamp,
+ parseShortNumber(group("amount")),
+ )
+ )
+ }
+ }
+
+}