diff --git a/common/src/main/java/ho/artisan/azusaconfig/AzusaConfigExpectPlatform.java b/common/src/main/java/ho/artisan/azusaconfig/AzusaConfigExpectPlatform.java index 11c61af..bf42ce0 100644 --- a/common/src/main/java/ho/artisan/azusaconfig/AzusaConfigExpectPlatform.java +++ b/common/src/main/java/ho/artisan/azusaconfig/AzusaConfigExpectPlatform.java @@ -1,6 +1,7 @@ package ho.artisan.azusaconfig; import dev.architectury.injectables.annotations.ExpectPlatform; +import dev.architectury.injectables.annotations.PlatformOnly; import java.nio.file.Path; import java.util.List; @@ -12,9 +13,10 @@ public static Path getConfigDirectory() { throw new AssertionError(); } -// @ExpectPlatform -// public static List getEntrypoints(String key, Class type) { -// // Just throw an error, the content should get replaced at runtime. -// throw new AssertionError(); -// } + @PlatformOnly("fabric") + @ExpectPlatform + public static List getEntrypoints(String key, Class type) { + // Just throw an error, the content should get replaced at runtime. + throw new AssertionError(); + } } diff --git a/common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java b/common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java index 49f3fb2..8f0c498 100644 --- a/common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java +++ b/common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java @@ -21,12 +21,14 @@ import java.util.LinkedHashMap; import java.util.Map; +import dev.architectury.injectables.targets.ArchitecturyTarget; import ho.artisan.azusaconfig.AzusaConfigExpectPlatform; import ho.artisan.azusaconfig.AzusaConfigMod; -import org.quiltmc.config.api.ConfigEnvironment; + import org.quiltmc.config.api.Serializer; import org.quiltmc.config.api.serializers.Json5Serializer; import org.quiltmc.config.api.serializers.TomlSerializer; +import org.quiltmc.config.implementor_api.ConfigEnvironment; import org.slf4j.Logger; public final class AzusaConfigImpl { @@ -43,13 +45,15 @@ public static void init() { serializerMap.put("toml", TomlSerializer.INSTANCE); serializerMap.put("json5", Json5Serializer.INSTANCE); -// for (Serializer serializer : AzusaConfigExpectPlatform.getEntrypoints("config_serializer", Serializer.class)) { -// Serializer oldValue = serializerMap.put(serializer.getFileExtension(), serializer); -// -// if (oldValue != null) { -// LOGGER.warn(AzusaConfigMod.MARKER, "Replacing {} serializer {} with {}", serializer.getFileExtension(), oldValue.getClass(), serializer.getClass()); -// } -// } + if (ArchitecturyTarget.getCurrentTarget().equals("fabric")) { + for (Serializer serializer : AzusaConfigExpectPlatform.getEntrypoints("config_serializer", Serializer.class)) { + Serializer oldValue = serializerMap.put(serializer.getFileExtension(), serializer); + + if (oldValue != null) { + LOGGER.warn(AzusaConfigMod.MARKER, "Replacing {} serializer {} with {}", serializer.getFileExtension(), oldValue.getClass(), serializer.getClass()); + } + } + } String globalConfigExtension = System.getProperty("azusaconfig.globalConfigExtension"); String defaultConfigExtension = System.getProperty("azusaconfig.defaultConfigExtension"); diff --git a/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigExpectPlatformImpl.java b/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigExpectPlatformImpl.java index 558f316..f966d31 100644 --- a/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigExpectPlatformImpl.java +++ b/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigExpectPlatformImpl.java @@ -10,7 +10,7 @@ public static Path getConfigDirectory() { return FabricLoader.getInstance().getConfigDir(); } -// public static List getEntrypoints(String key, Class type) { -// return FabricLoader.getInstance().getEntrypoints(key, type); -// } + public static List getEntrypoints(String key, Class type) { + return FabricLoader.getInstance().getEntrypoints(key, type); + } } diff --git a/gradle.properties b/gradle.properties index 0939493..ff275c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ enabled_platforms=fabric,neoforge yarn_mappings=1.20.4+build.3 archives_base_name=AzusaConfig -mod_version=0.1.2 +mod_version=0.1.3 maven_group=ho.artisan.azusaconfig fabric_loader_version=0.15.2 @@ -15,5 +15,5 @@ neoforge_version=20.4.235 curseforge_id=970148 modrinth_id=12LahGY4 -quiltconfig_version=1.3.1 +quiltconfig_version=1.3.2 quiltparsers_version=0.2.0 diff --git a/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigExpectPlatformImpl.java b/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigExpectPlatformImpl.java index 913a99e..da09460 100644 --- a/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigExpectPlatformImpl.java +++ b/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigExpectPlatformImpl.java @@ -1,9 +1,9 @@ package ho.artisan.azusaconfig.neoforge; -//import ho.artisan.azusaconfig.neoforge.entrypoint.impl.EntrypointStorage; import net.neoforged.fml.loading.FMLPaths; import java.nio.file.Path; +import java.util.Collections; import java.util.List; public class AzusaConfigExpectPlatformImpl { @@ -11,7 +11,7 @@ public static Path getConfigDirectory() { return FMLPaths.CONFIGDIR.get(); } -// public static List getEntrypoints(String key, Class type) { -// return (List) EntrypointStorage.getEntrypointContainers(key, type); -// } + public static List getEntrypoints(String key, Class type) { + return Collections.emptyList(); + } } diff --git a/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java b/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java index 1b49576..dd732ed 100644 --- a/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java +++ b/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java @@ -2,7 +2,6 @@ import ho.artisan.azusaconfig.AzusaConfigMod; import ho.artisan.azusaconfig.impl.config.AzusaConfigImpl; -//import ho.artisan.azusaconfig.neoforge.entrypoint.impl.EntrypointStorage; import net.neoforged.fml.IExtensionPoint; import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; @@ -12,7 +11,6 @@ public class AzusaConfigModNeoForge { public AzusaConfigModNeoForge() { ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true)); -// EntrypointStorage.loadAll(); AzusaConfigImpl.init(); } }