This post pertains specifically to Bukkit, which is no longer available due to a DMCA takedown request, and the future of Bukkit is somewhat in question now unfortunately.
Getting started developing in any platform always has a learning curve as you find your way around the language(s), tools and conventions involved. Developing plugins for Bukkit is no different. There are a number of good tutorial resources on this topic, so rather than do a full write-up we’ll link to a couple of tutorials and then add some additional comments to outline the process and identify some of the things to watch for — the ‘gotchas’ of plugin development.
The general process for getting started can be enumerated in these steps:
Install the following tools to set up your development environment.
- Download Oracle’s Java SE JDK (the JRE alone is not sufficient). Go ahead and install that first since you will need this to run Eclipse.
- Download and install Eclipse (if you are already set up to do Java development with another IDE, such as NetBeans, that’s great. In this post we’ll focus on Eclipse though.)
- Get the Bukkit jar file. (craftbukkit-1.7.10-R0.1-20140804.183445-7.jar) [Which you can’t get anymore]
You will find several tutorials (both documents and videos) with a bit of searching online. But two pretty reasonable tutorials to get your started are here:
Bukkit Coding for Dummies — a 10 page Google Doc covering pluggin development using Eclipse. This has some useful screen shots and code examples.
These tutorials will give you the details. For the sake of having a more general overview though, the steps for creating a plugin is basically this:
1. Launch into Eclipse and select your workspace — some directory somewhere on your computer that you can let Eclipse more or less have free reign in. Eclipse will use that directory
2. Create a new Java Project.
3. Add a new Package. This is basically your java source file. The convention in the world of Java is to name packages using a reverse-url, so you might use com.myfullname.bukkitone. (And no, you don’t need to really have the name registered or anything like that… although it is a nice touch if you do.)
4. Write up your plugin (see the tutorials above for more details there.) Be sure to import the appropriate libraries as needed.
5. Create your YML file for your Pluggin. This is where you will list the commands your plugin recognizes.
6. Compile your code into a JAR file. Select your project in the Package Explorer and then Select Export -> JAR File. Uncheck .classpath and .project from the resources to export, and select the location for Eclipse to save your jar file. You can click through to the next couple of screens but the defaults after this should be fine. You can also just hit ‘Finish’.
7. Copy your jar file to your Minecraft server’s plugin directory and start up Minecraft. Minecraft should recognize the plugin and load it. You should see this if you tail the logs/latest.log file.
Things that may trip you up….
- Go to your projects properties and go to the Java Build Path section.
- Click on the Libraries tab.
- Click on the Add External Jars button and find the craftbukkit jar file on your computer.
org.bukkit.plugin.InvalidPluginException java.lang.UnsupportedClassVersionError de/nofear13/craftbukkituptodate/CraftBukkitUpToDate : Unsupported major.minor version 51.0
- Go to your projects properties and go to the Java Compiler section.
- Uncheck ‘Use compliance from execution environment…’
- Set Compiler Compliance Level to 1.6