Tutorial: Live Eclipse Plugin Development for Spigot Servers

Discussion in 'Spigot Plugin Development' started by Noket, May 4, 2015.

  1. Live Plugin Development and Compilation for Spigot Servers in Eclipse

    Purpose: The objective of this tutorial is to teach a large audience of people to edit and debug plugins in realtime. This tutorial was written under the assumption that non-tech savvy users are attempting it.

    Advantages: Realtime variable manipulation, effective use of system resources, near instant plugin publishing/testing, instant stacktrace location.

    Eclipse IDE for Java Developers (Luna)

    Generated Spigot Jar using BuildTools

    An Active Workspace for Developing Plugins
    Follow the Bukkit Setup Tutorial


    Part 1: Running the Spigot Server
    Step 1: Under package explorer, create a folder called "server"


    Step 2: Right click on your project, and click "Properties". Navigate to "Java Build Path". Change the "Default output folder:" to

    Code (Text):
    (change VcMod to the name of your project in project explorer .. continue to do this throughout the tutorial)


    Step 3: Go to "Run/Debug Settings" and create a new configuration called "Spigot Server"


    Step 4: Change the "Main class:" to
    Code (Text):

    Step 5: Switch to the "Arguments" tab.

    Depending on which version of java you're running, you'll want different VM arguments:

    Java 7.. -XX:MaxPermSize=512M
    Java 8.. -XX:MaxMetaspaceSize=512M

    I'm running Java 8, so I'll be using MaxMetaspaceSize.


    Change the working directory to say:
    Code (Text):
    Again, change VcMod to whatever your project name is.

    Step 6: Switch to the "Classpath" tab. Remove any projects that exist under "User Entries" (yes, even Maven dependencies). Click on "User Entries" and click "Add External Jars..." to add your spigot-1.8.jar that you generated using BuildTools.


    Apply these settings and keep hitting OK until you reach Eclipse.

    Step 7:

    You see the little drop down arrow next to this lil' guy (let's call him Wilfred)?

    Click on it, and click on "Organize Favorites...". This window will pop up:


    Click "Add..." and add the Spigot Server configuration that you just created.

    Step 8:

    Find the little play button next to Wilfred from before.


    When you hover over it, it should say "Run Spigot Server". If it does, click on the play button. If you've followed all the steps properly, then you should now see this:


    (If the console doesn't open up automatically, you can open it manually by clicking Window > Show View > Console)

    Step 9: Left click on your Spigot project, and hit F5. This should refresh your project. If it doesn't refresh your project, right click on the project and click "Refresh".

    You should now see this:

    Open the eula, and change the boolean from "false" to "true". Save the file, and run the server again. In about 30 seconds, the server will finish loading. If you Refresh the Project again, you should see that many files have been created.

    Awesome job if you've gotten this far! We're halfway there. Now, all we have to do is make your plugin build automatically.

    Part 2: Making your Plugin Compile Automatically
    Step 10: Right click on your Project, and create a new file (New > File). Name it builder.xml


    Post the following code into the file that you just created and save it:
    Code (XML):
    <?xml version="1.0" ?>
    <!-- Configuration of the Ant build system to generate a Jar file -->
    <project name="VcMod" default="CreateJar">
      <target name="CreateJar" description="Create Jar file">
            <jar jarfile="./server/plugins/Plugin.jar" basedir="./target/classes/" includes="**/*" />
    Step 11: Right click on your project, click "Properties", and navigate to "Builders".


    ... Create a new ant builder:

    Step 12: Under the "Main" tab, in the "Buildfile:" input box, enter the following code:

    Code (Text):


    Again, change VcMod to your project name, and "builder" to whatever you named the file from Step 10.

    Step 13: You do the loopty loop and pull, and your shoes are looking good.

    Step 14: Click on the "Targets" tab. You'll notice at first that it looks something like this ...

    You'll want to set up the Auto Builder. Click "Set Targets..." (next to Auto Build)


    ... and click the check mark on the CreateJar option. Click OK.

    Apply and OK out of all windows until you reach Eclipse.

    Step 15: Right click on your plugins folder, and do "Show In" > "System Explorer" (Windows Explorer for windows users?).


    Your system explorer should open up. Add any dependencies that your plugin uses to this folder.

    Notice Plugin.jar .. hmmm, I wonder what that could be? ;)


    Step 16: Find Wilfred. He's been itching to be clicked. Give em a click.

    Step 17: Navigate to: Window > Open Perspective > Debug.

    If debug isn't there, click "Other".


    This beautiful window, your new home, will open.

    There's a lot going on here, but this is what you need to know: Various threads are created, and when you pause a thread, you can modify variables. If you look in the top right of the image, you can actually see the name and value of variables. If you want, you can change the variables themselves.

    If you run into an error, a stacktrace (with hyperlinks to the code, yay!) will pop out. Find the bugs, fix them, and save the bugged file. Your plugin will automatically compile (directly into the server/plugins/ folder, yay!). To test this new plugin, simply type "reload" into the console.

    Thank you for taking the time to read this tutorial: I hope it helps you as much as I know it has helped me.


    PS - Cheese is awesome
    • Useful Useful x 15
    • Informative Informative x 9
    • Like Like x 5
  2. Nice tutorial!
    I'd like to know how you can do this in Intellij :)
    • Agree Agree x 3
  3. jflory7

    jflory7 Retired Moderator
    Retired Benefactor

    Thread moved => Spigot Plugin Development
  4. Great tutorial!
    #4 Bladian, May 5, 2015
    Last edited: May 5, 2015
    • Like Like x 2
  5. It doesn't work for me, I have this error and the server stops :

    Loading libraries, please wait...
    2015-07-02 22:00:33,961 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream

    Found the solution. I had to add -Dlog4j.skipJansi=true in the VM arguments
    #5 val59000, Jul 2, 2015
    Last edited: Jul 2, 2015
    • Like Like x 3
  6. Great tutorial! I might use this sometime :)
  7. Awesome! Thanks for your contribution!
  8. I don't know if I'm missing something, but I have a plugin.yml in my Project folder, but I'm getting the error:

    Code (Text):
    [14:01:41 ERROR]: Could not load 'plugins\Plugin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:154) ~[spigot.jar:git-Spigot-0359393-9a17f01]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot.jar:git-Spigot-0359393-9a17f01]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot.jar:git-Spigot-0359393-9a17f01]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot.jar:git-Spigot-0359393-9a17f01]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:524) [spigot.jar:git-Spigot-0359393-9a17f01]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
        ... 6 more
    My plugin.yml reads:

    Code (Text):
    name: SmokeBomb
    main: com.digiduncan.smokebomb.SmokeBomb
    version: 1.0
            description: Teleport like a ninja!
            usage: /smokebomb [player] OR /smokebomb [x] [y] [z] <p> <y>
    What's going on? I can get the server running, but my plugin won't load. :(
    • Agree Agree x 1
  9. Show the structure of your project. You have put plugin.yml in the wrong directory I think.
  10. First of all I want to thank you for your great tutorial! :);)
    But I have one problem. When i build the plugin.jar there isnt any plugin.yml or config.yml. How can I include them?

    (And sorry for my Englisch :(, Im 14 and from Austria.)
  11. Excellent tutorial -- but I'm having the same problem as other people. This does not explain how to include the plugin.yml file. OP, or anyone else who figures it out, would you mind explaining how to do this?

    Edit for posterity:

    I found a solution that worked for my specific needs. AFTER following OP's instructions:
    • go to properties, java build path, set it back to bin (in my case: "MinecraftKingdoms/bin")
    • use this as your builder.xml (change names appropriately):
    Code (Text):
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="MinecraftKingdoms" default="makejar" basedir=".">
        <target name="makejar" description="Create a jar for the project">
            <mkdir dir="target"></mkdir>
            <jar destfile="/Users/jacobcrofts/minecraft-test-servers/PlainsKingdom/plugins/MinecraftKingdoms.jar">
                <fileset dir="bin/"></fileset>
                <fileset file="plugin.yml"></fileset>
                <fileset file="config.yml"></fileset>
    This is ONE way to ensure that your plugin.yml and config.yml are present. For additional clarity, these two files are right in the directory MinecraftKingdoms/ and not in sub-folders, as per convention.

    Inspiration from here.
    #11 JacobCrofts, Jul 3, 2016
    Last edited: Feb 27, 2018
    • Like Like x 1
    • Winner Winner x 1
    • Useful Useful x 1
  12. this looks like a over-complicated alias to typing 'stop' into the console.
  13. It really isn't, it saves a lot of time on loading, as well as avoiding to go through the menu to compile. Extreme improvement to workflow, especially when tweaking small things
    • Like Like x 1
  14. I actually prefer to continue opening my test servers from their original locations. Easier to keep track of them that way. I like this because it exports my plugins for me, and I *think* it updates my plugins in real-time.
  15. How do i export it to another directory that is not in workspace ? (in linux(ubuntu)
    lets say i have Workspace: home/Projects
    and a server home/desktop/server
    how do i export it in the home/desktop/server/plugins folder ?
  16. Brilliant post thank you SO MUCH!

    However, when I try to use the debugger with a player on the server it often causes the program I'm attempting to debug to crash, because of the player disconnecting due to a timeout error.

    Q: Is there any way to disable client timeout errors so that I can debug with a player connected to the server??


    What operating system/crazy-theme-thing are you using because I like the way your GUI looks
  17. The system is Linux Ubuntu
  18. I love you! <3
  19. Thanks a lot !
    It's very simple now for testing plugin