Class CorePlugin
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
com.github.pinont.singularitylib.plugin.CorePlugin
- All Implemented Interfaces:
io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, net.kyori.adventure.key.Namespaced, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin
- Direct Known Subclasses:
Plugin
public abstract class CorePlugin
extends org.bukkit.plugin.java.JavaPlugin
Abstract base class for plugins using the SingularityLib framework.
This class provides core functionality including configuration management,
command registration, and plugin lifecycle management.
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanFlag indicating if the plugin is running in test mode. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull org.bukkit.configuration.file.FileConfiguration@NotNull ConfigManagerGets the configuration manager for the main config file.static org.bukkit.plugin.java.JavaPluginGets the singleton instance of the plugin.static StringGets the plugin's console message prefix.static LongGets the time when the plugin started loading.static booleanisFolia()final voidfinal voidonEnable()abstract voidCalled when the plugin starts.abstract voidCalled when the plugin stops.voidregisterCommand(SimpleCommand... simpleCommand) Deprecated.Use the automatic registration system insteadprotected final voidregisterComponentClasses(Class<?>... classes) Registers component classes (instantiated reflectively via no-arg ctor) with this plugin.protected final voidregisterComponents(Object... components) Registers component instances directly (listeners, commands, custom items) with this plugin — the fast, explicit path (no classpath scanning).voidregisterReloadable(Reloadable reloadable) Registers a Reloadable component for this plugin.voidTriggers reload on every registered Reloadable (e.g.static voidsendConsoleMessage(String message) Sends a message to the console with the plugin prefix.static voidsendConsoleMessage(net.kyori.adventure.text.Component component) Sends a message to the console with the plugin prefix.static voidsendDebugMessage(String message) Sends a debug message to the console if debug mode is enabled.static voidsendDebugMessage(net.kyori.adventure.text.Component component) Sends a debug message to the console if debug mode is enabled.Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLifecycleManager, getLogger, getPlugin, getPluginLoader, getPluginMeta, getProvidingPlugin, getResource, getServer, getTextResource, init, init, isEnabled, isNaggable, onCommand, onLoad, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode, namespaceMethods inherited from interface org.bukkit.plugin.Plugin
getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
-
Field Details
-
isTest
public boolean isTestFlag indicating if the plugin is running in test mode.
-
-
Constructor Details
-
CorePlugin
public CorePlugin()Default constructor for CorePlugin.
-
-
Method Details
-
getConfig
@NotNull public @NotNull org.bukkit.configuration.file.FileConfiguration getConfig()- Specified by:
getConfigin interfaceorg.bukkit.plugin.Plugin- Overrides:
getConfigin classorg.bukkit.plugin.java.JavaPlugin
-
getConfigManager
Gets the configuration manager for the main config file.- Returns:
- the ConfigManager instance for config.yml
-
isFolia
public static boolean isFolia() -
getStartTime
Gets the time when the plugin started loading.- Returns:
- the start time in milliseconds
-
getPrefix
Gets the plugin's console message prefix.- Returns:
- the formatted prefix string
-
sendConsoleMessage
public static void sendConsoleMessage(net.kyori.adventure.text.Component component) Sends a message to the console with the plugin prefix. Falls back toSystem.outwhen no Bukkit server is running (e.g. during unit tests or very early startup) so logging never NPEs.- Parameters:
component- the message component to send
-
sendConsoleMessage
Sends a message to the console with the plugin prefix.- Parameters:
message- the message to send
-
getInstance
public static org.bukkit.plugin.java.JavaPlugin getInstance()Gets the singleton instance of the plugin.- Returns:
- the plugin instance
- Throws:
IllegalStateException- if the plugin instance cannot be retrieved
-
sendDebugMessage
Sends a debug message to the console if debug mode is enabled.- Parameters:
message- the debug message to send
-
sendDebugMessage
public static void sendDebugMessage(net.kyori.adventure.text.Component component) Sends a debug message to the console if debug mode is enabled. The prefix, DEV tag, and the message are rendered italic (matching the legacy colour-code behaviour where the trailing ITALIC code never reset); the message colour is whatever the supplied component carries.- Parameters:
component- the debug message component to send
-
onDisable
public final void onDisable()- Specified by:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.bukkit.plugin.java.JavaPlugin
-
onEnable
public final void onEnable()- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin
-
registerComponents
Registers component instances directly (listeners, commands, custom items) with this plugin — the fast, explicit path (no classpath scanning). Call fromonPluginStart():registerComponents(new MyListener(), new MyCommand(), new MyItem());- Parameters:
components- the component instances to register
-
registerComponentClasses
Registers component classes (instantiated reflectively via no-arg ctor) with this plugin. Preferred over old@AutoRegisterscanning when you want class-level registration without classpath scanning:registerComponentClasses(MyListener.class, MyCommand.class);- Parameters:
classes- the component classes to register
-
registerReloadable
Registers a Reloadable component for this plugin. The DevTool live config editor callsReloadable.reload()on every registered instance after saving config edits.- Parameters:
reloadable- the component to reload on config changes
-
reloadReloadables
public void reloadReloadables()Triggers reload on every registered Reloadable (e.g. after a live config edit). -
registerCommand
Deprecated.Use the automatic registration system insteadRegisters commands with the plugin.- Parameters:
simpleCommand- the commands to register
-
onPluginStart
public abstract void onPluginStart()Called when the plugin starts. Implement this method to add plugin-specific startup logic. -
onPluginStop
public abstract void onPluginStop()Called when the plugin stops. Implement this method to add plugin-specific shutdown logic.
-