blob: 1cb23bc31762b6e2cb98c08a4ec376a12eb72f09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package moe.nea.ledger
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
class BazaarOrderDetection(val ledger: LedgerLogger, val ids: ItemIdProvider) {
val buyOrderClaimed =
Pattern.compile("\\[Bazaar] Claimed (?<amount>$SHORT_NUMBER_PATTERN)x (?<what>.*) worth (?<coins>$SHORT_NUMBER_PATTERN) coins? bought for $SHORT_NUMBER_PATTERN each!")
val sellOrderClaimed =
Pattern.compile("\\[Bazaar] Claimed (?<coins>$SHORT_NUMBER_PATTERN) coins? from selling (?<amount>$SHORT_NUMBER_PATTERN)x (?<what>.*) at $SHORT_NUMBER_PATTERN each!")
@SubscribeEvent
fun detectBuyOrders(event: ChatReceived) {
buyOrderClaimed.useMatcher(event.message) {
ledger.logEntry(
LedgerEntry(
"BAZAAR_BUY_ORDER",
event.timestamp,
parseShortNumber(group("coins")),
ids.findForName(group("what")),
parseShortNumber(group("amount")).toInt(),
)
)
}
sellOrderClaimed.useMatcher(event.message) {
ledger.logEntry(
LedgerEntry(
"BAZAAR_SELL_ORDER",
event.timestamp,
parseShortNumber(group("coins")),
ids.findForName(group("what")),
parseShortNumber(group("amount")).toInt(),
)
)
}
}
}
|