Class Dashboard
java.lang.Object
io.prismmc.prism.dashboard.Dashboard
Prism's web dashboard, as plugins see it: where a plugin gets its
Extension.
These classes come with the Prism server; a plugin builds against them (compileOnly)
and never ships them. A plugin that also runs on other servers checks first, and keeps the code
that uses this API in a class of its own, which the JVM then never loads elsewhere:
private static boolean onPrism() {
try {
Class.forName("io.prismmc.prism.dashboard.Dashboard");
return true;
} catch (ClassNotFoundException elsewhere) {
return false;
}
}
public void onEnable() {
if (onPrism()) {
ShopDashboard.register(this); // the only class that touches io.prismmc.prism.dashboard
}
}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanWhether the server provides the dashboard's API.static booleanenabled()Whether the dashboard is switched on in the server's configuration.static ExtensionThe extension of a plugin: made at the first call, the same one after.static voidprovide(Dashboard.Provider provider) Prism's side of the API.static Stringversion()The version of this API the server speaks, asmajor.minor.
-
Method Details
-
version
The version of this API the server speaks, asmajor.minor. A new minor version only adds to the API; a new major version may change what was there.- Returns:
- the version,
1.0for now
-
available
public static boolean available()Whether the server provides the dashboard's API. Always true on Prism, where these classes come from; false only when a plugin shipped its own copy of them by mistake.- Returns:
- whether
extension(Plugin)works
-
enabled
public static boolean enabled()Whether the dashboard is switched on in the server's configuration. An extension can be registered either way: it shows as soon as the dashboard is switched on.- Returns:
- whether the dashboard answers
-
extension
The extension of a plugin: made at the first call, the same one after. Call it fromonEnable; the extension goes away by itself when the plugin is disabled.- Parameters:
plugin- the plugin, enabled- Returns:
- its extension
- Throws:
IllegalStateException- when the server does not provide the API, or the plugin is not enabled
-
provide
Prism's side of the API. The server sets it once, while it starts, before any plugin loads.- Parameters:
provider- what answers the calls above- Throws:
IllegalStateException- when it is set already
-