About creating an API

Discussion in 'Plugin Development' started by gomeow, Nov 4, 2012.

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

    gomeow

    I am thinking about creating a small api that could take in an item id, return a material name, and vice versa. It would also be able to take in aliases and return any other thing (Material, ID, etc)

    How do I make my methods visible to other plugins?
     
  2. Offline

    cman1885

    The public keyword?
     
    Theway2cool1 likes this.
  3. Offline

    Jogy34

    First off you would be looking for a public static method. Second the Material enum already has built in methods to do that.
     
  4. Offline

    gomeow

    but it doesn't have aliases such as: smoothstone, stone, sstone, etc
     
  5. Offline

    ChrisixStudios

    If you wanna know exactly how to do this you basically just make a plugin and do nothing with the main class (JavaPlugin) but load it. Then you would create your other classes and yes you would use the public keyword. And i don't know what you are using to create your plugins so I wouldn't know how to load your API so you can test it. But you would put the API jar file in the plugins folder.
     
  6. Offline

    gomeow

    Thanks, I think I'll make a small test plugin to test it. It shouldn't be to hard, all it will do is look something up form a file
     
  7. Offline

    ChrisixStudios

    Yea that's pretty easy. If you run into anything just let me know.
     
  8. Offline

    gomeow

    ok, thanks, I will
     
  9. Offline

    ChrisixStudios

    Welcome
     
  10. Offline

    Sagacious_Zed Bukkit Docs

    The proper way to create an API is through registering a service interface with bukkit. Other plugins can then ask bukkit for providers of that service.
     
  11. Offline

    gomeow

    Explain?
     
  12. Offline

    Sagacious_Zed Bukkit Docs

    Bukkit has a service manger. Plugins can register A service interface accompanied by a provider of that service.

    The other plugin can request all providers of a service interface.
     
  13. Offline

    Canownueasy

    Why would clients need to know the provider of the service? That kind of voids the purpose of interfacing...

    Sounds nice; mind linking me to the package that contains this (in the Git repo)?
     
  14. Offline

    Sagacious_Zed Bukkit Docs

    They don't know the implementation, only that the return object implants the interface. But since it is an object you call methods on, it is still an implementing class.

    The Javadoc for the ServicesManager can be found here
     
  15. Offline

    Canownueasy

    That's true but is irrelevant to my question. It's not a matter now because I realized that your statement had a different meaning than what I originally interpreted it to mean; and I have no questions on the new interpretation.

    Thank you for your information about Bukkit's service manager; this is useful to study because I and others can use a similar idea for future libraries we create.
     
Thread Status:
Not open for further replies.

Share This Page