diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-13 19:53:10 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-13 19:53:10 +0200 |
commit | 87b851373071490bb371ba1160f85f0341579cb2 (patch) | |
tree | 45d267d83baad2e3cb6caad6127f6a4d40e7fcbf /src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt | |
parent | e6142bb93619dee768fc18b87ffdd28558d4bcab (diff) | |
download | Firmament-87b851373071490bb371ba1160f85f0341579cb2.tar.gz Firmament-87b851373071490bb371ba1160f85f0341579cb2.tar.bz2 Firmament-87b851373071490bb371ba1160f85f0341579cb2.zip |
Add YACL config menu
Diffstat (limited to 'src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt')
-rw-r--r-- | src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt index 582f701..82e151e 100644 --- a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt +++ b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt @@ -6,22 +6,29 @@ import net.minecraft.client.gui.screen.Screen import moe.nea.firmament.Firmament interface FirmamentConfigScreenProvider { - val key: String - val isEnabled: Boolean get() = true + val key: String + val isEnabled: Boolean get() = true - fun open(parent: Screen?): Screen + fun open(parent: Screen?): Screen - companion object { - private val loader = ServiceLoader.load(FirmamentConfigScreenProvider::class.java) + companion object { + private val loader = ServiceLoader.load(FirmamentConfigScreenProvider::class.java) - val providers by lazy { - loader.stream().asSequence().mapNotNull { service -> - kotlin.runCatching { service.get() } - .getOrElse { - Firmament.logger.warn("Could not load config provider ${service.type()}", it) - null - } - }.filter { it.isEnabled }.toList() - } - } + val providers by lazy { + loader.stream().asSequence().mapNotNull { service -> + kotlin.runCatching { service.get() } + .getOrElse { + Firmament.logger.warn("Could not load config provider ${service.type()}", it) + null + } + }.filter { it.isEnabled } + .sortedWith(Comparator.comparing( + { it.key }, + Comparator<String> { left, right -> + if (left == "builtin") return@Comparator -1 + if (right == "builtin") return@Comparator 1 + return@Comparator left.compareTo(right) + })).toList() + } + } } |