Getting Started with Spigot Plugin Development
Spigot is the most popular server software for Minecraft Java Edition. It is a fork of CraftBukkit with performance improvements. Writing plugins for Spigot lets you add custom features to your server.
Setup
You need:
- Java 21 or higher
- The Spigot API (or Paper API for better performance)
- Maven or Gradle for building
Your project should have a plugin.yml file that tells Spigot what your plugin does:
name: MyFirstPlugin
version: 1.0
main: com.example.MyFirstPlugin
api-version: 1.21
Your first command
Commands are how players interact with your plugin. Here is a simple greet command:
public class MyFirstPlugin extends JavaPlugin {
@Override
public void onEnable() {
getCommand("greet").setExecutor(new GreetCommand());
getLogger().info("MyFirstPlugin enabled!");
}
}
The command executor handles what happens when a player types /greet:
public class GreetCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
sender.sendMessage("§aHello from MyFirstPlugin!");
return true;
}
}
Listening to events
Plugins come alive when they react to things happening in the game. Events are fired for almost everything including players joining, blocks breaking, and entities dying.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.sendTitle("§6Welcome", "§eto " + player.getName(), 10, 40, 10);
}
Register the listener in onEnable:
getServer().getPluginManager().registerEvents(new JoinListener(), this);
Building and testing
Use Maven or Gradle to build your plugin into a JAR file. Drop the JAR into your server’s plugins folder. Restart the server. Test your plugin with a friend or a second Minecraft account.
Next steps
Once you have the basics, try building something useful. A teleportation system, a home plugin, or a simple economy. Each project will teach you more about the API.
If you want to see a more complex example, check out the minigame plugin guide.