Making an API?

Discussion in 'Spigot Plugin Development' started by C_y, Jun 14, 2016.

  1. C_y

    C_y

    Hi! As the title states, I'd like to know how to make an API. I'm not really sure what it requires - is there anything needed other than just putting the method into the API and having the user import it?
     
  2. All you need to do is make the methods public then the user can import the .jar as a library to their project and use your methods. Nothing special required.
     
  3. At a very basic level it is what you said. There is not much to it, it just depends how advanced/complicated you want to make it. If you are making an API to be given out to other people, there are just a few things you should do:
    1) Make sure to document everything. It can be annoying for programmers if they don't know what something does.
    2) Have a good understanding of interfaces/abstract classes and when to use them.
    3) Make sure your API forces good programming habits.
    4) It should be intuitive. This can be hard to accomplish, but it basically means all methods can be accessed from where makes the most sense.
     
  4. github.io is a great place for JavaDocs.
    Make one.

    Make a big easy API class with all the things you'll need to change. E.g. set something in your config, or add a combat tagged player or whatever.
    Make it easy. Make it useful.