Class Module

All Implemented Interfaces:
ObservableConfig<KamiConfig>, CoreMethods

public abstract class Module extends AbstractSubsystem<ModuleConfig, Module>
This class represents a single module registered under your KamiPlugin plugin.
A module is a toggleable subsystem that acts like its own plugin, providing its own functionality and configuration.
For a subsystem that cannot be toggled or disabled, see Feature.
  • Field Details

  • Constructor Details

    • Module

      public Module()
  • Method Details

    • isEnabledByDefault

      public abstract boolean isEnabledByDefault()
      Returns:
      Whether this module is enabled by default (generally always true, except in specific situations)
    • defaultPrefix

      @NotNull public abstract @NotNull VersionedComponent defaultPrefix()
      Specified by:
      defaultPrefix in class AbstractSubsystem<ModuleConfig, Module>
      Returns:
      The default logging prefix for this subsystem (saved under the KamiPlugin modulesConfig modulePrefix)
    • getConfigFileDestination

      @NotNull public @NotNull File getConfigFileDestination()
      Specified by:
      getConfigFileDestination in class AbstractSubsystem<ModuleConfig, Module>
    • getConfigResourcePath

      @NotNull public @NotNull String getConfigResourcePath()
      The name of the config file (IN SOURCE CODE) for this Module.

      By default, it is fetched as KamiPlugin.getModuleYmlPath()/[name]Module.yml

      You can override this method, or edit KamiPlugin.getModuleYmlPath() to change the path resolution.
      Specified by:
      getConfigResourcePath in class AbstractSubsystem<ModuleConfig, Module>
    • createConfig

      @OverrideOnly @NotNull public @NotNull ModuleConfig createConfig()
      Specified by:
      createConfig in class AbstractSubsystem<ModuleConfig, Module>
    • isEnabledInConfig

      @Internal public final boolean isEnabledInConfig()
    • getSubsystemConfigSection

      @NotNull protected @NotNull String getSubsystemConfigSection()
      Description copied from class: AbstractSubsystem
      The top-level section of the plugin-level config that holds every subsystem of this kind: "modules" for a Module, read out of modules.yml, and "features" for a Feature, read out of features.yml.

      This is deliberately NOT the on-disk folder name from MODULES_FOLDER / FEATURES_FOLDER, even though the words currently match. Those name a directory and this names a config key; tying them together would make renaming the directory silently rename everybody's config keys.
      Specified by:
      getSubsystemConfigSection in class AbstractSubsystem<ModuleConfig, Module>
      Returns:
      the section name, with no trailing dot
    • getModulesConfigKey

      @Internal @NotNull public final @NotNull String getModulesConfigKey()
      The key this module's entries live under in the plugin's modules.yml, for example modules.My_Module.

      An alias of AbstractSubsystem.getSubsystemConfigKey(), kept under its own name because it is public. It builds nothing itself, so it cannot drift from the key features use.
    • getPrefix

      @NotNull public final @NotNull VersionedComponent getPrefix()
      Specified by:
      getPrefix in class AbstractSubsystem<ModuleConfig, Module>
      Returns:
      The prefix for this subsystem, as defined in the subsystem config
    • getModuleDataFolder

      @NotNull public @NotNull File getModuleDataFolder()
      The data folder for this module, located at:
      /home/container/plugins/<plugin>/modules/<module>/

      If the folder does not exist, it will be created automatically.
    • getModuleDataPath

      @NotNull public @NotNull String getModuleDataPath()
      The absolute path to the data folder for this module, i.e.:
      /home/container/plugins/<plugin>/modules/<module>/

      This is just the File's absolute path, it does not create the folder if it does not exist.