aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-15 22:07:19 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-15 22:07:19 +0100
commitce9cbd10d24d287bcb630900d14a9d5b1369f3b5 (patch)
treee79abdc420c3535009fd2c30aa0bb403bc44f599 /src/main/java
parentd39621e047877117fe7082b324c6403013dfb9b7 (diff)
downloadskyhanni-ce9cbd10d24d287bcb630900d14a9d5b1369f3b5.tar.gz
skyhanni-ce9cbd10d24d287bcb630900d14a9d5b1369f3b5.tar.bz2
skyhanni-ce9cbd10d24d287bcb630900d14a9d5b1369f3b5.zip
Allowing nullable parameters for regex functions matches() and find().
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt4
3 files changed, 4 insertions, 4 deletions
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() }