learning to use Bukkit API

Discussion in 'Plugin Development' started by eamike261, Feb 21, 2011.

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

    eamike261

    I have a bit of experience with java and eclipse so I know how to program, but how would I go about learning all the specifics of the API? I watched the Basic tutorial, which was helpful. But say I want to get the block that the crosshair was pointing to....how would I figure out the class and function for that? Is there a resource database or something that I can use?
     
  2. Offline

    Edward Hand

    The best way when you're just getting started is to look at other people's examples. A lot of developers include their source code along with their plugin releases.

    As for finding functions, I would assume most people use either github or the javadoc:
    https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit
    http://javadoc.lukegb.com/BukkitAPI/

    Just to guide you through finding the function you mentioned, first open the github link. You'll see that the classes are in nice subfolders.
    A quick skim read and the only folder thats likely to contain the function is entity (entities can look at things).
    Open that folder. If they implemented it for any entity, then surely it would be players. Go to the 'Player' class.
    Can't see it in that class, but we have to check the class it extends too (Human Entity)
    Not in human entity, but HumanEntity extends LivingEntity so check there next.
    In living entity we see:
    Code:
      public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance);
    Which looks promising

    Although, if you had some idea of what the function might be called, you can search the javadoc and it will tell you if any where it exists.

    Hope that helps
     
  3. Offline

    eamike261

    Yes that was extremely helpful! Thank you very much!
     
  4. Offline

    Nohup

    I guess it depends on how experienced you are... I just went through this process and the Javadocs are obviously a great resource to learn what Bukkit has to offer. I needed to go deeper to get an understanding of an issue I was having, so I also dug in the source repository for CraftBukkit to see how events were generating and how the resultant changes were used.
     
Thread Status:
Not open for further replies.

Share This Page