From 9a06bdb13ce55588b9f8dc28df132d7530742cac Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Thu, 1 Oct 2020 14:57:13 -0700 Subject: Kotlin for Forge 1.6.1 Close #7 --- README.md | 13 +---- build.gradle | 5 +- .../kotlinforforge/AutoKotlinEventBusSubscriber.kt | 25 +++++---- .../thedarkcolour/kotlinforforge/KotlinForForge.kt | 2 +- .../thedarkcolour/kotlinforforge/forge/Forge.kt | 22 +++++--- .../1.6.1/kotlinforforge-1.6.1-sources.jar | Bin 0 -> 35516 bytes .../1.6.1/kotlinforforge-1.6.1-sources.jar.md5 | 1 + .../1.6.1/kotlinforforge-1.6.1-sources.jar.sha1 | 1 + .../kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar | Bin 0 -> 101400 bytes .../1.6.1/kotlinforforge-1.6.1.jar.md5 | 1 + .../1.6.1/kotlinforforge-1.6.1.jar.sha1 | 1 + .../kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom | 60 +++++++++++++++++++++ .../1.6.1/kotlinforforge-1.6.1.pom.md5 | 1 + .../1.6.1/kotlinforforge-1.6.1.pom.sha1 | 1 + thedarkcolour/kotlinforforge/1.6.1/web.html | 20 +++++++ thedarkcolour/kotlinforforge/maven-metadata.xml | 3 +- .../kotlinforforge/maven-metadata.xml.md5 | 2 +- .../kotlinforforge/maven-metadata.xml.sha1 | 2 +- thedarkcolour/kotlinforforge/web.html | 1 + 19 files changed, 128 insertions(+), 33 deletions(-) create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.md5 create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.sha1 create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.md5 create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.sha1 create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.md5 create mode 100644 thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.sha1 create mode 100644 thedarkcolour/kotlinforforge/1.6.1/web.html diff --git a/README.md b/README.md index 8d8f2f6..ae7fab5 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,8 @@ git clone https://github.com/thedarkcolour/KotlinModdingSkeleton.git To implement in an existing project, paste the following into your build.gradle: ```groovy buildscript { - repositories { - // For early access Kotlin versions - maven { url = "https://dl.bintray.com/kotlin/kotlin-eap" } - } dependencies { - // Make sure to use the correct version - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0-rc" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10" } } @@ -38,16 +33,12 @@ repositories { dependencies { // Use the latest version of KotlinForForge - implementation 'thedarkcolour:kotlinforforge:1.4.0' + implementation 'thedarkcolour:kotlinforforge:1.7.0' } compileKotlin { - // Needed if you use Forge.kt - // and Kotlin 1.4 language features kotlinOptions { jvmTarget = '1.8' - languageVersion = '1.4' - apiVersion = '1.4' } } ``` diff --git a/build.gradle b/build.gradle index 4f82dcf..ccff79b 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'kotlin' apply plugin: 'org.jetbrains.dokka' -version = "1.6.0" +version = "1.6.1" group = 'thedarkcolour.kotlinforforge' archivesBaseName = 'kotlinforforge' @@ -89,6 +89,9 @@ dependencies { compile group: "org.jetbrains", name: "annotations", version: annotations_version compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-core", version: coroutines_version compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-jdk8", version: coroutines_version + + // Tests + testImplementation 'junit:junit:4.11' } shadowJar { diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt index 78325ee..3f4698f 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt @@ -53,20 +53,23 @@ public object AutoKotlinEventBusSubscriber { val modid = annotationData.annotationData.getOrDefault("modid", mod.modId) val busTargetHolder = annotationData.annotationData.getOrDefault("bus", ModAnnotation.EnumHolder(null, "FORGE")) as ModAnnotation.EnumHolder val busTarget = Mod.EventBusSubscriber.Bus.valueOf(busTargetHolder.value) - val ktObject = Class.forName(annotationData.classType.className, true, classLoader).kotlin.objectInstance - if (ktObject != null && mod.modId == modid && DIST in sides) { - try { - LOGGER.debug(Logging.LOADING, "Auto-subscribing kotlin object ${annotationData.classType.className} to $busTarget") + if (mod.modId == modid && DIST in sides) { + val ktObject = Class.forName(annotationData.classType.className, true, classLoader).kotlin.objectInstance - if (busTarget == Mod.EventBusSubscriber.Bus.MOD) { - MOD_BUS.register(ktObject) - } else { - FORGE_BUS.register(ktObject) + if (ktObject != null) { + try { + LOGGER.debug(Logging.LOADING, "Auto-subscribing kotlin object ${annotationData.classType.className} to $busTarget") + + if (busTarget == Mod.EventBusSubscriber.Bus.MOD) { + MOD_BUS.register(ktObject) + } else { + FORGE_BUS.register(ktObject) + } + } catch (e: Throwable) { + LOGGER.fatal(Logging.LOADING, "Failed to load mod class ${annotationData.classType} for @EventBusSubscriber annotation", e) + throw RuntimeException(e) } - } catch (e: Throwable) { - LOGGER.fatal(Logging.LOADING, "Failed to load mod class ${annotationData.classType} for @EventBusSubscriber annotation", e) - throw RuntimeException(e) } } } diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt index 237c445..168d3f0 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt @@ -5,7 +5,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext /** * Set `modLoader` in mods.toml to - * `"kotlinforforge"` and loaderVersion to `"[1.4,)"`. + * `"kotlinforforge"` and loaderVersion to `"[1.7,)"`. * * Make sure to use [KotlinModLoadingContext] * instead of [FMLJavaModLoadingContext]. diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt index 44fa17b..8289456 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt @@ -78,7 +78,8 @@ public val DIST: Dist = FMLEnvironment.dist */ @Deprecated( message = "Will be removed in 1.7.0 to improve compatibility between Minecraft versions", - replaceWith = ReplaceWith("Minecraft.getInstance()", "net.minecraft.client.Minecraft") + replaceWith = ReplaceWith("Minecraft.getInstance()", "net.minecraft.client.Minecraft"), + level = DeprecationLevel.ERROR, ) public val MINECRAFT: Minecraft @OnlyIn(Dist.CLIENT) @@ -87,8 +88,11 @@ public val MINECRAFT: Minecraft /** @since 1.0.0 * An alternative to [net.minecraftforge.fml.DistExecutor.callWhenOn] * that inlines the callable. + * + * @since 1.6.1 + * No longer an inline function to maintain side safety */ -public inline fun callWhenOn(dist: Dist, toRun: () -> T): T? { +public fun callWhenOn(dist: Dist, toRun: () -> T): T? { return if (DIST == dist) { try { toRun() @@ -103,8 +107,11 @@ public inline fun callWhenOn(dist: Dist, toRun: () -> T): T? { /** @since 1.0.0 * An alternative to [net.minecraftforge.fml.DistExecutor.runWhenOn] * that inlines the runnable. + * + * @since 1.6.1 + * No longer an inline function to maintain side safety */ -public inline fun runWhenOn(dist: Dist, toRun: () -> Unit) { +public fun runWhenOn(dist: Dist, toRun: () -> Unit) { if (DIST == dist) { toRun() } @@ -113,8 +120,11 @@ public inline fun runWhenOn(dist: Dist, toRun: () -> Unit) { /** @since 1.0.0 * An alternative to [net.minecraftforge.fml.DistExecutor.runForDist] * that inlines the function call. + * + * @since 1.6.1 + * No longer an inline function to maintain side safety */ -public inline fun runForDist(clientTarget: () -> T, serverTarget: () -> T): T { +public fun runForDist(clientTarget: () -> T, serverTarget: () -> T): T { return when (DIST) { Dist.CLIENT -> clientTarget() Dist.DEDICATED_SERVER -> serverTarget() @@ -186,8 +196,8 @@ public inline fun > objectHolder(namespace */ public inline fun > objectHolder(registryName: String): ReadOnlyProperty { return ObjectHolderDelegate( - registryName = GameData.checkPrefix(registryName, true), - registry = ObjectHolderDelegate.getRegistry(T::class.java) + registryName = GameData.checkPrefix(registryName, true), + registry = ObjectHolderDelegate.getRegistry(T::class.java) ) } diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar new file mode 100644 index 0000000..f15993c Binary files /dev/null and b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar differ diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.md5 b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.md5 new file mode 100644 index 0000000..9595059 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.md5 @@ -0,0 +1 @@ +fa7cf6b32617de9b7e660c323feb98d3 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.sha1 b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.sha1 new file mode 100644 index 0000000..6239ca4 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar.sha1 @@ -0,0 +1 @@ +225cc349a1b95b198dd7edbd0f0952f007d70c66 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar new file mode 100644 index 0000000..3eb6d07 Binary files /dev/null and b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar differ diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.md5 b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.md5 new file mode 100644 index 0000000..65638fe --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.md5 @@ -0,0 +1 @@ +e887c092171e4eb340506386ecc65525 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.sha1 b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.sha1 new file mode 100644 index 0000000..f8c00b6 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar.sha1 @@ -0,0 +1 @@ +1bef38a91c9e6e6f8e5ca63ac5f3a3432b2aad25 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom new file mode 100644 index 0000000..cd53b54 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom @@ -0,0 +1,60 @@ + + + 4.0.0 + thedarkcolour + kotlinforforge + 1.6.1 + + + kt-eap + Kotlin Early Access + https://dl.bintray.com/kotlin/kotlin-eap + + + + + org.jetbrains.kotlin + kotlin-stdlib + 1.4.10 + compile + + + org.jetbrains.kotlin + kotlin-stdlib-jdk7 + 1.4.10 + compile + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + 1.4.10 + compile + + + org.jetbrains.kotlin + kotlin-reflect + 1.4.10 + compile + + + org.jetbrains + annotations + 19.0.0 + compile + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + 1.3.7 + compile + + + org.jetbrains.kotlinx + kotlinx-coroutines-jdk8 + 1.3.7 + compile + + + diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.md5 b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.md5 new file mode 100644 index 0000000..ac1d414 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.md5 @@ -0,0 +1 @@ +95e28999fb98842551c72a2c5490e28b \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.sha1 b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.sha1 new file mode 100644 index 0000000..c204082 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.pom.sha1 @@ -0,0 +1 @@ +3ad01bda023402919c2d22c51e25c48d5f38cc39 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.6.1/web.html b/thedarkcolour/kotlinforforge/1.6.1/web.html new file mode 100644 index 0000000..9c0dc60 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/web.html @@ -0,0 +1,20 @@ + + +Index of /1.6.1/ + +

Index of /kotlinforforge/

+
+
../
+kotlinforforge-1.6.1-sources.jar
+kotlinforforge-1.6.1-sources.jar.sha1
+kotlinforforge-1.6.1-sources.jar.md5
+kotlinforforge-1.6.1.jar
+kotlinforforge-1.6.1.jar.sha1
+kotlinforforge-1.6.1.jar.md5
+kotlinforforge-1.6.1.pom
+kotlinforforge-1.6.1.pom.sha1
+kotlinforforge-1.6.1.pom.md5
+
+
+ + diff --git a/thedarkcolour/kotlinforforge/maven-metadata.xml b/thedarkcolour/kotlinforforge/maven-metadata.xml index 55c3750..f63a2a6 100644 --- a/thedarkcolour/kotlinforforge/maven-metadata.xml +++ b/thedarkcolour/kotlinforforge/maven-metadata.xml @@ -3,7 +3,7 @@ thedarkcolour kotlinforforge - 1.6.0 + 1.6.1 1.0.0 1.0.1 @@ -17,6 +17,7 @@ 1.4.1 1.5.0 1.6.0 + 1.6.1 diff --git a/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 b/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 index 3131ca0..b1bfa38 100644 --- a/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 +++ b/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 @@ -1 +1 @@ -a2d69dca57d7e21404b87543d1d77efd \ No newline at end of file +5dd75e78f41e4517a86d3efbf089de45 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 b/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 index cfa1306..d003f71 100644 --- a/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 +++ b/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 @@ -1 +1 @@ -f647c1e02d53ef1e9b7e00b663c327f0985bcec8 \ No newline at end of file +472c20190bb6d7e6e36f7c5b53960bf8129392b0 \ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/web.html b/thedarkcolour/kotlinforforge/web.html index 3a5ec8f..68989de 100644 --- a/thedarkcolour/kotlinforforge/web.html +++ b/thedarkcolour/kotlinforforge/web.html @@ -20,6 +20,7 @@ 1.4.1 1.5.0 1.6.0 +1.6.1 maven-metadata.xml maven-metadata.xml.md5 maven-metadata.xml.sha1 -- cgit