Decompile, change and compile a classfile in craftbukkit.jar

Discussion in 'Plugin Development' started by sds, Jan 29, 2012.

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

    sds

    Hey, for one of my plugins I need to take a file from craftbukkit.jar (net.minecraft.server.PlayerListBox) decompile so that I can watch source. Then I must change something in that file and after that I must recompile it and replace the old file in craftbukkit.jar with the new one. Does anyone know how I can do that? I really need it!

    Thx, sds
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    sds
    have you tried checking out the source code?
     
  3. Offline

    sds

    That's one problem... some files in net.minecraft.server have sourcecodes like Slot.class or Enchantment.class but PlayerListBox don't have. So I must take it out of craftbukkit.jar and decompile it with an external program to see the source code of it. But how can I compile that file and put it into craftbukkit.jar then?
     
  4. Offline

    coldandtired

  5. Offline

    sds

    Yes, that's not the problem. I have the source but I don't know how to compile it then as a single .java file.
     
  6. Offline

    masteroftime

    1. Download the source from github
    2. Download and install maven
    3. Change the file you want to change
    4. Open a command line in the root folder of the craft bukkit source and type mvn package
     
  7. Offline

    sds

    I'm very sorry, but how to install it? I unzipped it and put it to C:/Program Files/Apache Maven
    But when I try do do mvn in command line, it says unknown command...
     
  8. Offline

    masteroftime

    you have to add it to the path. On windows type set PATH=%PATH%;<path-to-maven>

    where path to maven is the folder where mvn.bat is in. You have to issue this command every time you open up a new command promt. You can also permanently add it somewhere in the control panel but I don't know exactly where.
     
  9. Offline

    bergerkiller

    sds you can find the source for the other files on the MC-dev github page.

    I recommend you keep a local copy of all the source files. First download the files from MC-dev, then copy and overwrite (replace) the craftbukkit ones. This way you always have all source files. Having the source locally is also useful when MC-dev goes down for the umpteenth time.
     
  10. Offline

    sds

    Ok, Maven is installed and I will try it out now...

    bergerkiller ok I downloaded it...

    masteroftime it doesn't work. I used JD Java Decompiler to get the source code. Then I put all the files to a separate folder, opened command line in that folder and typed in "mvn package". What's wrong?

    Here's a screenshot of the folder:
    http://dl.dropbox.com/u/34259573/do_not_delete/craftbukkit_source_01.jpg

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

    bergerkiller

    sds if you want to compile, you will probably have to compile everything at once. I haven't done it for CraftBukkit before, but it might be tricky. Someone else will have to guide you through, since I ended up with lots of errors :)
     
  12. Offline

    sds

    Is there no way to import craftbukkit as a new project in eclipse, change the file and compile it? Would be so easy... :-/
     
  13. Offline

    Sagacious_Zed Bukkit Docs

    sds
    you should be able to clone the git repository, then import it as a maven project in eclipse. There is a way to do it with egit, so it even tracks revision status.
     
  14. Offline

    nisovin

    If you have that one file in an Eclipse project with CraftBukkit in the build path, the class file will be automatically compiled and placed in the bin folder in your project's folder. You can then drop that class file back into the jar to replace the old one.
     
  15. To compile a classfile:

    Open commandline, if you have configured java you can type:
    Code:
    javac "D:/works/projectname/src/net/where/ever/your/class/is/MyChangedClass.java"
    and your done.
    The classfile is in the same folder, you can now open the jar with winrar or something else, an replace the file with drag and drop.
     
  16. Offline

    sds

    @wootklumpWn: It doesn't work. I navigated to the Java folder and typed in javac "C:/.../net/minecraft/server/PlayerListBox.java", but it didn't work so I typed in javac -sourcepath "C:/.../net/minecraft/server/PlayerListBox.java" but then it said: "javac: no source files"

    nisovin: I don't really understand... I made a new project with the craftbukkit.jar in buildpath. Then I added a new .class file in src.(default package) named PlayerListBox and wrote in the sourcecode of PlayerListBox.java: http://dl.dropbox.com/u/34259573/do_not_delete/eclipse_01.jpg

    Sagacious_Zed: OK, I installed TortoiseGit and Git, but how to import it then as a maven project in eclipse (and how to install eGit)?

    sds :)
     
  17. Offline

    Sagacious_Zed Bukkit Docs

    sds
    once you have a copy of the source, you can go to import project and import as a maven project.
     
  18. Offline

    sds

  19. Offline

    Sagacious_Zed Bukkit Docs

    sds
    which version of eclipse are you running?
    Eclipse Indigo IDE for Java Developers should have maven installed by default.
     
  20. Offline

    sds

    Yes I have Indigo...
     
  21. Offline

    masteroftime

  22. Offline

    sds

    Code:
    C:\Users\Timo>mvn package "C:/Users/Timo/Desktop/cb"
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'C'.
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] The plugin 'org.apache.maven.plugins:maven-C-plugin' does not exist or no
    valid version could be found
    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: < 1 second
    [INFO] Finished at: Mon Jan 30 15:54:10 CET 2012
    [INFO] Final Memory: 4M/61M
    [INFO] ------------------------------------------------------------------------
    OK... but whaat?
    [INFO] The plugin 'org.apache.maven.plugins:maven-C-plugin' does not exist or no
    valid version could be found
    :eek:

    EDIT: I will re-install Eclipse... I hope maven is included.

    It seems to work :O
    Oh my god!

    Hmm lol, "some" files are missing!?
    Eclipse: 168 files in net.minecraft.server (http://dl.dropbox.com/u/34259573/do_not_delete/eclipse_03.jpg)
    7Zip: 663 files in net.minecraft.server (http://dl.dropbox.com/u/34259573/do_not_delete/7zip_01.jpg)

    Is the source not complete?! :O

    My PlayerListBox file is not here too :(


    Please, try it out everybody and if it works, tell me what you did! I don't know what I could do more... >.<

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

    Sagacious_Zed Bukkit Docs

    sds
    I currently have a clone of the Craftbukkit and Bukkit repositories, and I have them imported to Eclipse. and the source does compile. make sure you import it as a maven project, if it is not installed you will have to install the m2eclipse plugin manually.
     
  24. Offline

    fish2ism

    Use fern flower to decompile the craftbukkit.jar file to get its source.
    (I Know This Post Is Old But For All The Pople Wondering)
     
Thread Status:
Not open for further replies.

Share This Page