diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-05 12:07:44 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-05 12:07:44 +0100 |
commit | 03ce43d928d18328e0cd731f161a7bfd794af3d3 (patch) | |
tree | 43d15879072646aadb03e212bb21fea60b3eeb59 /src/main | |
parent | 95029eebcc73feac8842e953239cb71a0c1d1b48 (diff) | |
download | skyhanni-03ce43d928d18328e0cd731f161a7bfd794af3d3.tar.gz skyhanni-03ce43d928d18328e0cd731f161a7bfd794af3d3.tar.bz2 skyhanni-03ce43d928d18328e0cd731f161a7bfd794af3d3.zip |
Moving pet menu check into PetAPI
Diffstat (limited to 'src/main')
4 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 72c7709e7..42c4d70a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -31,6 +31,7 @@ import at.hannibal2.skyhanni.data.MinecraftData import at.hannibal2.skyhanni.data.OtherInventoryData import at.hannibal2.skyhanni.data.OwnInventoryData import at.hannibal2.skyhanni.data.PartyAPI +import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.PurseAPI import at.hannibal2.skyhanni.data.RenderData @@ -441,6 +442,7 @@ class SkyHanniMod { loadModule(GardenBestCropTime()) loadModule(TrackerManager) loadModule(UtilsPatterns) + loadModule(PetAPI) // APIs loadModule(BazaarApi()) diff --git a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt index d8061683b..f422c0b12 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt @@ -1,6 +1,15 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern + object PetAPI { + private val petMenuPattern by RepoPattern.pattern( + "misc.pet.menu.title", + "Pets(?: \\(\\d+/\\d+\\) )?" + ) + + fun isPetMenu(inventoryTitle: String): Boolean = petMenuPattern.matches(inventoryTitle) // Contains color code + name and for older SkyHanni users maybe also the pet level var currentPet: String? diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index f93192a3d..d8fd9f13d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide import at.hannibal2.skyhanni.config.Storage +import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -49,10 +50,6 @@ class CaptureFarmingGear { "uniquevisitors.tierprogress", ".* §e(?<having>.*)§6/(?<total>.*)" ) - private val petMenuPattern by patternGroup.pattern( - "petsmenu", - "Pets(?: \\(\\d+/\\d+\\) )?" - ) companion object { private val strengthPattern = " Strength: §r§c❁(?<strength>.*)".toPattern() @@ -131,7 +128,7 @@ class CaptureFarmingGear { val farmingItems = farmingItems ?: return val outdatedItems = outdatedItems ?: return val items = event.inventoryItems - petMenuPattern.matchMatcher(event.inventoryName) { + if (PetAPI.isPetMenu(event.inventoryName)) { pets(farmingItems, items, outdatedItems) return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt index d4cc01fbd..ebff243f9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt @@ -18,7 +18,6 @@ class CurrentPetDisplay { private val config get() = SkyHanniMod.feature.misc.pets // TODO USE SH-REPO - private val inventoryNamePattern = "Pets( \\(\\d+/\\d+\\) )?".toPattern() private val inventorySelectedPetPattern = "§7§7Selected pet: (?<pet>.*)".toPattern() private val chatSpawnPattern = "§aYou summoned your §r(?<pet>.*)§r§a!".toPattern() private val chatDespawnPattern = "§aYou despawned your §r.*§r§a!".toPattern() @@ -50,7 +49,7 @@ class CurrentPetDisplay { @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!inventoryNamePattern.matches(event.inventoryName)) return + if (!PetAPI.isPetMenu(event.inventoryName)) return val lore = event.inventoryItems[4]?.getLore() ?: return for (line in lore) { |