An example plugin for the spigot Minecraft server that can be used as a template to write your own plugins. Minecraft plugins are a great way to learn Java programming.
In order to try this out you need the following software to be installed on your machine:
Clone the template project to your system:
git clone https://github.com/joe-akeem/minecraft-plugin-template.git
This project uses Maven for building. So on your command line run
mvn package
To test the plugin we fire up the spigot Minecraft server using an existing docker image.
In order for it to find the jar containing our plugin we need to mount the target
folder to /data/plugins
docker run --rm -e EULA=true -p 25565:25565 -v $(pwd)/target:/data/plugins cmunroe/spigot:1.16.4
To test it with bukkit do:
docker run --rm -e EULA=true -p 25565:25565 -v $(pwd)/target:/data/plugins cmunroe/bukkit:1.16.4
In the log produced by the server on the command line watch out for the following lines indicating that the plugin was deployed properly:
[19:33:52 INFO]: [TemplatePlugin] Enabling TemplatePlugin v1.0
[19:33:52 INFO]: [TemplatePlugin] Added the 'enrich' command.
Start the Mincraft client on your computer and connect to the local Mincraft server by specifying localhost
as Server Address.
Open the command line in Minecraft (by pressing t
) try the new command and see what happens:
/enrich
To play with the code e.g. import this plugin in Intellij. The community edition is absolutely sufficient. Read here how to import an existing Maven project.
Once you're done fiddling with the code don't forget to run mvn package
and restarting the docker image for
your changes to take effect.
To install your plugin in another Minecraft server just copy the file target/mc-plugin-template-1.0-SNAPSHOT.jar
to
that server's plugin
folder.
TODO - contributions welcome!