Skip to content
Risto Lahtela edited this page May 10, 2019 · 50 revisions

Plan Header

Plan API version 5

Welcome to using Plan API v5.

API module dependency information

Plan API is distributed via Bintray repository:

<repository>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
    <id>bintray-rsl1122-Plan-repository</id>
    <name>bintray</name>
    <url>https://dl.bintray.com/rsl1122/Plan-repository</url>
</repository>
<dependency>
    <groupId>com.djrapitops</groupId>
    <artifactId>Plan-api</artifactId>
    <version>...</version>
</dependency>

Dependency version information can be found here: https://bintray.com/rsl1122/Plan-repository/Plan-API

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.

Checking that needed capabilities of the API are available

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-module/com.djrapitops.plan.capability.Capability enum. (Please note that this class is package private to avoid direct calls that might lead to NoSuchFieldError.)

Listening for Plan reloads

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
    }
)

DataExtension API

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.

APIv4

Older API is still available on the plugin, although it requires manual installation of the full plugin as dependency.

Deprecation Warning
Plan API will be deprecated in the near future. While it will still be available, its functionality will be routed to the new APIs when it becomes possible.
The old API has not been stable in the past, and stability of the old API can not be guaranteed in the future, hence the deprecation. PluginData API is eventually to be replaced by the DataExtension API, so it is not recommended to implement new things using the old API

Clone this wiki locally