Bukkit Setup - aki-ks/sbt-bukkit GitHub Wiki

Enable the BukkitPlugin for your module.

enablePlugins(BukkitPlugin)

Enter your sbt shell and execute Bukkit/packagePlugin. Your plugin, its dependencies and a generated plugin.yml file will be packaged into a ready to use bukkit plugin jar.

The default export location is target/bukkit-server/plugins/<plugin-name>.jar

Configuring Server-Api

Your plugin can be compiled against the Bukkit or Spigot Api.

If you want to compile against a server implementation (Craftbukkit or Spigot), you must tell SbtBukkit where the jar can be found. This is described in the Preparation section of the Start Bukkit Page.

// Possible values: BukkitApi, SpigotApi, CraftBukkit, Spigot
serverApi := BukkitApi

The Spigot and Bukkit Api is fetched from the spigot repository. All available Spigot and Bukkit Api versions are listed there.

serverVersion := "1.12.2-R0.1-SNAPSHOT"

Library dependencies

The scala runtime is packaged into your plugin by default unless you assign autoScalaLibrary := false.

Libraries appended to the pluginLibraryDependencies key are also packaged into your plugin jar.

Libraries in libraryDependencies are only available at compile time.

// This library will be packed into your plugin jar.
pluginLibraryDependencies += "com.lihaoyi" %% "fastparse" % "1.0.0"

// This library will not be included in your plugin jar.
// This might be useful if another another plugin ships it.
libraryDependencies += "org.yaml" % "snakeyaml" % "1.10"

Configuring packaging

// Custom name for the generated plugin jar
Bukkit / pluginJarName := "example.jar"

// Custom folder for the generated plugin jar
Bukkit / pluginFolder := file("/home/user")

// Package an additional jar file into your final plugin jar
Bukkit / dependencyJars += file("/home/user/Desktop/ExampleDependency.jar")

Configuring plugin.yml

The plugin.yml file is generated by sbt-bukkit. It's content is defined in your sbt build file by following keys:

// Name of your plugin.
// Defaults to the module name.
Bukkit / pluginName := "ExamplePlugin"

// Version of your plugin.
// Defaults to the module version
Bukkit / pluginVersion := "1.0"

// Describe your plugin.
// Defaults to project description
Bukkit / pluginDescription := "An example plugin configuration"

// Author of the plugin
Bukkit / pluginAuthor := "Aki"

// Additional authors of the plugin
Bukkit / pluginAuthors += "TheExampleGuy"

// Commands registered by your plugin
Bukkit / pluginCommands += { /gm }
  .alias(/gmode, /cgm)
  .description("Change your gamemode")
  .usage("/gm [c|creative|s|survival]")
  .permission("example.gamemode" ! "You're not allowed to change your gamemode")

// Permissions the plugin wishes to register
Bukkit / pluginPermissions += { "example.gamemode" }
  .default
  .description("Change your gamemode")
  .children("example.gamemode.others" -> true)

// Your website or the website of the plugin
Bukkit / pluginWebsite := "https://github.com/aki-ks/sbt-bukkit"

// When will the plugin be initialized.
// Can be set to `OnStartup` or `PostWorld`.
Bukkit / pluginLoadTime := OnStartup

// Names of other plugins required to initialize your plugin
Bukkit / pluginDependencies += "WorldEdit"

// Names of plugins that extend the functionality of your plugin
Bukkit / pluginSoftDependencies += "Vault"

// Your plugin must be loaded before these plugins
Bukkit / pluginLoadBefore += "WorldGuard"

// Logging prefix of your plugin
Bukkit / pluginPrefix := "example"

// Does your plugin use a database
Bukkit / pluginDatabase := false

// Main class of your plugin.
// If you don't assign one, SbtBukkit will detect it for you.
Bukkit / pluginMain := "me.aki.bukkit.example.ExamplePlugin"

// Add custom values to your plugin.yml
Bukkit / pluginManifest += "myKey" -> "HelloWorld"
Bukkit / pluginManifest += "anotherKey" -> Map(
  "someSubkey" -> "random"
)