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

    Fields
    Modifier and Type
    Field
    Description
    boolean
    Flag indicating if the plugin is running in test mode.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for CorePlugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.bukkit.configuration.file.FileConfiguration
     
    @NotNull ConfigManager
    Gets the configuration manager for the main config file.
    static org.bukkit.plugin.java.JavaPlugin
    Gets the singleton instance of the plugin.
    static String
    Gets the plugin's console message prefix.
    static Long
    Gets the time when the plugin started loading.
    static boolean
     
    final void
     
    final void
     
    abstract void
    Called when the plugin starts.
    abstract void
    Called when the plugin stops.
    void
    registerCommand(SimpleCommand... simpleCommand)
    Deprecated.
    Use the automatic registration system instead
    protected final void
    Registers component classes (instantiated reflectively via no-arg ctor) with this plugin.
    protected final void
    registerComponents(Object... components)
    Registers component instances directly (listeners, commands, custom items) with this plugin — the fast, explicit path (no classpath scanning).
    void
    Registers a Reloadable component for this plugin.
    void
    Triggers reload on every registered Reloadable (e.g.
    static void
    Sends a message to the console with the plugin prefix.
    static void
    sendConsoleMessage(net.kyori.adventure.text.Component component)
    Sends a message to the console with the plugin prefix.
    static void
    Sends a debug message to the console if debug mode is enabled.
    static void
    sendDebugMessage(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, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode, namespace

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.plugin.Plugin

    getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
  • Field Details

    • isTest

      public boolean isTest
      Flag 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:
      getConfig in interface org.bukkit.plugin.Plugin
      Overrides:
      getConfig in class org.bukkit.plugin.java.JavaPlugin
    • getConfigManager

      @NotNull public @NotNull ConfigManager getConfigManager()
      Gets the configuration manager for the main config file.
      Returns:
      the ConfigManager instance for config.yml
    • isFolia

      public static boolean isFolia()
    • getStartTime

      public static Long getStartTime()
      Gets the time when the plugin started loading.
      Returns:
      the start time in milliseconds
    • getPrefix

      public static String 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 to System.out when 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

      public static void sendConsoleMessage(String message)
      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

      public static void sendDebugMessage(String message)
      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:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • onEnable

      public final void onEnable()
      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
    • registerComponents

      protected final void registerComponents(Object... components)
      Registers component instances directly (listeners, commands, custom items) with this plugin — the fast, explicit path (no classpath scanning). Call from onPluginStart():
      registerComponents(new MyListener(), new MyCommand(), new MyItem());
      
      Parameters:
      components - the component instances to register
    • registerComponentClasses

      protected final void registerComponentClasses(Class<?>... classes)
      Registers component classes (instantiated reflectively via no-arg ctor) with this plugin. Preferred over old @AutoRegister scanning when you want class-level registration without classpath scanning:
      registerComponentClasses(MyListener.class, MyCommand.class);
      
      Parameters:
      classes - the component classes to register
    • registerReloadable

      public void registerReloadable(Reloadable reloadable)
      Registers a Reloadable component for this plugin. The DevTool live config editor calls Reloadable.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 public void registerCommand(SimpleCommand... simpleCommand)
      Deprecated.
      Use the automatic registration system instead
      Registers 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.