diff options
author | Linnea Gräf <nea@nea.moe> | 2024-08-31 11:59:47 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-08-31 11:59:47 +0200 |
commit | 816f80f862d2f5de6bc9b0ae84cd6df0da341228 (patch) | |
tree | ee8aaccbaebe5a024549c2530319ed09a02cc4e4 /src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt | |
parent | d2f240ff0ca0d27f417f837e706c781a98c31311 (diff) | |
download | firmament-816f80f862d2f5de6bc9b0ae84cd6df0da341228.tar.gz firmament-816f80f862d2f5de6bc9b0ae84cd6df0da341228.tar.bz2 firmament-816f80f862d2f5de6bc9b0ae84cd6df0da341228.zip |
Add configured compat
[no changelog]
Diffstat (limited to 'src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt')
-rw-r--r-- | src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt new file mode 100644 index 0000000..582f701 --- /dev/null +++ b/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt @@ -0,0 +1,27 @@ +package moe.nea.firmament.gui.config + +import java.util.ServiceLoader +import kotlin.streams.asSequence +import net.minecraft.client.gui.screen.Screen +import moe.nea.firmament.Firmament + +interface FirmamentConfigScreenProvider { + val key: String + val isEnabled: Boolean get() = true + + fun open(parent: Screen?): Screen + + 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() + } + } +} |