Class ModuleConfig

java.lang.Object
enterprises.iwakura.modularbot.config.ModuleConfig

public abstract class ModuleConfig extends Object
Module config
  • Constructor Details

    • ModuleConfig

      public ModuleConfig(ModuleInfo moduleInfo, String modulesDirectoryPath)
      Creates new ModuleConfig
      Parameters:
      moduleInfo - Module info
      modulesDirectoryPath - Path to the modules directory, or null to use the default "./modules"
  • Method Details

    • register

      public abstract void register()
      Registers all configs here using the register(Class, String, ConfigSerializer) method
    • register

      public void register(Class<?> clazz, String name, ConfigSerializer configSerializer)
      Registers a config class with the given name and serializer
      Parameters:
      clazz - Class of the config
      name - Name of the config file
      configSerializer - Serializer to use
    • copyResourceConfigs

      public void copyResourceConfigs(ClassLoader classLoader)
      Copies all registered config files from the resources to the module's config directory if they do not exist yet
      Parameters:
      classLoader - ClassLoader to use to load the resources
    • getOrLoad

      public <T> T getOrLoad(Class<T> clazz)
      Gets the config of the given class, or loads it if not loaded yet. If the config file does not exist, it will be created with default values (using the public no-args constructor of the class).
      Type Parameters:
      T - Type of the config
      Parameters:
      clazz - Class of the config
      Returns:
      Instance of the config
    • save

      public void save(Object object)
      Saves the given config object to its corresponding file
      Parameters:
      object - Config object to save