Skip to content

Developer Guide (9 Compiling)

TheBusyBot edited this page Oct 18, 2024 · 1 revision

This is a part of our Developer Guide, you can find a full overview on our main page.

This guide assumes you are using Maven for your project.

Compiling

In order to test your addon, you need to compile the addon into a .jar file (the files that servers recognize as plugins).
If you've chosen to use Maven for your project (as we suggested in Part 1), you can simply run the following command in the root directory of your addon:

$ mvn clean package

Your compiled .jar can be found in the target/ directory in the project folder.

IntelliJ also provides a way to compile your plugin.
On the right side of the editor window, click the button that says Maven. (If there is no such button, go to the top bar and navigate to View > Tool Windows > Maven)
Now in the project folder, open the folder called Lifecycle and double click clean. Once that is complete, double click package.

Once again, your compiled .jar can be found in the target/ directory in the project folder.

Creating a testing environment

The next step is to run a server with your freshly compiled addon.
We recommend Paper as your server software.
Do note that only Spigot and its forks (Paper, Purpur, etc.) are supported by Slimefun and its addons.

The server should be in the form of a .jar file.
Create a new folder somewhere dedicated for your server, and place the downloaded server .jar file there.

Now, open the command line and run this command (in the server folder) to start the server:

java -jar [name of jar file].jar

This will create eula.txt in your server directory, which you must open and change false to true on the last line to run your server.
Once you do that, rerun your server by reentering the command.

You will now see a folder called plugins/ in the same place. This is where you will put Slimefun, your addon, and other plugins for your server.
Place your compiled .jar as well as the Slimefun jar into this folder.

Stop the server by typing stop into the console, and rerun the server with the plugins installed. Now, if you did everything right, the server should now be running with your addon.

Trying out your addon

Now, you can launch Minecraft and join the server that is running.
In the multiplayer tab, create a new server with the address localhost.
Hopefully, once you join it, you will be in a server with Slimefun and your addon installed. To verify this, run /sf versions to display Slimefun and the installed addons.
If your addon appears, it was a success!

Recompiling

Let's say that you want to make changes to your addon now, whether you're adding a new item or fixing a bug.

After you make your changes, compile your addon again.
The compiled jar will be in the target/ folder of the project.
Now, stop the server, remove the old addon .jar, and put in the new .jar. Then rerun the server.

As always, if you have any questions, you can ask them in #programming-help in the Slimefun Discord.

Publishing

If you wish, you can now publish your addon.

Clone this wiki locally