diff options
author | thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> | 2020-10-01 14:57:13 -0700 |
---|---|---|
committer | thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> | 2020-10-01 14:57:13 -0700 |
commit | 9a06bdb13ce55588b9f8dc28df132d7530742cac (patch) | |
tree | be7c4a6cd5a19fe3891568c3e3be689bd1898a99 | |
parent | 6fdda20f1977c17ab45599b249094fe13821db09 (diff) | |
download | KotlinForForge-9a06bdb13ce55588b9f8dc28df132d7530742cac.tar.gz KotlinForForge-9a06bdb13ce55588b9f8dc28df132d7530742cac.tar.bz2 KotlinForForge-9a06bdb13ce55588b9f8dc28df132d7530742cac.zip |
Kotlin for Forge 1.6.1
Close #7
19 files changed, 128 insertions, 33 deletions
@@ -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 <T> callWhenOn(dist: Dist, toRun: () -> T): T? { +public fun <T> callWhenOn(dist: Dist, toRun: () -> T): T? { return if (DIST == dist) { try { toRun() @@ -103,8 +107,11 @@ public inline fun <T> 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 <T> runForDist(clientTarget: () -> T, serverTarget: () -> T): T { +public fun <T> runForDist(clientTarget: () -> T, serverTarget: () -> T): T { return when (DIST) { Dist.CLIENT -> clientTarget() Dist.DEDICATED_SERVER -> serverTarget() @@ -186,8 +196,8 @@ public inline fun <reified T : IForgeRegistryEntry<in T>> objectHolder(namespace */ public inline fun <reified T : IForgeRegistryEntry<in T>> objectHolder(registryName: String): ReadOnlyProperty<Any?, T> { 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 Binary files differnew file mode 100644 index 0000000..f15993c --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1-sources.jar 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 Binary files differnew file mode 100644 index 0000000..3eb6d07 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.6.1/kotlinforforge-1.6.1.jar 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>thedarkcolour</groupId> + <artifactId>kotlinforforge</artifactId> + <version>1.6.1</version> + <repositories> + <repository> + <id>kt-eap</id> + <name>Kotlin Early Access</name> + <url>https://dl.bintray.com/kotlin/kotlin-eap</url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib</artifactId> + <version>1.4.10</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-jdk7</artifactId> + <version>1.4.10</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-jdk8</artifactId> + <version>1.4.10</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-reflect</artifactId> + <version>1.4.10</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains</groupId> + <artifactId>annotations</artifactId> + <version>19.0.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlinx</groupId> + <artifactId>kotlinx-coroutines-core</artifactId> + <version>1.3.7</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlinx</groupId> + <artifactId>kotlinx-coroutines-jdk8</artifactId> + <version>1.3.7</version> + <scope>compile</scope> + </dependency> + </dependencies> +</project> 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 @@ +<html lang="HTML5"> +<link rel="stylesheet" href="../../style.css"> +<head><title>Index of /1.6.1/</title></head> +<body> +<h1>Index of /kotlinforforge/</h1> +<hr> +<pre><a href="../web.html">../</a> +<a href="kotlinforforge-1.6.1-sources.jar">kotlinforforge-1.6.1-sources.jar</a> +<a href="kotlinforforge-1.6.1-sources.jar.sha1">kotlinforforge-1.6.1-sources.jar.sha1</a> +<a href="kotlinforforge-1.6.1-sources.jar.md5">kotlinforforge-1.6.1-sources.jar.md5</a> +<a href="kotlinforforge-1.6.1.jar">kotlinforforge-1.6.1.jar</a> +<a href="kotlinforforge-1.6.1.jar.sha1">kotlinforforge-1.6.1.jar.sha1</a> +<a href="kotlinforforge-1.6.1.jar.md5">kotlinforforge-1.6.1.jar.md5</a> +<a href="kotlinforforge-1.6.1.pom">kotlinforforge-1.6.1.pom</a> +<a href="kotlinforforge-1.6.1.pom.sha1">kotlinforforge-1.6.1.pom.sha1</a> +<a href="kotlinforforge-1.6.1.pom.md5">kotlinforforge-1.6.1.pom.md5</a> +</pre> +<hr> +</body> +</html> 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 @@ <groupId>thedarkcolour</groupId> <artifactId>kotlinforforge</artifactId> <versioning> - <release>1.6.0</release> + <release>1.6.1</release> <versions> <version>1.0.0</version> <version>1.0.1</version> @@ -17,6 +17,7 @@ <version>1.4.1</version> <version>1.5.0</version> <version>1.6.0</version> + <version>1.6.1</version> </versions> </versioning> </metadata> 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 @@ <a href="1.4.1/web.html">1.4.1</a> <a href="1.5.0/web.html">1.5.0</a> <a href="1.6.0/web.html">1.6.0</a> +<a href="1.6.1/web.html">1.6.1</a> <a href="maven-metadata.xml">maven-metadata.xml</a> <a href="maven-metadata.xml.md5">maven-metadata.xml.md5</a> <a href="maven-metadata.xml.sha1">maven-metadata.xml.sha1</a> |