aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt8
2 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt
index c21b2f384..9c5eac610 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data
object PetAPI {
+ // Contains color code + name and for older SkyHanni users maybe also the pet level
var currentPet: String?
get() = ProfileStorageData.profileSpecific?.currentPet
set(value) {
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 7855a94b9..128e9a126 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,8 @@ class CurrentPetDisplay {
private val config get() = SkyHanniMod.feature.misc.pets
// TODO USE SH-REPO
- private val inventoryNamePattern = "(?:\\(\\d+/\\d+\\))? Pets".toPattern()
+ 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()
private val chatPetRulePattern = "§cAutopet §eequipped your §7\\[Lvl .*] (?<pet>.*)! §a§lVIEW RULE".toPattern()
@@ -49,12 +50,11 @@ class CurrentPetDisplay {
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
- if (!inventoryNamePattern.matcher(event.inventoryName).matches()) return
+ if (!inventoryNamePattern.matches(event.inventoryName)) return
val lore = event.inventoryItems[4]?.getLore() ?: return
- val selectedPetPattern = "§7§7Selected pet: (?<pet>.*)".toPattern()
for (line in lore) {
- selectedPetPattern.matchMatcher(line) {
+ inventorySelectedPetPattern.matchMatcher(line) {
val newPet = group("pet")
PetAPI.currentPet = if (newPet != "§cNone") newPet else ""
}