From aee1bd5207a3193d05068fc046ef01e06fc1be67 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 17 Nov 2023 12:15:40 +0100 Subject: Fixed opening the Pet menu no longer updating current pet display. --- src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt | 1 + .../java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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: (?.*)".toPattern() private val chatSpawnPattern = "§aYou summoned your §r(?.*)§r§a!".toPattern() private val chatDespawnPattern = "§aYou despawned your §r.*§r§a!".toPattern() private val chatPetRulePattern = "§cAutopet §eequipped your §7\\[Lvl .*] (?.*)! §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: (?.*)".toPattern() for (line in lore) { - selectedPetPattern.matchMatcher(line) { + inventorySelectedPetPattern.matchMatcher(line) { val newPet = group("pet") PetAPI.currentPet = if (newPet != "§cNone") newPet else "" } -- cgit