javadebuggingintellij-ideaminecraftbukkit

Run Configuration to Debug Bukkit/Minecraft Plugin in IntelliJ IDEA?


I'm helping my kid learn to create Minecraft plugins, although I don't have much experience with Java or IDEA. Everything is working well so far, but in order to execute our code, we have to:

  1. Make the project in IDEA (output path is set to Bukkit/plugins)
  2. Run Bukkit server
  3. Start Minecraft and connect

I'm not sure that anything can be done about (3), but it seems to me that IDEA should be able to handle (1) & (2) in a single step. Also, we cannot presently debug using this configuration.

In Visual Studio / .NET, I would just need to specify the executable -- java/craftbukkit, in this case -- as an "external program", and it would solve all of these problems. In IDEA, though, it seems that I am supposed to add a Run Configuration, and I don't see an option which allows anything like a "host application." Instead, it wants the full classpath to the main for Bukkit, and it isn't clear to me what that would be. I have also seen it suggested elsewhere that even this won't work without a debug build of Bukkit. but I don't really want to debug Bukkit; I just want to debug our plugin code only.

I found these instructions for remote debugging Bukkit plugins, but is that actually necessary? It doesn't solve the "two steps to run" problem; it actually makes it worse!


Solution

  • I realize this question is more than a year old, but I too had this problem recently and found no satisfactory answers. This is how I solved it, with help from @hunterboerner's answer.


    First thing is you need to create an artifact that compiles the plugin JAR to the testing server's plugins directory:

    1. Go to "File > Project Structure > Artifacts"
    2. Add a new Artifact from the template "Other"
    3. Set "Output Directory" to the plugins directory of the testing server
    4. Under "Available Elements", right click the entry "'ProjectName' compile output" and then click "Pack into /ProjectName.jar"

    If your project has no MANIFEST.MF file:

    1. Select the new jar file entry under "output root" and click "Create Manifest..."
    2. Navigate to the directory the project's java source files are kept (e.g. src/main/java/)

    An example artifact configuration: example artifact config

    Next, you need to create a Run Configuration that executes the Spigot server JAR:

    1. Go to "Run > Edit Configurations..."
    2. Add a new "JAR Application" configuration
    3. Set "Path to JAR" to the testing server's Spigot JAR
    4. Set "Working directory" to the directory of the testing server
    5. Under "Before launch", add a new "Build Artifacts" task
    6. Checkmark the artifact created above on the list

    An example run configuration: example run config

    After completing these steps, "Debug" the run configuration or press SHIFT+F9. This will automatically build the plugin JAR, copy it to the testing server and execute that server with full debugging facilities, including breakpoints and hot code swapping.