diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-18 14:57:07 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-18 14:57:07 +0200 |
commit | a39f6e9bec3318b2be251570ea7aea29d58b49cb (patch) | |
tree | e7d93e4243c172f80111e18768f5ee7ec19fb3f5 /src/main/kotlin/moe/nea/firmament/util/listutil.kt | |
parent | ad09808c25c769be760559e1a597e29e488827bf (diff) | |
download | firmament-a39f6e9bec3318b2be251570ea7aea29d58b49cb.tar.gz firmament-a39f6e9bec3318b2be251570ea7aea29d58b49cb.tar.bz2 firmament-a39f6e9bec3318b2be251570ea7aea29d58b49cb.zip |
Fix item rarity not displaying in npc shops
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/listutil.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/listutil.kt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/listutil.kt b/src/main/kotlin/moe/nea/firmament/util/listutil.kt new file mode 100644 index 0000000..b72457f --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/util/listutil.kt @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.util + +fun <T, R> List<T>.lastNotNullOfOrNull(func: (T) -> R?): R? { + for (i in indices.reversed()) { + return func(this[i]) ?: continue + } + return null +} |