diff options
Diffstat (limited to 'mod/src/main')
-rw-r--r-- | mod/src/main/kotlin/moe/nea/ledger/Ledger.kt | 2 | ||||
-rw-r--r-- | mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt | 38 |
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"))), + ) + ) + ) + } + } +} |