Class ModuleConfig
java.lang.Object
enterprises.iwakura.modularbot.config.ModuleConfig
Module config
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContains information about a registered config -
Constructor Summary
ConstructorsConstructorDescriptionModuleConfig(ModuleInfo moduleInfo, String modulesDirectoryPath) Creates newModuleConfig -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyResourceConfigs(ClassLoader classLoader) Copies all registered config files from the resources to the module's config directory if they do not exist yet<T> TGets the config of the given class, or loads it if not loaded yet.abstract voidregister()Registers all configs here using theregister(Class, String, ConfigSerializer)methodvoidregister(Class<?> clazz, String name, ConfigSerializer configSerializer) Registers a config class with the given name and serializervoidSaves the given config object to its corresponding file
-
Constructor Details
-
ModuleConfig
Creates newModuleConfig- Parameters:
moduleInfo- Module infomodulesDirectoryPath- Path to the modules directory, or null to use the default "./modules"
-
-
Method Details
-
register
public abstract void register()Registers all configs here using theregister(Class, String, ConfigSerializer)method -
register
Registers a config class with the given name and serializer- Parameters:
clazz- Class of the configname- Name of the config fileconfigSerializer- Serializer to use
-
copyResourceConfigs
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
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
Saves the given config object to its corresponding file- Parameters:
object- Config object to save
-