Can't seem to compile, Bukkit dependency on simple plugin edit

Discussion in 'Plugin Development' started by Pr4w, Apr 22, 2011.

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

    Pr4w

    Hey :)

    I'm pretty handy with PHP and other forms of code, and I can understand most of the scripts I use, so I thougt I'd have a try at editing one of them to suit my needs better.
    I'm trying to edit Essentials.jar, so I can change how the /msg function appears, apparently not difficult, I managed to decompile it to /Essentials.src/, find the Commandmsg.java, edit it so it looked and worked better for what I needed it to do.
    The problem is, I can't re-compile it.

    I've read the Bukkit Wiki on Eclipse, so I tried creating a new project EssentialsEdited, adding Bukkit to the build path libraries as an external jar, and importing the decompiled /Essentials.src/ into the workspace, but every time I try to compile, I get lots of errors saying that certain classes and functions don't exist.
    Here's a screenshot of my workspace on Eclipse : http://puu.sh/1Gpf
    And some of the errors : http://puu.sh/1Gph
    I see this as the dependencies not being set correctly, ie my edited plugin can't fetch some of the info it needs from the Bukkit Snapshot, and as such, I can't compile it to test out the changes I made.

    I tried opening up Essentials.jar with WinRar, extraction Commandmsg.class, decompiling it and editing it, but I can't recompile it either, as there are Bukkit dependencies, and dependencies to other stuff within Essentials, so it refuses to compile...

    I'm only trying to do minor changes, nothing too big. Could anyone help me with this ?
    Is it not possible to compile Java without error verification, ie forcing it to compile even if some of the dependencies are missing ?
    If not, what am I doing wrong, and why can't I compile?
    It's frustrating as tools like JD allow me to see the source in a .Jar, so I can open up Essentials.Jar, find exactly what I want to edit, but I can't modify anything...

    Thanks a lot for any help, I'm really new at Java :)
    Mark
     
  2. Offline

    matter123

    try adding craftbukkit(n9t bukkit) to you build path as well
     
  3. Offline

    Pr4w

    I'm still getting all the errors, like before.
    Do I need to decompile bukkit to use it?
    Edit : Tried decompiling it, adding it as a referenced library, and stuff, still doesn't work :/
     
  4. Offline

    matter123

    show me your build path
     
  5. Offline

    Pr4w

  6. Offline

    1337

    Just go to the bin folder, get the edited .class file into essentials so it replaces the oldone
     
  7. Offline

    Pr4w

    I'd like to, but the Commandmsg.class in /bin/ is this at the moment :
    Code:
    package EssentialsvPr4w.com.earth2me.essentials.commands;
    
    public class Commandmsg extends EssentialsCommand
    {
      public String[] getTriggers()
      {
        throw new Error("Unresolved compilation problem: \n");
      }
    }
     
  8. Offline

    matter123

    get a better decompiler
     
  9. Offline

    Pr4w

    Which one should I use?
     
  10. Offline

    matter123

    i use jd_gui
     
  11. Offline

    Pr4w

    That's what I used too...

    Right, well I'll start from scratch, and post what I did, you tell me if it's right, and if not, what I'm doing wrong. :)

    - Opened up Essentials.Jar
    - File, save all sources, to Essentials.src.zip
    - Unzip it

    So far, shouldn't be any problem.
    Loaded up Eclipse, File > New Java Project
    New project, EssentialsByPr4w
    Right-click, Build Path, added bukkit-0.0.1-SNAPSHOT.jar to the libraries, as an external .jar.
    Bukkit is now in the "Referenced libraries".
    Added the contents of Essentials.src to the /src/ of my project, in Eclipse.
    Found Commandmsg.class, edited it.
    Project -> Build All
    Starts building, and now I get all those errors again.
    If I go to my project directory and open up Commandmsg.class, I get :
    Code:
    package Essentials.source.com.earth2me.essentials.commands;
    
    public class Commandmsg extends EssentialsCommand
    {
      public String[] getTriggers()
      {
        throw new Error("Unresolved compilation problem: \n");
      }
    }
    Again :/

    Could you guide me through what I need to do?
     
  12. Offline

    Carnes

    I would try to compile bukkit and craftbukkit first. I'm still very new to java and eclipse (i'm a php guy too). But if you can get git to fetch the source and maven to clean & install bukkit and craftbukkit.. that's most of the battle.

    After that you right-click your project->build path->configure build path. Then click "add external jars". Select the two bukkit and craftbukkit jars. Should be something like YourEclipseWorkspace/.m2/org/blahblahblah/bukkit-0.0.1-SNAPSHOT.jar

    I usually copy the bukkit and CB jars to another directory, so they can't be overwritten by a new version pulled from git.
    ref_libs.jpg
     
  13. Offline

    Xaw4

    You decompiled it? im not sure if you are aware of the fact that Essentials is OpenSource.
    so you just broke in a House that was allready open... ;)

    i'd say your main problem is this. at
    http://java.net/projects/essentials/sources/svn/show
    you can get all of the code, and so no classes are missing ;)
     
  14. Offline

    Pr4w

    @Carnes I'll have a go later on :)

    I did have a look, but I don't know which one to download, so many different builds and folders :confused:
    I actually ended up going with CommandBook, a little easier to work with GitHub, and managed to edit and build it correctly with ANT. (A pain in the arse though, why does Java need to be compiled? Feels like a waste of time)
     
  15. Offline

    matter123

    well if java was just interpreted it would be turtle slow for instance a interpreted program took 96 seconds to run on my computer a compiled C++ that does the same thing twice took 114ms
     
Thread Status:
Not open for further replies.

Share This Page