aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt
blob: 5aaa5fa3a35774ac2d2e8331c385c88def2c0e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package moe.nea.firmament.gui.config

import net.minecraft.client.gui.screen.Screen
import moe.nea.firmament.util.compatloader.CompatLoader

interface FirmamentConfigScreenProvider {
	val key: String
	val isEnabled: Boolean get() = true

	fun open(parent: Screen?): Screen

	companion object : CompatLoader<FirmamentConfigScreenProvider>(FirmamentConfigScreenProvider::class) {
		val providers by lazy {
			allValidInstances
				.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()
		}
	}
}