Skip to content

About

Leaf language module for Kotlin.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

A language module for Kotlin

License Gradle version Build status Code Size Maven status

Adds support for Kotlin exclusive entrypoints and bundles the Kotlin Stdlib as well as common kotlinx libraries.

Usage

Dependency

Add it as a dependency to your Gradle project:

dependencies {
    implementation("dev.aoqia.leaf:language-kotlin:1.0.0")
}

Adapter

Use the kotlin adapter for your mod by setting the adapter property in the leaf.mod.json file. Remember to the add a dependency entry to your leaf.mod.json file:

{
    "schemaVersion": 1,
    "entrypoints": {
        "main": [
            {
                "adapter": "kotlin",
                "value": "package.ClassName"
            }
        ]
    },
    "depends": {
        "leaf-language-kotlin": ">=1.0.0"
    }
}

For more info reference the fabric.mod.json documentation.

Note

Don't forget to set the schemaVersion to 1 or it will fall back to schema 0 and will not attempt to load entrypoints.

Samples

Kind Class reference Function reference Field reference
class
{
    "adapter": "kotlin",
    "value": "mymod.MyMod"
}
package mymod

class MyMod : ModInitializer {
    override fun onInitialize() {
        TODO()
    }
}
object
{
    "adapter": "kotlin",
    "value": "mymod.MyMod"
}
package mymod

object MyMod : ModInitializer {
    override fun onInitialize() {
        TODO()
    }
}
{
    "adapter": "kotlin",
    "value": "mymod.MyMod::init"
}
package mymod

object MyMod {
    fun init() {
        TODO()
    }
}
{
    "adapter": "kotlin",
    "value": "mymod.MyMod::initializer"
}
package mymod

object MyMod {
    val initializer = ModInitializer {
        TODO()
    }
}
companion object
{
    "adapter": "kotlin",
    "value": "mymod.MyMod$Companion"
}
package mymod

class MyMod {
    companion object : ModInitializer {
        override fun onInitialize() {
            TODO()
        }
    }
}
{
    "adapter": "kotlin",
    "value": "mymod.MyMod$Companion::init"
}
package mymod

class MyMod {
    companion object {
        fun init() {
            TODO()
        }
    }
}
{
    "adapter": "kotlin",
    "value": "mymod.MyMod$Companion::initializer"
}
package mymod

class MyMod {
    companion object {
        val initializer = ModInitializer {
            TODO()
        }
    }
}
top level
{
  "adapter": "kotlin",
  "value": "mymod.MyModKt::init"
}

File: src/main/kotlin/mymod/MyMod.kt

package mymod

fun init() {
    TODO()
}

Companion objects can be used by appending $Companion to the class. Take care of processResources there, it might try to expand it, in that case escape it.

Bundled libraries

org.jetbrains.kotlin namespace:

org.jetbrains.kotlinx namespace:

Updating README

  • Update the readme in templates/README.template.md.
  • Run the processTemplates task.

Special Thanks

About

Leaf language module for Kotlin.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages