From 372eec27e5e0c8ef796ed9e6bcdc68a10df84718 Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 12 Jul 2022 14:20:22 +0200 Subject: initial --- .../kotlin/net/examplemod/ExampleExpectPlatform.kt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt (limited to 'common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt') diff --git a/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt b/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt new file mode 100644 index 0000000..4949054 --- /dev/null +++ b/common/src/main/kotlin/net/examplemod/ExampleExpectPlatform.kt @@ -0,0 +1,30 @@ +package net.examplemod + +import dev.architectury.injectables.annotations.ExpectPlatform +import dev.architectury.platform.Platform +import java.nio.file.Path + +object ExampleExpectPlatform { + /** + * We can use [Platform.getConfigFolder] but this is just an example of [ExpectPlatform]. + * + * + * This must be a **public static** method. The platform-implemented solution must be placed under a + * platform sub-package, with its class suffixed with `Impl`. + * + * + * Example: + * Expect: net.examplemod.ExampleExpectPlatform#getConfigDirectory() + * Actual Fabric: net.examplemod.fabric.ExampleExpectPlatformImpl#getConfigDirectory() + * Actual Forge: net.examplemod.forge.ExampleExpectPlatformImpl#getConfigDirectory() + * + * + * [You should also get the IntelliJ plugin to help with @ExpectPlatform.](https://plugins.jetbrains.com/plugin/16210-architectury) + */ + @ExpectPlatform + @JvmStatic + fun getConfigDirectory(): Path { + // Just throw an error, the content should get replaced at runtime. + throw AssertionError() + } +} -- cgit