Getting started with Bukkit and CraftBukkit

Discussion in 'Bukkit Help' started by Oslarathos, Jan 4, 2011.

Thread Status:
Not open for further replies.
  1. Offline


    I excluded an important part of plugin creation, at some point you'll have to create a file called "plugin.yml" located in your source folder prior to compiling. The contents of this file should consist of:
    name: < Your plugin's name >
    main: < the full name of the class that extends JavaPlugin >
    version: < plugin version >
    The sample plugin would consist of:

    name: SamplePlugin
    main: com.dinnerbone.bukkit.sample.SamplePlugin
    version: 0.1
  2. Offline


    Bah you beat me to it.

    This is my step by step guide (in text form)

    Server Installation

    Download Bukkit and CraftBukkit to a directory. This is the API and the Server software built by hudson.

    Later, you would presumably use the Stable official builds.

    Create a .bat file with:

    java -Xms512M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar

    in the same directory.

    Double click to start the server (this creates the sub directories)

    type in stop to stop it

    Sample Plugin Building

    On to compiling the sample plugin:

    File -> New -> Java Project

    Enter SamplePlugin into Project Name

    Click Finish

    Right click on SamplePlugin (left windown) -> properties

    Select java build path in the left window and add external jars in the right

    Add the bukkit.jar file that you downloaed

    Right click on SamplePlugin (left windown) -> New -> Package

    Enter com.<yourname>.bukkit.sample

    Right click on SamplePlugin -> src -> com.<yourname>.bukkit.sample

    Select new -> class

    Enter SamplePlugin as the class name and press finish

    Repeat for SamplePlayerListener and SampleBlockListener

    Get the source from here

    Copy and paste the source files into your eclipse project

    Note: Don't copy the package name, eclipse sets that up for you

    Right click SamplePlugin->src and choose new -> file

    Filename is plugin.yml

    Copy and paste the yml file from here

    Replace Dinnerbone with your name

    Delete the version number (Don't do this with latest builds)

    Save everything

    Right click on SamplePlugin -> Export

    Select Java -> Jar file

    Click next

    Click browse to place the .jar file in the plugin directory of craftBukkit

    Make sure java sources and resources is selected (it it off by default)

    Click finish

    use start.bat to start the server

    What is does is:

    - information when a player joins or leaves (but you can't actually see it, since it says that you joined before you joined :) ).
    - /pos command
    - /pos x y z to teleport
    - /debug will cause it to send you movement info

    - allows cactus to be built anywhere
    - prevents sand and gravel from falling if they are below an iron block

    (Ofc, it needs a /item command to test that on a fresh server :) ).
  3. Offline


    Good, but one part is incorrect, you are supposed to build your plugin with Bukkit on the build path, not CraftBukkit.
  4. Offline


    Updated. The main reason I did it that way was to only have 1 .jar to download. However, using the bukkit file is better as it ensures that you aren't using any craftBukkit specific stuff.
  5. Offline


    Some great start-up instructions Oslarathos (and Raphfrk)!

    I have some questions about the process:

    When following Oslarathos video step-by-step (install eclipse, egit plugin, m2maven plugin, get the bukkit/craftbukkit git repo's), at the 7:20 mark - (right click craftbukkit -> Run As -> 9 Maven package), you just assume that since your works - it works for everyone, but it doesn't. There is some dependency issue with the bukkit jar that the build fails and I couldn't get it to work.. Perhaps explain how to get by that part?

    The way I resolved this is to completely scrap the Eclipse headache, and install netbeans + maven separately, and it worked without no issues at all - everything built without any issues.
    --- merged: Jan 5, 2011 1:50 PM ---
    Also, using the batch file to start up the craftbukkit server, it works fine. When adding the bukkit plugin to the mix, it seems to error out on me (possible missing plugin.yml from the bukkit project perhaps? i swore it existed)... here's the error:

    Jan 5, 2011 8:46:44 AM org.bukkit.plugin.SimplePluginManager loadPlugins
    SEVERE: Could not load plugins\bukkit.jar in plugins
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(
            at org.bukkit.craftbukkit.CraftServer.<init>(
            at net.minecraft.server.ServerConfigurationManager.<init>(
            at net.minecraft.server.MinecraftServer.d(
    Caused by: Jar does not contain plugin.yml
            ... 8 more
  6. Offline


    you are talking about java
    is it possible with c# (using pluginloader)
    and can somebody tell me how to use pluginloader
  7. Offline


    You now have to have a "version: #" in your plugin.yml. I've edited the OP to reflect this change.
  8. Offline


    Great tutorial -- helped me a lot with porting my plugins! Just one thing:
    I noticed that CraftBukkit has the chunk events, but Bukkit itself doesn't (at least not the version I had). These are hooks that ARE going to be implemented in Bukkit, right?
  9. Offline


    I put both of those files into a directory, and when i ran the .bat file it just gave an error telling me "java" isn't recognized as a command and closes instantly. is there something im doing wrong?

    EDIT: I managed to get it working, apparantly instead of just putting "java" at the beginning i needed to put the location of java.exe in programs.
  10. Offline


    The method isDebugging(Player) is undefined for the type SamplePlugin 

    This error shows up after pasting example code. But if i type "plugin.", it shows me isDebugging(Player) on suggestions list.
  11. Offline


    Actually, if you add the location (not the file name but the folder name) to your PATH environment variable, all you need to do is type 'java *parameters*'. If you need help with that, I can tell you how to do that. I would actually suggest doing this for later stuffs (like if you need to make javadocs, you can type 'javadocs *parameters*'; you can easily make use of other programs in that folder, too).
  12. Offline


    Verified as not working. The command prompt closes as soon as it is opened.
  13. Offline


    That's funny, worked for me perfectly fine. Make sure that the path to your java.exe file is in the PATH environment variable. Also make sure that the name of the jar file in your statement is the same name as the CraftBukkit jar file you downloaded (the name may have changed).
  14. Offline


    "PATH environment variable"? I'm sorry, I don't know what you're talking about.

    I followed the tutorial exactly, and my folder looks like this:

  15. Offline


  16. Offline


    Unfortunately, that doesn't help. Please refer to the text and picture above and tell me what I am doing wrong. As I said above, I have only done as the tutorial instructed.

    It's like I've taken a brand new computer and followed the tutorial without installing any programs (besides Java and Minecraft).
  17. Offline


    Alright, here's a test you can run before going into the details about environment variables:
    Click start, then into the run/search bar (depends on your version of Windows), type 'cmd' (minus the quotes). Use the 'cd' command to navigate to your bin folder. E.g. type 'cd C:\Bukkit\bin\'. Then execute the batch file (type 'serverstarter.bat'). What does it print out?
  18. Offline


    I appreciate the help you've given me so far. Here is the text:


    To clarify, I have Java installed.
  19. Offline


    Ah. You're going to have to modify the PATH environment variable, then, as the system can't find the java.exe file. Here's what to do:
    Open the Control Panel, select System, then Advanced System Properties. Click Environment Variables (at the bottom of the window).
    In the bottom table (labelled System Variables), select the 'PATH' variable and click the 'Edit...' button. It may also be called 'Path' (or possibly 'path', but I haven't seen that variation on capitalization).
    Find the path to your java.exe file and copy it (I will refer to it as *path* in the next step)
    Put a semicolon (';') at the end of the text in the edit field, then paste your path into it (should have added, collectively, ';*path*').
    Click 'Okay' until you're back to the Control Panel. Close that out, and repeat the test. Does it start the server, or does it repeat the error? If it repeats the error, tell me exactly what you added to the PATH variable.
  20. Offline


    The problem has been solved and the server works, thank you for the massive help.
  21. Offline


    Do you remember where you installed Java to in the first place? I found mine here:
    C:\Program Files\Java\jre6\bin
    Check your Java program folder for the latest version of the JRE (or, if you prefer, the JDK if you have that installed), then go to its bin folder. Use that path. If you can't find it in 'Program Files\Java', check 'Program Files (x86)\Java'.

    Glad to hear it works. Next time, though, could you leave a reply? Goodness I've been waiting for the past 30 minutes for a reply to see if I needed to help further xD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jan 8, 2016
  22. Offline


    Same problem ( dependencies) could you explain how you set this up in netbeans? Maybe a small step by step? =3

    Disregard that. Works fine in Linux. Another reason to drop Windows all together.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jan 8, 2016
  23. Offline


    I'm getting this same issue and I cant seem to resolve it no matter how hard I try, even after reading the docs multiiple times again and validating manually multiple times using winrare that the file does in fact exist.

    Running on windows, but should that really matter? Jar does not contain plugin.yml

    EDIT: Compiler was placing the file int the wrong path inside the .jar file.. it was placing it in with the .class files and not on the top of the directory structure.. look for this using winrar if you get that error, hen move the location of the file in your project file to compensate.
  24. Offline


    It runs on windows perfectly fine, as long as you compile your plugin correctly.
  25. Offline


    Missing an important step. You have to mvn clean install bukkit before you mvn clean package craftbukkit..
    So for eclipse you would
    right click bukkit, runas> 8 Maven Install
    then rightclick craftbukkit, runas>9 Maven package.

    For linux (Debian systems, replace apt with yum etc) and without using eclipse
    sudo apt-get install git
    sudo apt-get install maven2
    mkdir bukkit
    mkdir craftbukkit
    cd bukkit
    (run as root in non-sudo environments)
    sudo git init
    sudo git pull git://
    sudo mvn clean install
    cd ..
    cd craftbukkit
    sudo git init
    sudo git pull git://
    sudo mvn clean package
    Both compiles will be in target directory.
  26. Offline


    In the File I get Errors.

    Description    Resource    Path    Location    Type
    The method isCancelled() of type EntityCombustEvent must override a superclass method    /bukkit/src/main/java/org/bukkit/event/entity    line 19    Java Problem
    and the same Error for setCancelled().

    When I compile Plugin it just gives me just Warnings. When I start server with the sample-Plugin I get this:

    11.01.2011 10:37:57 org.bukkit.plugin.SimplePluginManager loadPlugins
    SCHWERWIEGEND: Could not load plugins\SamplePlugin.jar in plugins: null
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(
            at net.minecraft.server.MinecraftServer.e(
            at net.minecraft.server.MinecraftServer.c(
            at net.minecraft.server.MinecraftServer.d(
    Caused by: java.lang.ClassNotFoundException: com.hans.bukkit.sample.SamplePlugin
            at$ Source)
            at Method)
            at Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            ... 8 more
    2011-01-11 10:37:57 [INFO] Done! For help, type "help" or "?"
    Can someone help me?
    I am not that up to date with all the java-stuff, but i really want to get into it. :)
  27. Offline


    You did't override method. That mean you need to write/implement in your class(SamplePlugin) method isCancelled() or it won't work.
  28. Offline


    I'm having the same issue as TheArcher, I've done as AnonymousJohn described with no change. Only differences from what I can tell are; I'm using a 64-bit OS so my java dir is in 'Program Files (x86)' and I have the Bukkit files on another HDD(which shouldn't make any difference). I don't really know a lot about this kind of stuff but from what I can tell this shouldn't be doing this at all. I've used .bat files to run .jar files on several occasions without issue, why would this be any different? Any help would be appreciated, but it's not urgent or anything. I'm just curious to have a play around.
  29. Offline


    Run the test I gave TheArcher and tell us the exact results, as well as the full PATH variable described. Then give us the path to your Bukkit jar file, the path to your batch file, and the exact contents of said batch file.
    Also, I'm pretty sure having the Bukkit files on another HDD shouldn't make a difference. But if we can't figure anything else out, try putting it on the same harddrive as your java directory and running it again. But only do that if we can't come up with another solution.
  30. Offline


    By 'the test' you mean running the .bat via console? Yeah I did that. I did everything you described to him with no change at all.

    So . . . Running the .bat file(containing 'java -Xms512M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar') via double clicking simply opens and immediately closes command prompt.
    I then added java.exe(located 'C:\Program Files (x86)\java\bin\java.exe') to the PATH environments and tried again with the same result.
    Now I tried running via cmd prompt and was given the same error as The Archer('java' is not recognized as an internal or external command, operable program or batch file.)

    Just now I tried running the .bat file via double click and cmd prompt from the same HDD(moved to 'C:\Bukkit\bin') as java is installed with the same result.
    My Bukkit path was ('P:\Phoenix.Games\Minecraft\Bukkit\bin') with the .bat file in the same dir and labeled as ('server.bat') with contents ('java -Xms512M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar').

    Note: I'm using Win7 64-bit, Java is up to date. If that at all matters.

    Unless there's something I'm overlooking everything should work fine. Even without taking the steps you've described. As I said in my last post I run other java apps via .bat file perfectly fine, what would make this any different?

    Cheers for your help pal.
Thread Status:
Not open for further replies.

Share This Page