Server API
Important Note
You'll need Java Development Kit (JDK) 8 or higher to be able to use the LabyMod 4 Server API (the Velocity platform-specific implementation requires JDK 17 or higher)
Adding the LabyMod Repository
repositories {
maven {
name = "labymod"
url = uri("https://dist.labymod.net/api/v1/maven/release/")
}
}
repositories {
maven {
name = "labymod"
url = "https://dist.labymod.net/api/v1/maven/release/"
}
}
<repositories>
<repository>
<id>labymod</id>
<url>https://dist.labymod.net/api/v1/maven/release/</url>
</repository>
</repositories>
Adding the LabyMod 4 Server API as a Dependency
Depending on the actual artifact you want to use, you have to add the following dependency to your project. Listed below are the available artifacts and their use cases:
api- The protocol itself without any LabyMod-specific code. Useful if you want to just use the protocol.core- The LabyMod implementation of the protocol, containing all packets and models to interact with the LabyMod client. Use this if you want to communicate with the LabyMod 4 Server API platform-independently.server-bukkit- The platform-specific implementation of the LabyMod Protocol for Servers running on Bukkit (Spigot, Paper, etc.).server-bungeecord- The platform-specific implementation of the LabyMod Protocol for Servers running on BungeeCord.server-minestom- The platform-specific implementation of the LabyMod Protocol for Servers running on Minestom.server-velocity- The platform-specific implementation of the LabyMod Protocol for Servers running on Velocity.server-common- Contains shared classes and utilities used across different server implementations to ensure consistent behavior and reduce code duplication. Use this if you want to create your own platform implementation.
Important Note
For the examples below, replace ARTIFACT and VERSION with the artifact and version you want to use. The latest version can be found here:
dependencies {
compileOnly("net.labymod.serverapi:ARTIFACT:VERSION")
}
dependencies {
compileOnly "net.labymod.serverapi:ARTIFACT:VERSION"
}
<dependencies>
<dependency>
<groupId>net.labymod.serverapi</groupId>
<artifactId>ARTIFACT</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
Setting up Your Plugin
Each officially supported server platform has two types of implementations.
- You load the official jar file into your server's plugins folder and add it as a plugin dependency to your plugin.
- You shade the dependency into your plugin and initialize it manually, effectively eliminating the need to have the Server API run as a separate plugin.
Bukkit Plugin
Running the Server API as a Plugin
- Add the
server-bukkitdependency to your project's dependencies as described above. - Download the latest version of the
server-bukkitjar file from the GitHub Releases. - Place the jar file in your server's
pluginsfolder. - Add the following line to your plugin's
plugin.yml:depend: [LabyModServerAPI] - You're now ready to use the LabyMod 4 Server API in your Bukkit plugin.
Shading the Server API into Your Plugin
- Add the
server-bukkitdependency to your project's dependencies as described above. - Configure shadow in your project's
build.gradleorpom.xmlto shade theserver-bukkitdependency into your plugin. - Initialize the LabyMod 4 Server API in your plugin's
onEnablemethod:@Override public void onEnable() { LabyModProtocolService.initialize(this); } - You're now ready to use the LabyMod 4 Server API in your Bukkit plugin.
BungeeCord Plugin
Running the Server API as a Plugin
- Add the
server-bungeecorddependency to your project's dependencies as described above. - Download the latest version of the
server-bungeecordjar file from the GitHub Releases. - Place the jar file in your server's
pluginsfolder. - Add the following line to your plugin's
plugin.ymlorbungee.yml:depend: [LabyModServerAPI] - You're now ready to use the LabyMod 4 Server API in your BungeeCord plugin.
Shading the Server API into Your Plugin
- Add the
server-bungeecorddependency to your project's dependencies as described above. - Configure shadow in your project's
build.gradleorpom.xmlto shade theserver-bungeecorddependency into your plugin. - Initialize the LabyMod 4 Server API in your plugin's
onEnablemethod:@Override public void onEnable() { LabyModProtocolService.initialize(this); } - You're now ready to use the LabyMod 4 Server API in your BungeeCord plugin.
Minestom Library
- Add the
server-minestomdependency to your project's dependencies as described above. - Initialize the LabyMod 4 Server API before you call
MinecraftServer#start:LabyModProtocolService.initialize(); - You're now ready to use the LabyMod 4 Server API in your Minestom server.
Velocity Plugin
Running the Server API as a Plugin
- Add the
server-velocitydependency to your project's dependencies as described above. - Download the latest version of the
server-velocityjar file from the GitHub Releases. - Place the jar file in your server's
pluginsfolder. - Add the following code to the
Pluginannotation above your plugin's main class:dependencies = { @Dependency(id = "labymod-server-api") } - You're now ready to use the LabyMod 4 Server API in your BungeeCord plugin.
Shading the Server API into Your Plugin
- Add the
server-velocitydependency to your project's dependencies as described above. - Configure shadow in your project's
build.gradleorpom.xmlto shade theserver-velocitydependency into your plugin. - Initialize the LabyMod 4 Server API in your plugin's
ProxyInitializeEventlistener:@Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { LabyModProtocolService.initialize(this, this.server, this.logger); } - You're now ready to use the LabyMod 4 Server API in your Velocity plugin.