diff options
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt index 3e55f93ac..61381bc7e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.features.inventory.bazaar import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -20,7 +21,7 @@ class BazaarCancelledBuyOrderClipboard { private val patternGroup = RepoPattern.group("bazaar.cancelledorder") /** - * REGEX-TEST: §6§7from §a59§7x §7missing items. + * REGEX-TEST: §6§7from §a50§7x §7missing items. */ private val lastAmountPattern by patternGroup.pattern( "lastamount", @@ -30,14 +31,18 @@ class BazaarCancelledBuyOrderClipboard { "cancelledmessage", "§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(?<coins>.*) coins §r§7from cancelling Buy Order!" ) + private val inventoryTitlePattern by patternGroup.pattern( + "inventorytitle", + "Order options" + ) private var latestAmount: Int? = null @SubscribeEvent - fun onTooltip(event: LorenzToolTipEvent) { + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!isEnabled()) return - - val stack = event.itemStack + if (!inventoryTitlePattern.matches(event.inventoryName)) return + val stack = event.inventoryItems[11] ?: return if (!stack.name.contains("Cancel Order")) return stack.getLore().matchFirst(lastAmountPattern) { @@ -49,7 +54,7 @@ class BazaarCancelledBuyOrderClipboard { fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return val coins = cancelledMessagePattern.matchMatcher(event.message) { - group("coins") + group("coins").formatInt().addSeparators() } ?: return val latestAmount = latestAmount ?: error("latest amount is null") |