From 9d3913018df1ee642a0ddc17d68a5c3c6bda8055 Mon Sep 17 00:00:00 2001 From: martimavocado <39881008+martimavocado@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:39:04 +0100 Subject: Fix: Stranded Placable NPCs (#2071) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/stranded/HighlightPlaceableNpcs.kt | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt index c5bab7fc8..82d57cac6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt @@ -21,9 +21,24 @@ object HighlightPlaceableNpcs { private val config get() = SkyHanniMod.feature.misc.stranded - private val locationPattern by RepoPattern.pattern( - "stranded.highlightplacement.location", - "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]" + private val patternGroup = RepoPattern.group("stranded.highlightplacement") + + // TODO Please add regex tests + private val locationPattern by patternGroup.pattern( + "location", + "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]", + ) + + // TODO Please add regex tests + private val clickToSetPattern by RepoPattern.pattern( + "clicktoset", + "§7§eClick to set the location of this NPC!", + ) + + // TODO Please add regex tests + private val clickToSpawnPattern by RepoPattern.pattern( + "clicktospawn", + "§elocation!", ) private var inInventory = false @@ -69,7 +84,9 @@ object HighlightPlaceableNpcs { private fun isPlaceableNpc(lore: List): Boolean { // Checking if NPC & placeable - if (lore.isEmpty() || !(lore.last() == "§ethis NPC!" || lore.last() == "§eyour location!")) { + if (lore.isEmpty() || + !(clickToSetPattern.matches(lore.last()) || + clickToSpawnPattern.matches(lore.last()))) { return false } -- cgit