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

    Oslarathos



    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:
    Code:
    name: < Your plugin's name >
    main: < the full name of the class that extends JavaPlugin >
    version: < plugin version >
    
    The sample plugin would consist of:

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

    Raphfrk

    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

    Oslarathos


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

    Raphfrk

    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

    thegleek

    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:

    Code:
    Jan 5, 2011 8:46:44 AM org.bukkit.plugin.SimplePluginManager loadPlugins
    SEVERE: Could not load plugins\bukkit.jar in plugins
    org.bukkit.plugin.InvalidPluginException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:56)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:112)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:80)
            at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:34)
            at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:31)
            at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:98)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:162)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
            ... 8 more
     
  6. Offline

    Killie01

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

    EvilSeph Retired Staff

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

    AnonymousJohn

    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

    Dafishies

    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

    matejdro

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

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

    AnonymousJohn

    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

    TheArcher

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

    AnonymousJohn

    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

    TheArcher

    "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:

    [​IMG]
     
  15. Offline

    croxis

  16. Offline

    TheArcher

    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

    AnonymousJohn

    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

    TheArcher

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

    [​IMG]

    To clarify, I have Java installed.
     
  19. Offline

    AnonymousJohn

    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

    TheArcher

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

    AnonymousJohn

    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

    ScytheX10

    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

    feverdream

    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?
    java.io.FileNotFoundException: 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

    AnonymousJohn

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

    ScytheX10

    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
    Code:
    sudo apt-get install git
    
    sudo apt-get install maven2
    
    cd
    
    mkdir bukkit
    
    mkdir craftbukkit
    
    cd bukkit
    
    (run as root in non-sudo environments)
    
    sudo git init
    
    sudo git pull git://github.com/Bukkit/Bukkit
    
    sudo mvn clean install
    
    cd ..
    
    cd craftbukkit
    
    sudo git init
    
    sudo git pull git://github.com/Bukkit/CraftBukkit
    
    sudo mvn clean package
    Both compiles will be in target directory.
     
  26. Offline

    hansudo

    In the File EntityCombustEvent.java I get Errors.

    Code:
    Description    Resource    Path    Location    Type
    The method isCancelled() of type EntityCombustEvent must override a superclass method    EntityCombustEvent.java    /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:

    Code:
    11.01.2011 10:37:57 org.bukkit.plugin.SimplePluginManager loadPlugins
    SCHWERWIEGEND: Could not load plugins\SamplePlugin.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:77)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:115)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:80)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:37)
            at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:140)
            at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:127)
            at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:103)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:164)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.lang.ClassNotFoundException: com.hans.bukkit.sample.SamplePlugin
    
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.net.FactoryURLClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:71)
            ... 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

    Kekec852

    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

    D00M.7RA1N

    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

    AnonymousJohn

    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

    D00M.7RA1N

    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