Add configured compat
[no changelog]
This commit is contained in:
@@ -146,7 +146,9 @@ public class AutoDiscoveryPlugin {
|
||||
*/
|
||||
private void walkDir(Path classRoot) {
|
||||
System.out.println("Trying to find mixins from directory");
|
||||
try (Stream<Path> classes = Files.walk(classRoot.resolve(getMixinBaseDir()))) {
|
||||
var path = classRoot.resolve(getMixinBaseDir());
|
||||
if (!Files.exists(path)) return;
|
||||
try (Stream<Path> classes = Files.walk(path)) {
|
||||
classes.map(it -> classRoot.relativize(it).toString())
|
||||
.forEach(this::tryAddMixinClass);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
package moe.nea.firmament.gui.config
|
||||
|
||||
import io.github.notenoughupdates.moulconfig.observer.ObservableList
|
||||
@@ -36,10 +34,16 @@ object AllConfigsGui {
|
||||
}
|
||||
}
|
||||
|
||||
fun makeScreen(parent: Screen? = null): Screen {
|
||||
fun makeBuiltInScreen(parent: Screen? = null): Screen {
|
||||
return MoulConfigUtils.loadScreen("config/main", MainMapping(allConfigs), parent)
|
||||
}
|
||||
|
||||
fun makeScreen(parent: Screen? = null): Screen {
|
||||
val provider = FirmamentConfigScreenProvider.providers.find { it.key == "builtin" }
|
||||
?: FirmamentConfigScreenProvider.providers.first()
|
||||
return provider.open(parent)
|
||||
}
|
||||
|
||||
fun showAllGuis() {
|
||||
setScreenLater(makeScreen())
|
||||
}
|
||||
|
||||
14
src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt
Normal file
14
src/main/kotlin/gui/config/BuiltInConfigScreenProvider.kt
Normal file
@@ -0,0 +1,14 @@
|
||||
package moe.nea.firmament.gui.config
|
||||
|
||||
import com.google.auto.service.AutoService
|
||||
import net.minecraft.client.gui.screen.Screen
|
||||
|
||||
@AutoService(FirmamentConfigScreenProvider::class)
|
||||
class BuiltInConfigScreenProvider : FirmamentConfigScreenProvider {
|
||||
override val key: String
|
||||
get() = "builtin"
|
||||
|
||||
override fun open(parent: Screen?): Screen {
|
||||
return AllConfigsGui.makeBuiltInScreen(parent)
|
||||
}
|
||||
}
|
||||
27
src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt
Normal file
27
src/main/kotlin/gui/config/FirmamentConfigScreenProvider.kt
Normal file
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,8 @@ abstract class ManagedConfig(override val name: String) : ManagedConfigElement()
|
||||
latestGuiAppender?.reloadables?.forEach { it() }
|
||||
}
|
||||
|
||||
val labelText = Text.translatable("firmament.config.${name}")
|
||||
val translationKey get() = "firmament.config.${name}"
|
||||
val labelText = Text.translatable(translationKey)
|
||||
|
||||
fun getConfigEditor(parent: Screen? = null): Screen {
|
||||
var screen: Screen? = null
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"firmament.poweruser.entity.armor": "Entity Armor:",
|
||||
"firmament.poweruser.entity.armor.item": " - %s",
|
||||
"firmament.poweruser.entity.passengers": "%s Passengers",
|
||||
"firmament.config.all-configs": "- All Configs -",
|
||||
"firmament.config.anniversary": "Anniversary Features",
|
||||
"firmament.config.anniversary.shiny-pigs": "Shiny Pigs Tracker",
|
||||
"firmament.config.anniversary.pig-hud": "Pig Tracker Hud",
|
||||
|
||||
@@ -50,6 +50,11 @@
|
||||
"roughlyenoughitems": ">=${rei_version}"
|
||||
},
|
||||
"custom": {
|
||||
"configured": {
|
||||
"providers": [
|
||||
"moe.nea.firmament.compat.configured.ConfiguredCompat"
|
||||
]
|
||||
},
|
||||
"modmenu": {
|
||||
"links": {
|
||||
"modmenu.discord": "https://discord.gg/64pFP94AWA"
|
||||
|
||||
7
src/main/resources/firmament.mixins.json
Normal file
7
src/main/resources/firmament.mixins.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"required": true,
|
||||
"plugin": "moe.nea.firmament.init.MixinPlugin",
|
||||
"package": "moe.nea.firmament.mixins",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"refmap": "Firmament-refmap.json"
|
||||
}
|
||||
3
src/main/resources/firmament.mixins.json.license
Normal file
3
src/main/resources/firmament.mixins.json.license
Normal file
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
Reference in New Issue
Block a user