Skip to content

Getting Started

Junhyung edited this page Jan 7, 2024 · 6 revisions

Making a production plugin with SpringBukkit is strongly recommended because of these reasons:

  • Published on MavenCentral, so your plugin will never break due to API breaking issues.
  • Plugins have a different Spring application context and different class loaders, there is no (library) conflict issue.
  • By exposing application.config to the server admins who use the plugin, it provides powerful customization.

So, let's start with adding SpringBukkit dependencies to your project.

Maven Central

dependencies {
    implementation("kr.summitsystems:spring-bukkit-starter:<version>")
}

If you have any understanding of Gradle scripting, you can use other configurations(api/compileOnly) if needed.

How to build a Jar?

Is there any need to build a fatjar? The short and clear answer is No.

explanation that no one wants to know

Spigot provides the SpigotLibraryLoader for each independent plugin to load the library from a different class loader, which can help resolve version conflicts between libraries. This became the key to making the SpringFramework available on . The Spring ComponentScan fits very well in this environment.  

Fatjars produce various errors in the complex environment of the Spring.

Just simply use the Gradle's default task, Jar. Then specify the dependency notations in your plugin.yml.

name: ExamplePlugin
version: 1.0.0
main: org.examplegroup.exampleartifact.ExamplePlugin
libraries:
  - kr.summitsystems:spring-bukkit-starter:<version> # Required
  - kr.summitsystems:spring-bukkit-<module>:<version> # Optional

Modules

There is a module that manages a lot of dependencies in one. What is the starter module? It automatically adds the necessary for one plugin to be created.

the starter module dependencies:
  • core module
  • command module
  • view module
  • support module (runtime)
  • Jakarta annotations API
  • Spring TX

Additional modules can be added when needed. The module is automatically set up when you add it (by Spring's component scan).

  • jpa module By simply adding this module, you can use the JPA feature of SpringFramework.
  • coroutines module Add KotlinX Coroutines supports.
    • you can create a command controller and listener by 'suspend' keyword of Kotlin.
    • Make possible to use Dispatchers.Main.
Clone this wiki locally