Build your first plugin
Build a SoulFire plugin from the official template and load it as a Fabric mod.
Diese Anleitung gibt es nur auf Englisch.
This guide builds a plugin JAR from the official SoulFirePluginExample template and loads it into SoulFire. The template already contains the Fabric, Loom, and SoulFire setup.
Before you start
- Install Java 25 and Git.
- Use IntelliJ IDEA, or another IDE that supports Gradle and Fabric Loom.
- Have a SoulFire server where you can copy JARs into
minecraft/mods.
Align the template with your SoulFire server
The template's gradle/libs.versions.toml can pin an older SoulFire and Minecraft version than your SoulFire server.
The examples below compile against the 2.10.8 release baseline, which runs Minecraft 26.3.
Update the Minecraft, Fabric Loader, and SoulFire versions together.
Changing only the SoulFire version leaves Minecraft classes that do not match the runtime.
If the CodeMC metadata does not list your SoulFire server version, build that SoulFire release tag from source and publish it to your local Maven repository.
The template already reads mavenLocal().
Read Gradle and project layout before making that change.
Create the project
Clone the template
git clone https://github.com/soulfiremc-com/SoulFirePluginExample.git my-soulfire-plugin
cd my-soulfire-pluginRename the plugin metadata
Update these files first:
settings.gradle.ktsbuild.gradle.ktsgradle/libs.versions.tomlsrc/main/resources/fabric.mod.json- the Java package under
src/main/java
Make your plugin ID lowercase and hyphenated.
Reuse the same ID consistently in PluginInfo, fabric.mod.json, settings namespaces, mixin config names, and access widener names.
Keep the Fabric entrypoint
SoulFire plugins are Fabric mods, so the JVM entrypoint is still a normal ModInitializer:
package com.example.myplugin;
import com.soulfiremc.server.api.SoulFireAPI;
import net.fabricmc.api.ModInitializer;
public final class Main implements ModInitializer {
@Override
public void onInitialize() {
SoulFireAPI.loadPlugin(new MyPlugin());
}
}SoulFireAPI.loadPlugin(...) registers the plugin with SoulFire.
Implement the plugin class
For external plugins, extend ExternalPlugin and provide PluginInfo:
package com.example.myplugin;
import com.soulfiremc.server.api.ExternalPlugin;
import com.soulfiremc.server.api.PluginInfo;
import com.soulfiremc.server.api.event.bot.BotConnectionInitEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.lenni0451.lambdaevents.EventHandler;
public final class MyPlugin extends ExternalPlugin {
private static final Logger LOGGER = LoggerFactory.getLogger(MyPlugin.class);
public MyPlugin() {
super(new PluginInfo(
"my-plugin",
"1.0.0",
"Example SoulFire plugin",
"YourName",
"MIT",
"https://example.com"
));
}
@EventHandler
public void onBotInit(BotConnectionInitEvent event) {
LOGGER.info("Bot {} was initialized", event.connection().accountName());
}
}PluginInfo takes the ID, version, description, author, license, and website, in that order.
The template's example class passes some of these in a different order, so do not copy its arguments.
Install it into SoulFire
Copy the jar into SoulFire's Fabric mods directory and restart SoulFire:
- all deployments:
minecraft/modsunder the SoulFire server's base directory - Docker:
/soulfire/data/minecraft/modsinside the container
Use persistent data to locate that directory. The remote client's installation directory is not the SoulFire server's mod directory.
Check that the plugin loaded
Restart SoulFire, then use one of these checks:
- open the project in the app and view Plugins
- run
pluginsin the terminal
If the plugin is missing, read the startup log.
Fabric loading problems, missing dependencies, and a bad Mixin config fail before SoulFire sees your ExternalPlugin.
For Fabric errors, see Gradle and project layout and the Fabric documentation.
Check the event with one bot
Start one bot in a test project.
Expect the SoulFire server log to include Bot <account name> was initialized.
This event fires before the bot has a usable player or world.
For actions that need a joined player, use a tick event such as BotPostTickEvent and check that connection.minecraft().player is not null.
Stop the bot after the check.
If the plugin appears in plugins but logs nothing, check that your handler has @EventHandler and takes the right event type.
Add settings and a plugin page
The official example plugin shows the standard pattern:
- create a
SettingsObjectclass withpublic static finalproperties - listen for
InstanceSettingsRegistryInitEvent - call
event.settingsPageRegistry().addPluginPage(...) - read values through
connection.settingsSource()
The page then appears in the GUI and CLI. See Settings and metadata.
What to do next
- Gradle and project layout for the important build files
- Event system to choose the right hook
- Mixins and access wideners if events are not enough
Zuletzt aktualisiert am
War diese Seite hilfreich?
