From 82b1e940370442fc2d05c5fe3e6cfd691b5fb8d9 Mon Sep 17 00:00:00 2001 From: Risto Lahtela Date: Wed, 10 Apr 2019 17:16:48 +0300 Subject: [PATCH] Updated APIv5 (markdown) --- APIv5.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/APIv5.md b/APIv5.md index 2204ca2..7ccbc47 100644 --- a/APIv5.md +++ b/APIv5.md @@ -11,6 +11,68 @@ API module Version | Plan Version -- | -- 0.0.3 | 4.8.0 +## Checking if some part of an API is available + +> This section is about API v0.0.4 which is set for release with 4.8.2 + +
+API module dependency information + +Plan API is distributed via Bintray repository: +``` + + + false + + bintray-rsl1122-Plan-repository + bintray + https://dl.bintray.com/rsl1122/Plan-repository + +``` + +``` + + com.djrapitops + Plan-api + ... + +``` + +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). + +
+ +
+Checking if the API supports a capability + +- `CapabilityService` allows you to ensure that Plan version on the server has all the API capabilities you need available. +- All Plan API related things should be done in it's own class to avoid NoClassDefFoundError if Plan is not installed. Below is an example of a capability check. + +``` +class ClassWhereYouDoAllPlanThings { + + public boolean areAllCapabilitiesAvailable() { + try { + CapabilityService capabilities = CapabilityService.getInstance(); + return capabilities.hasCapability("DATA_EXTENSION_VALUES") && ...; + } catch (NoClassDefFoundError e) { + return false; + } + } + + public void doOtherPlanThings() {...} + +} +``` + +- Capability names can be found in `com.djrapitops.plan.capability.Capability` enum. Please note that this class is package private to avoid direct calls that might lead to NoSuchFieldError. +- The required capabilities are listed in the documentations below. + +
+ ## DataExtension API - [Documentation for DataExtension API](https://github.com/plan-player-analytics/Plan/wiki/APIv5---DataExtension-API)