From 5cabbcd9bc250c1d7b4f16c31ffd9aac4095a221 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 8 Oct 2023 15:27:57 +0200 Subject: Fixed a crash with future NEU versions because of renamed code. --- .../at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt index c43215d6b..4870e2e6d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -58,13 +59,25 @@ class PetExpTooltip { index = toolTip.indexOfFirst { it.contains("Progress to Level") } if (index != -1) { - val offset = if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) 4 else 3 + + val offset = if (isNeuExtendedExpEnabled) 4 else 3 return index + offset } return null } + private val isNeuExtendedExpEnabled get() = fieldPetExtendExp.get(objectNeuTooltipTweaks) as Boolean + + private val objectNeuTooltipTweaks by lazy { + val field = NotEnoughUpdates.INSTANCE.config.javaClass.getDeclaredField("tooltipTweaks") + field.makeAccessible().get(NotEnoughUpdates.INSTANCE.config) + } + + private val fieldPetExtendExp by lazy { + objectNeuTooltipTweaks.javaClass.getDeclaredField("petExtendExp").makeAccessible() + } + private fun getMaxValues(petName: String, petExperience: Double): Pair { val useGoldenDragonLevels = petName.contains("Golden Dragon") && (!config.showGoldenDragonEgg || petExperience >= level100Legendary) -- cgit