Skip to content

Getting started

Publication coordinates are not stable yet. The dependency examples assume your server is a project in this repository and use its type-safe project accessors.

Also, make sure you understand Minestom before continuing as this guide won’t cover it.

Not all Twaddle features need a running core. Look at the page of your feature to see what it needs.

build.gradle.kts
dependencies {
implementation(projects.twaddleCore)
}

The application lifecycle has four phases:

  1. Twaddle creates the root context.
  2. Pre-init modules are installed.
  3. Minestom is initialized.
  4. Modules that need the server are installed.

Create the server directly and wrap the process lifetime with runTwaddleApplication. When the application block finishes or fails, the context cancels lifetime coroutine work and closes owned resources.

import kotlinx.coroutines.awaitCancellation
import net.minestom.server.Auth
import net.minestom.server.MinecraftServer
import org.everbuild.twaddle.core.runTwaddleApplication
suspend fun main() = runTwaddleApplication { cx ->
// Install pre-init modules here
val server = MinecraftServer.init(Auth.Online())
val serverCx = cx.initialized(server)
// Pass serverCx to post-init modules here
server.start("0.0.0.0", 25565)
awaitCancellation()
}

The wait after start(...) is deliberate. Minestom starts its server threads and returns, while the Twaddle context must stay alive for as long as those threads do. Replace the indefinite wait with your application’s shutdown signal when it has one.

Continue with Inventory transfer rules for the first optional capability.