From ce9cbd10d24d287bcb630900d14a9d5b1369f3b5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 15 Jan 2024 22:07:19 +0100 Subject: Allowing nullable parameters for regex functions matches() and find(). --- .../at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt | 2 +- src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt | 2 +- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt index db1375b75..9a18572b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt @@ -29,7 +29,7 @@ object ShiftClickNPCSell { @SubscribeEvent fun onOpen(event: InventoryFullyOpenedEvent) { if (!LorenzUtils.inSkyBlock) return - inInventory = lastLoreLineOfSellPattern.matches(event.inventoryItems[sellSlot]?.getLore()?.lastOrNull() ?: "") + inInventory = lastLoreLineOfSellPattern.matches(event.inventoryItems[sellSlot]?.getLore()?.lastOrNull()) } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index 9aee4035d..f5552701e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -133,7 +133,7 @@ class MinionFeatures { if (!minionTitlePattern.find(event.inventoryName)) return event.inventoryItems[48]?.let { - if (minionCollectItemPattern.matches(it.name ?: "")) { + if (minionCollectItemPattern.matches(it.name)) { MinionOpenEvent(event.inventoryName, event.inventoryItems).postAndCatch() return } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 7c33cd1b2..b25c47aae 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -281,9 +281,9 @@ object StringUtils { fun String.convertToFormatted(): String = this.replace("&&", "ยง") - fun Pattern.matches(string: String) = matcher(string).matches() + fun Pattern.matches(string: String?) = string?.let { matcher(it).matches() } ?: false - fun Pattern.find(string: String) = matcher(string).find() + fun Pattern.find(string: String?) = string?.let { matcher(it).find() } ?: false fun String.allLettersFirstUppercase() = split("_").joinToString(" ") { it.firstLetterUppercase() } -- cgit