For those new to Minecraft Plugins, there's a lot of new and old documentation to run through on the web.
Additionally plugins compiled on newer versions of Java weren't working on older stable Minecraft server versions.
I've captured my learning in two places.
-
This guide covers the workflow of editing, compiling and testing plugins.
-
A plugin starter template: https://github.com/briangershon/minecraft-plugin
A plugin in a Java module that runs on a Minecraft server, and be used to create commands, games, tools for editing the world, etc.
This is different than Minecraft Mods which actually change and add features to Minecraft itself.
To test your plugin, you need a Minecraft server running locally on your machine, and there are many servers. Spigot and Paper are two popular ones.
I started with Creating a blank Spigot plugin, using Maven.
Then took a slightly different path:
- using Eclipse instead of IntelliJ
- compiling the plugin directly via the terminal and not rely any specific IDE
I've tested this guide on MacOS with these dependencies:
- Java 14 was installed
- Installed Maven via Home Brew (
brew install maven).
I installed Spigot into ~/spigotmc.
In one terminal window, I run Spigot via my run.sh script:
#/bin/sh
java -Xms2G -Xmx2G -jar spigot-1.16.4.jar nogui
# java -jar BuildTools.jarI can then restart/reload this server as I iterate on the plugin.
Edit plugin via Eclipse for nice code auto completion.
I use a second terminal session for compiling and copying the plugin to the local server.
mvn clean package
cp target/PluginDemo-n.n.n.jar ~/spigotmc/plugins/
Flip over to ~/spigotmc terminal and type reload. Or if server not running use run.sh script.
You can then run the Minecraft client, choose Direct Connection, type localhost for Server Address. Inside Minecraft, you can type /plugins and you should see yours listed.