aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index 5fc4474d9..9aee4035d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -33,10 +33,12 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.SpecialColour
+import at.hannibal2.skyhanni.utils.StringUtils.find
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
@@ -61,12 +63,14 @@ class MinionFeatures {
private var lastInventoryClosed = 0L
private var coinsPerDay = ""
- private val minionUpgradePattern = "§aYou have upgraded your Minion to Tier (?<tier>.*)".toPattern()
- private val minionCoinPattern = "§aYou received §r§6(.*) coins§r§a!".toPattern()
+ private val minionUpgradePattern by RepoPattern.pattern("minion.chat.upgrade", "§aYou have upgraded your Minion to Tier (?<tier>.*)")
+ private val minionCoinPattern by RepoPattern.pattern("minion.chat.coin", "§aYou received §r§6(.*) coins§r§a!")
+ private val minionTitlePattern by RepoPattern.pattern("minion.title", "Minion [^➜]")
+ private val minionCollectItemPattern by RepoPattern.pattern("minion.item.collect", "^§aCollect All$")
@SubscribeEvent
fun onPlayerInteract(event: PlayerInteractEvent) {
- if (!enableWithHub()) return
+ if (!enable()) return
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return
val lookingAt = event.pos.offset(event.face).toLorenzVec()
@@ -126,10 +130,10 @@ class MinionFeatures {
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (!enableWithHub()) return
- if (!event.inventoryName.contains("Minion ")) return
+ if (!minionTitlePattern.find(event.inventoryName)) return
event.inventoryItems[48]?.let {
- if ("§aCollect All" == it.name) {
+ if (minionCollectItemPattern.matches(it.name ?: "")) {
MinionOpenEvent(event.inventoryName, event.inventoryItems).postAndCatch()
return
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index cb7a0fa23..5cde8f6f9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -263,4 +263,6 @@ object StringUtils {
}
fun Pattern.matches(string: String) = matcher(string).matches()
+
+ fun Pattern.find(string: String) = matcher(string).find()
}