aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorjani270 <69345714+jani270@users.noreply.github.com>2025-01-20 22:50:42 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-21 00:15:49 +0100
commit7375808ececd341d92533bc52c583524d25af792 (patch)
treead4bd210f9b877fd817d99c0afe1626c4a2126db /mod
parent4e20d0e95b2fe6ef71a33f41f9cd8cebd06cf982 (diff)
downloadLocalTransactionLedger-7375808ececd341d92533bc52c583524d25af792.tar.gz
LocalTransactionLedger-7375808ececd341d92533bc52c583524d25af792.tar.bz2
LocalTransactionLedger-7375808ececd341d92533bc52c583524d25af792.zip
feat: Bank Interest Detection
Diffstat (limited to 'mod')
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/Ledger.kt2
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt38
2 files changed, 40 insertions, 0 deletions
diff --git a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
index 5db4346..06ee9c9 100644
--- a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
+++ b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
@@ -16,6 +16,7 @@ import moe.nea.ledger.modules.AccessorySwapperDetection
import moe.nea.ledger.modules.AllowanceDetection
import moe.nea.ledger.modules.AuctionHouseDetection
import moe.nea.ledger.modules.BankDetection
+import moe.nea.ledger.modules.BankInterestDetection
import moe.nea.ledger.modules.BazaarDetection
import moe.nea.ledger.modules.BazaarOrderDetection
import moe.nea.ledger.modules.BitsDetection
@@ -127,6 +128,7 @@ class Ledger {
AllowanceDetection::class.java,
AuctionHouseDetection::class.java,
BankDetection::class.java,
+ BankInterestDetection::class.java,
BazaarDetection::class.java,
BazaarOrderDetection::class.java,
BitsDetection::class.java,
diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt
new file mode 100644
index 0000000..1e8da23
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt
@@ -0,0 +1,38 @@
+package moe.nea.ledger.modules
+
+import moe.nea.ledger.ItemChange
+import moe.nea.ledger.LedgerEntry
+import moe.nea.ledger.LedgerLogger
+import moe.nea.ledger.SHORT_NUMBER_PATTERN
+import moe.nea.ledger.TransactionType
+import moe.nea.ledger.events.ChatReceived
+import moe.nea.ledger.parseShortNumber
+import moe.nea.ledger.useMatcher
+import moe.nea.ledger.utils.di.Inject
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+
+class BankInterestDetection {
+
+ val bankInterestPattern =
+ Pattern.compile("You have just received (?<coins>$SHORT_NUMBER_PATTERN) coins as interest in your (co-op|personal) bank account!")
+
+ @Inject
+ lateinit var logger: LedgerLogger
+
+ @SubscribeEvent
+ fun onChat(event: ChatReceived) {
+ bankInterestPattern.useMatcher(event.message) {
+ logger.logEntry(
+ LedgerEntry(
+ TransactionType.BANK_WITHDRAW,
+ event.timestamp,
+ listOf(
+ ItemChange.gainCoins(parseShortNumber(group("coins"))),
+ )
+ )
+ )
+ }
+ }
+}