Compatibility
Minecraft: Java Edition
1.21–1.21.1
1.20.1–1.20.6
Platforms
Fabric
Supported environments
75% of ad revenue goes to creators
Support creators and Modrinth ad-free with Modrinth+Creators
Details
Licensed GPL-2.0-or-later
Published 5 months ago
Updated 2 months ago
ServerLibraries
ServerLibraries is a library for Minecraft server-side Fabric mod development, aiming to simplify the development experience and make it feel like making a Bukkit-based plugin.
Features
- Simplified event handling with hundreds of mapped events.
- Easy sync/async scheduling.
Example Usage
Here's an example of how to use ServerLibraries to handle events:
// Listener class that handles server events
public class ExampleListener implements Listener {
@EventHandler
public void onPlayerChatEvent(@NotNull PlayerChatEvent event) {
event.setCancelled(true);
ServerPlayerEntity player = event.getPlayer();
String message = event.getMessage();
// Format the message to display the player's name followed by the message
String formattedMessage = player.getName().getString() + " > " + message;
// Broadcast the formatted message to all players and log it in the console
msg.broadcast(formattedMessage);
msg.log(formattedMessage);
}
@EventHandler
public void onPlayerMoveEvent(@NotNull PlayerMoveEvent event) {
// Get the player and their position
ServerPlayerEntity player = event.getPlayer();
BlockPos pos = player.getBlockPos();
// Format and send the coordinates as an action bar message
String message = "X: " + pos.getX() + " Y: " + pos.getY() + " Z: " + pos.getZ();
msg.sendActionBar(player, message);
}
}
// Main Fabric mod class
public class ExampleMod implements ModInitializer {
@Override
public void onInitialize() {
EventsRegistry.registerListener(new ExampleListener());
}
}
Installation
To include ServerLibraries in your project, add the following to your build.gradle
file.
Maven Repository
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}
Dependency
Add the following dependency. Replace <version>
with the version you want to use. You can find available versions here or use the version below for the latest stable release.
dependencies {
modImplementation "maven.modrinth:kjqxZ07F:<version>"
}
Documentation
Docs and Javadocs can be found on here.