diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-01 23:00:53 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-01 23:00:53 +0100 |
commit | 8b410fbdf2cffb3ceaa51bbea150f5165848bc37 (patch) | |
tree | e4b4ec4ba24a7edbefa45b7deb2503b74214ee02 /src/main/kotlin/util | |
parent | 653454e290a1bb6142e2bb40947239c2e450820b (diff) | |
download | Firmament-8b410fbdf2cffb3ceaa51bbea150f5165848bc37.tar.gz Firmament-8b410fbdf2cffb3ceaa51bbea150f5165848bc37.tar.bz2 Firmament-8b410fbdf2cffb3ceaa51bbea150f5165848bc37.zip |
Add tint override to texture packs
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r-- | src/main/kotlin/util/ErrorUtil.kt | 14 | ||||
-rw-r--r-- | src/main/kotlin/util/filter/IteratorFilterSet.kt | 33 |
2 files changed, 14 insertions, 33 deletions
diff --git a/src/main/kotlin/util/ErrorUtil.kt b/src/main/kotlin/util/ErrorUtil.kt index 4f229af..afecf25 100644 --- a/src/main/kotlin/util/ErrorUtil.kt +++ b/src/main/kotlin/util/ErrorUtil.kt @@ -7,10 +7,24 @@ object ErrorUtil { Thread.currentThread().stackTrace.any { it.className.startsWith("org.junit.") } || Firmament.DEBUG } + inline fun softCheck(message: String, func: () -> Boolean) { + if (!aggressiveErrors) return + if (func()) return + error(message) + } + @Suppress("NOTHING_TO_INLINE") // Suppressed since i want the logger to not pick up the ErrorUtil stack-frame inline fun softError(message: String) { if (aggressiveErrors) error(message) else Firmament.logger.error(message) } + inline fun <T : Any> notNullOr(nullable: T?, message: String, orElse: () -> T): T { + if (nullable == null) { + softError(message) + return orElse() + } + return nullable + } + } diff --git a/src/main/kotlin/util/filter/IteratorFilterSet.kt b/src/main/kotlin/util/filter/IteratorFilterSet.kt deleted file mode 100644 index 483b8d9..0000000 --- a/src/main/kotlin/util/filter/IteratorFilterSet.kt +++ /dev/null @@ -1,33 +0,0 @@ - -package moe.nea.firmament.util.filter - -abstract class IteratorFilterSet<K>(val original: java.util.Set<K>) : java.util.Set<K> by original { - abstract fun shouldKeepElement(element: K): Boolean - - override fun iterator(): MutableIterator<K> { - val parentIterator = original.iterator() - return object : MutableIterator<K> { - var lastEntry: K? = null - override fun hasNext(): Boolean { - while (lastEntry == null) { - if (!parentIterator.hasNext()) - break - val element = parentIterator.next() - if (!shouldKeepElement(element)) continue - lastEntry = element - } - return lastEntry != null - } - - override fun next(): K { - if (!hasNext()) throw NoSuchElementException() - return lastEntry ?: throw NoSuchElementException() - } - - override fun remove() { - TODO("Not yet implemented") - } - } - } -} - |