From d392c8085486b7d6b3c6a0e0707dd0ffc72224fa Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Mon, 5 Feb 2024 22:05:53 +0100 Subject: Fix: "Piece of wizard portal earned" shows duplicate somtimes (#982) Fixed showing the Piece of wizard portal earned duplicate. #982 --- .../features/misc/RestorePieceOfWizardPortalLore.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt index fe21f488f..deedd7f98 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt @@ -3,8 +3,11 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getRecipientName +import at.hannibal2.skyhanni.utils.StringUtils.anyMatches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class RestorePieceOfWizardPortalLore { @@ -13,15 +16,15 @@ class RestorePieceOfWizardPortalLore { private val item by lazy { "WIZARD_PORTAL_MEMENTO".asInternalName() } + private val earnedPattern by RepoPattern.pattern("misc.restore.wizard.portal.earned", "§7Earned by:.*") + @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { if (!config.restorePieceOfWizardPortalLore) return val stack = event.itemStack if (stack.getInternalName() != item) return + if (earnedPattern.anyMatches(stack.getLore())) return val recipient = stack.getRecipientName() ?: return - if (!event.toolTip[5].contains(recipient)) { - event.toolTip.add(5, "§7Earned by: $recipient") - } + event.toolTip.add(5, "§7Earned by: $recipient") } - -} \ No newline at end of file +} -- cgit