How to Make Your First Minecraft Plugin (Spigot and Paper)
Want to build your own Minecraft plugin? This guide covers the tools, the project setup, and writing your first working command and event.
Writing your own Minecraft plugin is the gateway to customising a server exactly how you want, and to selling your work. Here is how to build your first one.
1. Set up the tools
You will need:
- The Java Development Kit (JDK) installed.
- An IDE like IntelliJ IDEA or VS Code.
- A build tool, Maven or Gradle, to manage the Spigot or Paper API dependency.
2. Create the project
Start a new project and add the Spigot or Paper API as a dependency through Maven or Gradle. Paper is recommended because it is faster and supports more, while staying compatible with Spigot plugins.
3. The plugin.yml
Every plugin needs a plugin.yml file describing it: the name, version, main class, and any commands it registers. The server reads this to load your plugin.
4. Write the main class
Your main class extends JavaPlugin and overrides onEnable (runs when the plugin loads) and onDisable. This is the entry point for everything your plugin does.
5. Add a command and an event
The two building blocks:
- Commands let players trigger actions by typing, like
/heal. - Event listeners react to things happening in the world, like a player joining or a block breaking.
Register a command in your plugin.yml and handle it in code; register an event listener to respond to gameplay.
6. Build and test
Build your project into a .jar, drop it in your test server plugins folder, and start the server. Watch the console: it tells you if the plugin loaded and reports any errors.
Where to go next
Once you can make commands and handle events, you can build almost anything. When your plugin is good enough that other server owners would pay for it, you can sell it on ModForge with protected delivery, so your work earns instead of getting leaked.