Interface MagstarPlugin


public interface MagstarPlugin
Core interface for all Magstar-based plugins.

A MagstarPlugin defines the lifecycle and metadata contract that each plugin must implement in order to integrate with the Magstar framework.

Responsibilities

  • Provide plugin metadata such as version, update version, identity code, and name.
  • Expose core synchronization and runtime helpers, e.g. via SyncBukkit.
  • Define lifecycle methods: init() for starting and destroy() for shutting down.
  • Allow registration and retrieval of MagstarConfig instances through a ConfigHandler.
  • Offer defaults for configuration lookup and ASCII art banner printing.

Typical Usage


 public class ExamplePlugin extends JavaPlugin implements MagstarPlugin {

     @Override
     public @NotNull PluginVersion getPluginVersion() {
         return PluginVersion.V1_0;
     }

     @Override
     public @NotNull String getUpdateVersion() {
         return "1.0.3";
     }

     @Override
     public @NotNull String getIdentifyCode() {
         return "example-plugin";
     }

     @Override
     public @NotNull SyncBukkit getSyncBukkit() {
         return new SyncBukkit(this);
     }

     @Override
     public @NotNull String getPluginName() {
         return "ExamplePlugin";
     }

     @Override
     public boolean init() {
         registerConfig();
         getLogger().info("Plugin initialized!");
         return true;
     }

     @Override
     public void destroy() {
         getLogger().info("Plugin shutdown!");
     }

     @Override
     public void registerConfig() {
         // register configs here
     }

     @Override
     public @NotNull ExampleConfigHandler getConfigHandler() {
         return new ExampleConfigHandler();
     }
 }
 

The framework provides default implementations for configuration access via getConfig(Class) and for printing an ASCII art banner via getArtCode(String).

Since:
1.0
Author:
Magstar
  • Method Details

    • getPluginVersion

      @NotNull @NotNull PluginVersion getPluginVersion()
      Gets the plugin's declared version.
      Returns:
      plugin version enum
    • getUpdateVersion

      @NotNull @NotNull String getUpdateVersion()
      Gets the plugin's remote update version (e.g. for comparing with latest).
      Returns:
      update version string
    • getIdentifyCode

      @NotNull @NotNull String getIdentifyCode()
      Gets a unique identify code for this plugin (usually unique key or symbolic name).
      Returns:
      unique identity code string
    • getBasePackage

      @NotNull @NotNull String getBasePackage()
    • getSyncBukkit

      @NotNull @NotNull SyncBukkit getSyncBukkit()
      Gets an instance of SyncBukkit for thread synchronization helpers.
      Returns:
      the SyncBukkit instance
    • getPluginName

      @NotNull @NotNull String getPluginName()
      Gets the plugin's human-readable name.
      Returns:
      plugin name string
    • init

      boolean init()
      Called to initialize the plugin and start its services.
      Returns:
      true if initialization succeeded
    • destroy

      void destroy()
      Called when the plugin is being disabled; should clean up resources.
    • registerConfig

      void registerConfig()
      Called to register all configuration files used by this plugin.
    • getConfigHandler

      @NotNull <T extends ConfigHandler> T getConfigHandler()
      Gets the configuration handler associated with this plugin.
      Type Parameters:
      T - type of ConfigHandler
      Returns:
      non-null config handler instance
    • getConfig

      @NotNull default <K extends ConfigHandler> @NotNull org.bukkit.configuration.file.FileConfiguration getConfig(Class<? extends MagstarConfig<?>> clazz)
      Default helper to retrieve a specific MagstarConfig's underlying file configuration.
      Type Parameters:
      K - config handler type
      Parameters:
      clazz - the class of the config to retrieve
      Returns:
      the FileConfiguration backing the given config class
    • getMessages

      default <T extends MessageTemplate<?, ?>, K extends ConfigHandler> T getMessages()
    • getMessages

      default <T extends MessageTemplate<?, ?>> T getMessages(Class<T> clazz)
    • getArtCode

      default String[] getArtCode(String name)
      Default ASCII art banner printer with plugin metadata.
      Parameters:
      name - the plugin name
      Returns:
      array of banner lines
    • enableInputModule

      default void enableInputModule(org.bukkit.plugin.Plugin plugin)
    • enableSchedulerModule

      default void enableSchedulerModule(org.bukkit.plugin.Plugin plugin)
    • enableSchedulerModule

      default void enableSchedulerModule(org.bukkit.plugin.Plugin plugin, String basePack)