Warning
Platform Weaver is an experimental project. Use it with caution.
You're writing a Minecraft server plugin — and it has to run on both Fabric and Paper.
The logic is identical. The same storage format, same commands, same packet handling, etc.
But Fabric says ServerLevel, Paper says World. Fabric says BlockPos, Paper says Location.
So you end up with two codebases that do the same thing. Platform Weaver breaks that loop.
Annotate declarations by platform. The compiler plugin removes the ones that don't belong — before a single byte is written to disk.
object Scheduler {
@FabricOnly fun scheduleAsync(task: Runnable) {
Thread(task, "async-worker").also { it.isDaemon = true }.start()
}
@PaperOnly fun scheduleAsync(task: Runnable) {
Bukkit.getScheduler().runTaskAsync(plugin, task)
}
}Compile for Paper? The @FabricOnly block is gone — it never made it to bytecode. No runtime overhead, and it's the same file for both platforms.
And when the platforms differ only in a type name or an accessor, @Chameleon merges them so the shared logic is written exactly once.
Platform Weaver is on Maven Central — no extra repository needed:
// build.gradle.kts
dependencies {
compileOnly("io.github.arnodoelinger:platformweaver-annotations:1.2.0")
"kotlinCompilerPluginClasspath"("io.github.arnodoelinger:platformweaver-plugin:1.2.0")
}Then point the compiler at your target platform — see Getting started for the full setup.
The full guide lives in the wiki.
Platform Weaver is developed with passion and dedication by me and my friends. If you enjoy our mod and want to support further development, consider making a donation or buying us a coffee.
