diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-02-22 21:54:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-22 21:54:12 +0100 |
commit | 7bde14535264d20e37c5c085f8a03db3275044b5 (patch) | |
tree | 7b5a2852057fd89dd1a1622f2f25c1808938677c /src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt | |
parent | 3994a15d86eee42023e3715a671c85de243ea226 (diff) | |
download | skyhanni-7bde14535264d20e37c5c085f8a03db3275044b5.tar.gz skyhanni-7bde14535264d20e37c5c085f8a03db3275044b5.tar.bz2 skyhanni-7bde14535264d20e37c5c085f8a03db3275044b5.zip |
Removed duplicate pet level detection logic. #1027
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt index d5efd3735..2a0f97ae2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt @@ -12,13 +12,22 @@ object PetAPI { ) private val petItemName by patternGroup.pattern( "item.name", - "§.\\[Lvl (?<level>\\d)] (?<name>.*)" + "(?:§.)*\\[Lvl (?<level>\\d+)] (?<name>.*)" ) private val neuRepoPetItemName by patternGroup.pattern( "item.name.neu.format", "(§f§f)?§7\\[Lvl 1➡(100|200)] (?<name>.*)" ) + private val ignoredPetStrings = listOf( + "Archer", + "Berserk", + "Mage", + "Tank", + "Healer", + "➡", + ) + fun isPetMenu(inventoryTitle: String): Boolean = petMenuPattern.matches(inventoryTitle) // Contains color code + name and for older SkyHanni users maybe also the pet level @@ -40,4 +49,10 @@ object PetAPI { return null } + + fun getPetLevel(nameWithLevel: String): Int? = petItemName.matchMatcher(nameWithLevel) { + group("level").toInt() + } + + fun hasPetName(name: String): Boolean = petItemName.matches(name) && !ignoredPetStrings.any { name.contains(it) } } |