Class CraftyCore

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
dev.crafty.core.CraftyCore
All Implemented Interfaces:
io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin

public final class CraftyCore extends org.bukkit.plugin.java.JavaPlugin
Main class for the CraftyCore plugin. This plugin provides a comprehensive configuration library for Spigot plugins.
Since:
1.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static CraftyCore
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the data folder path for the plugin.
    void
    Called when the configuration is reloaded.
    void
     
    void
     
    void
    registerConfig(org.bukkit.plugin.Plugin plugin, Object configObject)
    Register a configuration object with CraftyCore.
    void
    Reload all registered configuration objects for all plugins.
    void
     
    boolean
    reloadConfigs(String pluginName)
    Reload all registered configuration objects for a plugin.
    void
    saveResource(String resourcePath, boolean replace)
    Save a resource from the plugin's jar file to the plugin's data folder.
    int
    scanAndLoadConfigs(org.bukkit.plugin.Plugin plugin)
    Scan a plugin for classes with the @ConfigurationFile annotation and automatically register and load them.
    int
    scanAndReloadConfigs(org.bukkit.plugin.Plugin plugin)
    Scan a plugin for configuration classes and reload all of them.
    void
    setConfigWatcherEnabled(boolean enabled)
    Enable or disable the automatic configuration watcher.
    void
    unregisterConfigs(org.bukkit.plugin.Plugin plugin)
    Unregister all configuration objects for a plugin.

    Methods inherited from class org.bukkit.plugin.java.JavaPlugin

    getClassLoader, getCommand, getConfig, 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, saveConfig, saveDefaultConfig, setEnabled, setNaggable, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.bukkit.plugin.Plugin

    getComponentLogger, getLog4JLogger, getSLF4JLogger
  • Field Details

  • Constructor Details

    • CraftyCore

      public CraftyCore()
  • Method Details

    • onEnable

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

      public void reloadConfig()
      Specified by:
      reloadConfig in interface org.bukkit.plugin.Plugin
      Overrides:
      reloadConfig in class org.bukkit.plugin.java.JavaPlugin
    • scanAndLoadConfigs

      public int scanAndLoadConfigs(org.bukkit.plugin.Plugin plugin)
      Scan a plugin for classes with the @ConfigurationFile annotation and automatically register and load them. This method uses reflection to find and instantiate configuration classes.
      Parameters:
      plugin - The plugin to scan for configuration classes
      Returns:
      The number of configuration classes found and registered
    • scanAndReloadConfigs

      public int scanAndReloadConfigs(org.bukkit.plugin.Plugin plugin)
      Scan a plugin for configuration classes and reload all of them. This method first scans for classes with the @ConfigurationFile annotation, then reloads all registered configurations for the plugin.
      Parameters:
      plugin - The plugin to scan and reload configurations for
      Returns:
      The total number of configurations reloaded
    • onDisable

      public void onDisable()
      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • setConfigWatcherEnabled

      public void setConfigWatcherEnabled(boolean enabled)
      Enable or disable the automatic configuration watcher. The configuration watcher monitors changes to the config.yml file and automatically reloads the configuration when changes are detected.
      Parameters:
      enabled - True to enable the watcher, false to disable
    • onConfigReloaded

      public void onConfigReloaded()
      Called when the configuration is reloaded. This method reloads all registered configurations and can be overridden by subclasses to handle additional configuration changes.
    • registerConfig

      public void registerConfig(org.bukkit.plugin.Plugin plugin, Object configObject)
      Register a configuration object with CraftyCore.
      Parameters:
      plugin - The plugin that owns the configuration object
      configObject - The configuration object to register
    • unregisterConfigs

      public void unregisterConfigs(org.bukkit.plugin.Plugin plugin)
      Unregister all configuration objects for a plugin.
      Parameters:
      plugin - The plugin to unregister configurations for
    • reloadConfigs

      public boolean reloadConfigs(String pluginName)
      Reload all registered configuration objects for a plugin. This method will also scan for new configuration classes.
      Parameters:
      pluginName - The name of the plugin to reload configurations for
      Returns:
      True if configurations were reloaded, false if no configurations were found
    • reloadAllConfigs

      public void reloadAllConfigs()
      Reload all registered configuration objects for all plugins. This method will also scan for new configuration classes in all plugins.
    • getDataPath

      public Path getDataPath()
      Get the data folder path for the plugin. This is used by other classes to access the plugin's data folder.
      Returns:
      The data folder path
    • saveResource

      public void saveResource(String resourcePath, boolean replace)
      Save a resource from the plugin's jar file to the plugin's data folder. This is a convenience method that wraps the JavaPlugin.saveResource method.
      Specified by:
      saveResource in interface org.bukkit.plugin.Plugin
      Overrides:
      saveResource in class org.bukkit.plugin.java.JavaPlugin
      Parameters:
      resourcePath - The path to the resource in the jar file
      replace - Whether to replace the file if it already exists