Sueta
KO

KotlinLoader

1.2.2

Use Kotlin in your plugins without bloating your jarfile!

·Plugin

KotlinLoader

Kotlin is a wonderful growing programming language with support for the JVM. This allows us to write Minecraft Plugins in Kotlin. While this works fine, it does bring some inconviences. To run kotlin, it is mandatory for the kotlin library files to be available at runtime. While it is possible to provide these classes with the -classpath option, when starting the JVM, most spigot servers run in managed environments. The go-to workaround for this problem is to add these library files to the final jar by shading them. This will increase your jar size alot.

KotlinLoader provides a custom PluginLoader, that will provide the Kotlin library classes for you.

Included Kotlin Libraries

  • kotlin-stdlib
  • kotlinx-coroutines
  • kotlin-reflect
  • kotlin-stdlib-jdk8
  • kotlin-stdlib-jdk7

Pros

  • Write Idiomatic Kotlin!
  • The main class can be an object singleton, instead of a normal class.
  • Decrease size of the final plugin jar.
  • A simpler way of defining events, which prevent a lot of boilerplate.

Cons

  • This plugin uses alot of reflection and injection hacks to allows Kotlin classes to be accessed by JavaPlugins
  • Plugins extending KotlinPlugin should be located in the <server_root>/plugins/kotlin folder.
  • Java Plugins might not be able to use features provided by Kotlin Plugins due to a problem in the normal PluginClassLoader

Roadmap

  • Add support for .kts configuration
  • Add support for annotation based/kts based plugin descriptions
  • Add BungeeCord support

Usage for Server Administrators
Download the plugin and place it into your {server_root}/plugins folder.
Add the plugins using this project to the {server_root}/plugins/kotlin folder, which will be created on runtime, if it wasn't already.

For a slightly better description, please visit the github page.

Similar projects

Plugin →