[LIBRARY] ServiceCommons -- A common list of services for your plugin to use

#ServiceCommons – a compilation of common services for your plugin to use

##What is this?
ServiceCommons is a library of commonly used services made accessible by services. It is made to globalize common cases that require some form of management by a “manager,” and release the load on server resources.

##How do I use it?
ServiceCommons can be used without installing the plugin into the server. In fact, its not even a plugin at all! Simply include the jar with your plugin jar and start using its services.

ServiceCommons requires you to tell it to register the service you need using ServiceCommons.registerService(). After telling it to register the service you want, you can access the service using Sponge’s ServiceManager, providing the class of the service as the argument.

##FAQ
###Potential Problems – What if multiple plugins try to use the service?
Nope! ServiceCommons will try to check if the service already exists. If it does, it won’t do anything at all. You still need to tell ServiceCommons to register your service, though; Sponge won’t do it on its own!

###Potential Problems – What if a plugin uses an out-of-date version of the library?
Each service in ServiceCommons is versioned. If another plugin is using an out of date version of the library, a plugin with the newer version will tell the service manager to replace the service with the newer version. Contributors, and myself, will try very hard to make sure nothing breaks between versions; so don’t worry about having to update your methods!

###How do I get a service I need onto the library?
Make a pull request or an issue on the GitHub repository. Either I or someone else will take up the job of implementing it. Implementors, please be wary of the contribution guidelines in the repo; it is NOT just code style.

###Why didn’t you put this topic in the WIP Plugins section?
Technically, this library won’t ever be complete. People’ll be coming up with new ideas for services, thus adding to the library over time.

##Links n’ stuff!
GitHubs ;w;

##Be aware that this library is still under development. Do not expect it to be filled with features, or be completely functional.

2 Likes

A few suggestions:

  • Add interfaces for your services so that other plugins can replace them
  • Create a fake plugin container so that your library does not need a plugin instance to register a service

yeah, gonna need to turn them into interfaces; i plan to add other things like the Economy service that probably can be preferably replaced by alternate implementation

as for the plugin container, i have yet to see what sponge does besides store the plugin container; i’m not sure if its used for anything else. though, in any case it might be a good idea to do it anyway since i don’t need the source plugin to be a plugin using the library.