-
Notifications
You must be signed in to change notification settings - Fork 2
1. Project setup
Add the following to your build script if you are using Kotlin DSL:
repositories {
// ...
mavenCentral()
maven("https://jitpack.io")
maven("https://repo.codemc.io/repository/maven-snapshots/")
maven("https://libraries.minecraft.net")
// ...
}
dependencies {
// ...
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk9:1.6.0")
implementation("com.github.dyam0:LirandAPI:VERSION")
compileOnly("com.mojang:brigadier:1.0.18")
// ...
}
Or this if you are using Groovy-based build script:
repositories {
// ...
mavenCentral()
maven {
url "https://jitpack.io"
}
maven {
url "https://repo.codemc.io/repository/maven-snapshots/"
}
maven {
url "https://libraries.minecraft.net"
}
// ...
}
dependencies {
// ...
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk9:1.6.0'
implementation 'com.github.dyam0:LirandAPI:VERSION'
compileOnly 'com.mojang:brigadier:1.0.18'
// ...
}
Replace VERSION
with the version of Lirand API you need.
Also you can build the latest snapshot on the JitPack and use it as a dependency.
I highly recommend you to shade this dependency into your Jar file as well as some dependencies of Lirand API (MCCoroutine and AnvilGUI).
You need to register LirandAPI instance to use some features of this library. You can do that by simply calling LirandAPI.register(plugin)
.
In addition, you can also extend KotlinPlugin class which is subclass of MCCoroutine SuspendingJavaPlugin. In this case LirandAPI registers automatically. SuspendingJavaPlugin allows you to override suspend callback functions so the logic of registering LirandAPI was moved to onEnable
which should not be overrided. Your code must look like this:
class MyPlugin : KotlinPlugin() {
override suspend fun onLoadAsync() {
// load logic
}
override suspend fun onEnableAsync() {
// enable logic
}
override suspend fun onDisableAsync() {
// disable logic
}
}