This simple API allows you to manage API-dependencies of your plugins.
You only have to add
2 lines of code to include an API, you can then include the
API source code in your plugin file.
This Manager is primarily made for APIs which have to
register events to function, so they usually would have to be installed as separate plugins.
How-To
If you are making a Plugin with dependencies:
- Make sure the API you depend on supports APIManager
- In your plugin's onLoad method call APIManager#require with the API class you require and your plugin instance
- In the onEnable method call APIManager#initAPI with the required API class
- Add the plugin name of the required API to softdepend in your plugin.yml
- You successfully added an API dependency! (Repeat steps 2-4 for all APIs your plugin depends on.)
- Finally just compile all of the required API classes with your plugin. Maven is the easiest way to do so.
> Example Plugin class
If you are making an API (with dependencies):
- Create your API class an implement API
- Also implement Listener here if your API has to register events
- If your API has dependencies as well:
- In the load method call APIManager#require with the API class and null as the plugin instance
- in the init method call APIManager#initAPI with the required API class
- Add the plugin name of the required API to softdepend in your plugin.yml
- (Repeat steps 2.1-2.3 for all APIs your API depends on)
- In the init method call APIManager#registerEvents with your API instance (i.e. this) and the Listener to register
- If you need an enabled Plugin instance anywhere else (e.g. to run Schedulers) you can use the plugin variable in init or disable, or just call APIManager#getAPIHost with your API instance
- Finally just compile all of your API classes and required API classes with your plugin. Maven is the easiest way to do so.
- You should also add information on how to implement your API with APIManager to your documentation (i.e. which class to require & init)
> Example API class
> Example Plugin class
Maven
Code (XML):
<repository>
<id>inventive-repo
</id>
<url>https://repo.inventivetalent.org/content/groups/public/
</url>
</repository>
...
<dependency>
<groupId>org.inventivetalent
</groupId>
<artifactId>apimanager
</artifactId>
<version>1.0.1
</version>
</dependency>
Links