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 anddestroy()for shutting down. - Allow registration and retrieval of
MagstarConfiginstances through aConfigHandler. - 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 Summary
Modifier and TypeMethodDescriptionvoiddestroy()Called when the plugin is being disabled; should clean up resources.default voidenableInputModule(org.bukkit.plugin.Plugin plugin) default voidenableSchedulerModule(org.bukkit.plugin.Plugin plugin) default voidenableSchedulerModule(org.bukkit.plugin.Plugin plugin, String basePack) default String[]getArtCode(String name) Default ASCII art banner printer with plugin metadata.@NotNull Stringdefault <K extends ConfigHandler>
@NotNull org.bukkit.configuration.file.FileConfigurationgetConfig(Class<? extends MagstarConfig<?>> clazz) Default helper to retrieve a specificMagstarConfig's underlying file configuration.<T extends ConfigHandler>
TGets the configuration handler associated with this plugin.@NotNull StringGets a unique identify code for this plugin (usually unique key or symbolic name).default <T extends MessageTemplate<?,?>, K extends ConfigHandler>
Tdefault <T extends MessageTemplate<?,?>>
TgetMessages(Class<T> clazz) @NotNull StringGets the plugin's human-readable name.@NotNull PluginVersionGets the plugin's declared version.@NotNull SyncBukkitGets an instance ofSyncBukkitfor thread synchronization helpers.@NotNull StringGets the plugin's remote update version (e.g. for comparing with latest).booleaninit()Called to initialize the plugin and start its services.voidCalled to register all configuration files used by this plugin.
-
Method Details
-
getPluginVersion
Gets the plugin's declared version.- Returns:
- plugin version enum
-
getUpdateVersion
Gets the plugin's remote update version (e.g. for comparing with latest).- Returns:
- update version string
-
getIdentifyCode
Gets a unique identify code for this plugin (usually unique key or symbolic name).- Returns:
- unique identity code string
-
getBasePackage
-
getSyncBukkit
Gets an instance ofSyncBukkitfor thread synchronization helpers.- Returns:
- the
SyncBukkitinstance
-
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
Gets the configuration handler associated with this plugin.- Type Parameters:
T- type ofConfigHandler- 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 specificMagstarConfig's underlying file configuration.- Type Parameters:
K- config handler type- Parameters:
clazz- the class of the config to retrieve- Returns:
- the
FileConfigurationbacking the given config class
-
getMessages
-
getMessages
-
getArtCode
-
enableInputModule
default void enableInputModule(org.bukkit.plugin.Plugin plugin) -
enableSchedulerModule
default void enableSchedulerModule(org.bukkit.plugin.Plugin plugin) -
enableSchedulerModule
-