diff options
3 files changed, 50 insertions, 0 deletions
diff --git a/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt b/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt index 8424893..a3910a0 100644 --- a/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt +++ b/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt @@ -31,6 +31,7 @@ enum class TransactionType { KUUDRA_CHEST_OPEN, NPC_BUY, NPC_SELL, + PEST_REPELLENT_USED, VISITOR_BARGAIN, WYRM_EVOKED, }
\ No newline at end of file diff --git a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt index e0382a9..5db4346 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt @@ -35,6 +35,7 @@ import moe.nea.ledger.modules.KuudraChestDetection import moe.nea.ledger.modules.MineshaftCorpseDetection import moe.nea.ledger.modules.MinionDetection import moe.nea.ledger.modules.NpcDetection +import moe.nea.ledger.modules.PestRepellentDetection import moe.nea.ledger.modules.UpdateChecker import moe.nea.ledger.modules.VisitorDetection import moe.nea.ledger.utils.ErrorUtil @@ -152,6 +153,7 @@ class Ledger { MineshaftCorpseDetection::class.java, MinionDetection::class.java, NpcDetection::class.java, + PestRepellentDetection::class.java, QueryCommand::class.java, RequestUtil::class.java, TriggerCommand::class.java, diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/PestRepellentDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/PestRepellentDetection.kt new file mode 100644 index 0000000..f627393 --- /dev/null +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/PestRepellentDetection.kt @@ -0,0 +1,47 @@ +package moe.nea.ledger.modules + +import moe.nea.ledger.ItemChange +import moe.nea.ledger.LedgerEntry +import moe.nea.ledger.LedgerLogger +import moe.nea.ledger.TransactionType +import moe.nea.ledger.events.ChatReceived +import moe.nea.ledger.gen.ItemIds +import moe.nea.ledger.useMatcher +import moe.nea.ledger.utils.di.Inject +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class PestRepellentDetection { + + val pestRepellent = "YUM! Pests will now spawn (?<reduction>[2-4])x less while you break crops for the next 60m!".toPattern() + + @Inject + lateinit var logger: LedgerLogger + + @SubscribeEvent + fun onChat(event: ChatReceived) { + pestRepellent.useMatcher(event.message) { + val reductionAmount = group("reduction") + if (reductionAmount == "2") { + logger.logEntry( + LedgerEntry( + TransactionType.PEST_REPELLENT_USED, + event.timestamp, + listOf( + ItemChange.lose(ItemIds.PEST_REPELLENT, 1), + ) + ) + ) + } else if (reductionAmount == "4"){ + logger.logEntry( + LedgerEntry( + TransactionType.PEST_REPELLENT_USED, + event.timestamp, + listOf( + ItemChange.lose(ItemIds.PEST_REPELLENT_MAX, 1), + ) + ) + ) + } + } + } +}
\ No newline at end of file |