<imadam.io/>
HomeBlogContact Me

Journey into Spigot: Creating My First Plugin

by Adam B • 13/08/2022

# Coding
An introspective account of my journey to learn Spigot by creating my first plugin. This post serves as a reflection and guide for those embarking on a similar path.

A New Journey

Ready for embarkation, let’s begin.

Step 1: Installing Essential Plugins

In my quest to delve into the realm of creating Minecraft Plugins using Java, my first crucial decision was choosing an appropriate IDE.

I opted for IntelliJ. Its free accessibility for personal use, aesthetic dark theme, and extensive library of plugins proved too enticing to resist. In aid of this journey, I downloaded several plugins:

Step 2: Building A Project

Using the Minecraft Development plugin I was able to generate a ready-to-use project, designed specifically for working with Spigot. The plugin provides a wizard to guide you through the process of creating a new project.

Choosing API

To adhere to software engineering best practices, I used my Top-Level Domain (TLD) and website name for the GroupId and coined the name of the plugin as ArtifactID, yielding dev.lerndmina & exampleplugin. I chose Maven as my build tool, leaning on the fact that most tutorials utilize it.

Specifying Build Settings

Subsequently, I filled out necessary and optional plugin settings, especially paying attention to the Minecraft Version setting, which determines the API version I needed to reference in crafting my plugin.

Defining Settings

Lastly, I designated a local name for my project and that marked completion of this setup phase!

Naming the Project

Behold, the glorious main class!

Displaying the Main Class

The next step involves server setup for testing.

Step 3: Establishing A Test Server

For my testing servers, my preference leans towards Paper since it offers both speed and stability. Let’s navigate to papermc.io, and download the version we defined earlier in the plugin settings - 1.19.

We create a folder to host our Minecraft Server, and move the server.jar file into it. Make sure to remember the jar file’s name as it will be required later.

Returning to IntelliJ, the path to navigate is:
File > Project Structure > Artifacts > ➕ > JAR > From Modules With Dependencies...

We specify the path to the Main Class, which in this case is dev.lerndmina.exampleplugin.ExamplePlugin and affirm with OK. The final alteration here pertains to the Output directory, set this to the plugins folder inside your Minecraft Server folder.

Sounds easy, right?

Next, we add the settings allowing IntelliJ to launch the server for us. With a single click, we can build and run the plugin. Navigate to your current build config and edit configurations.

Access Edit Configurations

A new Jar Application is created by clicking ➕ > 📦 Jar Application, and providing a name for it.

Take a quick look at the image below to follow the process and customize according to your needs. Jar Application Config

Finally, by navigating to the ‘before launch’ section and clicking the ➕, the build artifact task we created earlier is added.

And Voila! With just one push of a button, we can build our plugin and spin up a server to test it. Not too daunting after all, right?