Class Dashboard

java.lang.Object
io.prismmc.prism.dashboard.Dashboard

public final class Dashboard extends Object
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
    }
}
  • Method Details

    • version

      public static String version()
      The version of this API the server speaks, as major.minor. A new minor version only adds to the API; a new major version may change what was there.
      Returns:
      the version, 1.0 for 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

      public static Extension extension(Plugin plugin)
      The extension of a plugin: made at the first call, the same one after. Call it from onEnable; 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

      public static void provide(Dashboard.Provider provider)
      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