Class ZetaCorePlugin

All Implemented Interfaces:
LifecycleEventOwner, CommandExecutor, TabCompleter, TabExecutor, Plugin

public abstract class ZetaCorePlugin extends JavaPlugin
Base class for plugins built on ZetaCore.

On enable, the plugin boots itself. It saves the default config, creates the ConfigService and ServiceRegistry, registers the beans of all Configuration classes and starts eagerly loaded services and beans. It then registers everything found in the plugin's package:

Finally, it starts bStats if ZetaPlugin.bstatsId() is set (charts come from MetricsCustomizers) and runs every UpdateChecker service or bean asynchronously.

Use ZetaPlugin on the main class to change the defaults, and override onStartup() and onShutdown() for custom logic.

The plugin itself, its Logger, the ConfigService, the ServiceRegistry, the ClassScanner and every ConfigFile class can be injected into any service. Injected config objects are updated in place by ConfigService.reload().

  • Constructor Details

    • ZetaCorePlugin

      public ZetaCorePlugin()
  • Method Details

    • onEnable

      public final void onEnable()
      Specified by:
      onEnable in interface Plugin
      Overrides:
      onEnable in class JavaPlugin
    • onDisable

      public final void onDisable()
      Specified by:
      onDisable in interface Plugin
      Overrides:
      onDisable in class JavaPlugin
    • onStartup

      protected void onStartup()
      Called at the end of onEnable(), after everything is set up.
    • onShutdown

      protected void onShutdown()
      Called when the plugin is disabled, before services and beans are destroyed (see PreDestroy). Not called if enabling the plugin failed.
    • getServiceRegistry

      public ServiceRegistry getServiceRegistry()
      Gets the service registry of this plugin. Only available once the plugin is enabled.
      Returns:
      The service registry.
    • getConfigService

      public ConfigService getConfigService()
      Gets the config service of this plugin. Only available once the plugin is enabled.
      Returns:
      The config service.
    • getClassScanner

      public ClassScanner getClassScanner()
      Gets the scanner used to discover this plugin's classes. Only available once the plugin is enabled.
      Returns:
      The class scanner.
    • getPluginFile

      public File getPluginFile()
      Gets the plugin jar file.
      Returns:
      The plugin file.
    • createBStatsMetrics

      public Metrics createBStatsMetrics(int pluginId)
      Creates bStats metrics instance for this plugin.
      Parameters:
      pluginId - The plugin bStats id
      Returns:
      The metrics instance