-
-
Notifications
You must be signed in to change notification settings - Fork 169
APIv5
Welcome to using Plan API v5.
Plan API is distributed via Jitpack
<repository>
<id>jitpack</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.plan-player-analytics</groupId>
<artifactId>Plan</artifactId>
<version>{jitpack tag}</version>
<scope>provided</scope>
</dependency>
- See latest version number from https://github.com/plan-player-analytics/Plan/tags
- It is best to place jitpack as the last repository if you have multiple.
- Remember to add
"Plan"
as a softdependency to your plugin information (plugin.yml / Plugin annotation).
💡 All Plan API related things should be done in it's own class to avoid NoClassDefFoundError if Plan is not installed.
- DataExtension API
- Query API
- PageExtension API
- Checking that needed capabilities of the API are available
- Listening for Plan reloads
DataExtension API is for adding data of plugins to Plan. The provided data is placed in Plan database, so that it can be accessed on servers in the network. The values are displayed on the web panel, and so server admins get a more complete picture of what is going on their server. In addition basic calculations are performed on the provided values, such as totals, averages and percentages.
Query API is for performing SQL queries and statements on the Plan database. The API is intended for those who want to store data of their plugins for DataExtension API in the Plan database (in case they don't have their own storage) or want to use Plan data.
- Documentation for PageExtension API
- Since: 5.1 build 474
PageExtension API is for adding more content to the Plan website. The API is intended for those who want to add new pages or expand the amount of information available on the website.
CapabilityService#hasCapability(String)
allows you to ensure that Plan version on the server has all the API capabilities you need.
Example usage
class ClassWhereYouDoAllPlanThings {
public boolean areAllCapabilitiesAvailable() {
try {
CapabilityService capabilities = CapabilityService.getInstance();
return capabilities.hasCapability("DATA_EXTENSION_VALUES") && ...;
} catch (NoClassDefFoundError e) {
return false;
}
}
public void doOtherPlanThings() {...}
}
If something requires a Capability, it is mentioned in the documentation on this wiki like this:
Requires
DATA_EXTENSION_TABLES
capability
Capability names can be found in api/com.djrapitops.plan.capability.Capability
enum. (Please note that this class is package private to avoid direct calls that might lead to NoSuchFieldError.)
CapabilityService#registerEnableListener(Consumer<Boolean>)
can be used to be notified via a callback when Plan reloads.
Example usage
CapabilityService.getInstance().registerEnableListener(
isPlanEnabled -> {
if (isPlanEnabled) // Register DataExtension again
}
)