Interface ConfigManager
- All Known Implementing Classes:
DefaultConfigManager
public interface ConfigManager
Main entry point for configuration management.
-
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateDefaults(@NotNull Class<?> configClass) Generates a default config file with comments.<T> TGets a loaded config by class.@Nullable ObjectGets a value by path.<T> TGets a typed value by path.booleangetBoolean(@NotNull String path, boolean defaultValue) Gets a boolean value with default.doubleGets a double value with default.<T> @NotNull Collection<T>getFolderConfig(@NotNull Class<T> configClass) Gets a folder-based config (folder-config).<T> @NotNull Collection<T>getFolderConfig(@NotNull Class<T> configClass, @NotNull String folderConfigName) Gets a folder config by item type and folder config name.<T> @NotNull FolderConfigRef<T>getFolderConfigRef(@NotNull Class<T> configClass) Gets a live folder config reference with edit capabilities.<T> @NotNull FolderConfigRef<T>getFolderConfigRef(@NotNull Class<T> configClass, @NotNull String folderConfigName) Gets a live folder config reference by item type and folder config name.intGets an int value with default.longGets a long value with default.<T> @NotNull ConfigRef<T>Gets a live reference to a config.Gets all registered config classes.@NotNull TypeSerializerRegistryGets the serializer registry for registering custom serializers.@NotNull StringGets a string value with default.getStringList(@NotNull String path) Gets a string list.booleanisRegistered(@NotNull Class<?> configClass) Checks if a config class is registered.<T> voidRegisters a config class for management.<T> voidregister(@NotNull Class<T> configClass, @NotNull ConfigSource source) Registers a config class with a custom source.voidReloads a specific config.voidReloads all managed configs.voidreloadFolderConfigItem(@NotNull Class<?> configClass, @NotNull String itemId) Reloads a specific file in a folder config.voidreloadFolderConfigItem(@NotNull Class<?> configClass, @NotNull String folderConfigName, @NotNull String itemId) Reloads a specific file in a folder config by name.voidSaves a config (writes current values to file).
-
Method Details
-
get
Gets a loaded config by class.- Type Parameters:
T- the config type- Parameters:
configClass- the config class- Returns:
- the config instance
-
getRef
Gets a live reference to a config.- Type Parameters:
T- the config type- Parameters:
configClass- the config class- Returns:
- the config reference
-
getFolderConfig
Gets a folder-based config (folder-config).If multiple folder configs exist for this item type, throws an exception instructing to use
getFolderConfig(Class, String)instead.- Type Parameters:
T- the config type- Parameters:
configClass- the config class- Returns:
- the collection of config instances
-
getFolderConfig
@NotNull <T> @NotNull Collection<T> getFolderConfig(@NotNull @NotNull Class<T> configClass, @NotNull @NotNull String folderConfigName) Gets a folder config by item type and folder config name.- Type Parameters:
T- the config type- Parameters:
configClass- the config classfolderConfigName- the folder config name- Returns:
- the collection of config instances
-
getFolderConfigRef
Gets a live folder config reference with edit capabilities.If multiple folder configs exist for this item type, throws an exception instructing to use
getFolderConfigRef(Class, String)instead.- Type Parameters:
T- the config type- Parameters:
configClass- the config class- Returns:
- the folder config reference
-
getFolderConfigRef
@NotNull <T> @NotNull FolderConfigRef<T> getFolderConfigRef(@NotNull @NotNull Class<T> configClass, @NotNull @NotNull String folderConfigName) Gets a live folder config reference by item type and folder config name.- Type Parameters:
T- the config type- Parameters:
configClass- the config classfolderConfigName- the folder config name- Returns:
- the folder config reference
-
get
Gets a value by path.Format: "configName:path.to.value" or just "path.to.value"
- Parameters:
path- the path- Returns:
- the value, or null if not found
-
get
Gets a typed value by path.- Type Parameters:
T- the type- Parameters:
path- the pathtype- the target type- Returns:
- the value, or null if not found
-
getString
@NotNull @NotNull String getString(@NotNull @NotNull String path, @NotNull @NotNull String defaultValue) Gets a string value with default.- Parameters:
path- the pathdefaultValue- the default value- Returns:
- the value or default
-
getInt
Gets an int value with default.- Parameters:
path- the pathdefaultValue- the default value- Returns:
- the value or default
-
getLong
Gets a long value with default.- Parameters:
path- the pathdefaultValue- the default value- Returns:
- the value or default
-
getBoolean
Gets a boolean value with default.- Parameters:
path- the pathdefaultValue- the default value- Returns:
- the value or default
-
getDouble
Gets a double value with default.- Parameters:
path- the pathdefaultValue- the default value- Returns:
- the value or default
-
getStringList
Gets a string list.- Parameters:
path- the path- Returns:
- the list, or empty list if not found
-
register
Registers a config class for management.- Type Parameters:
T- the config type- Parameters:
configClass- the config class
-
register
Registers a config class with a custom source.- Type Parameters:
T- the config type- Parameters:
configClass- the config classsource- the config source
-
reload
Reloads a specific config.- Parameters:
configClass- the config class
-
reloadFolderConfigItem
void reloadFolderConfigItem(@NotNull @NotNull Class<?> configClass, @NotNull @NotNull String itemId) Reloads a specific file in a folder config.If multiple folder configs exist for this item type, throws an exception instructing to use
reloadFolderConfigItem(Class, String, String)instead.- Parameters:
configClass- the config classitemId- the item ID (filename without extension)
-
reloadFolderConfigItem
void reloadFolderConfigItem(@NotNull @NotNull Class<?> configClass, @NotNull @NotNull String folderConfigName, @NotNull @NotNull String itemId) Reloads a specific file in a folder config by name.- Parameters:
configClass- the config classfolderConfigName- the folder config nameitemId- the item ID (filename without extension)
-
reloadAll
void reloadAll()Reloads all managed configs. -
save
Saves a config (writes current values to file).- Parameters:
configClass- the config class
-
generateDefaults
Generates a default config file with comments.- Parameters:
configClass- the config class
-
isRegistered
Checks if a config class is registered.- Parameters:
configClass- the config class- Returns:
- true if registered
-
getRegisteredConfigs
Gets all registered config classes.- Returns:
- the set of registered classes
-
getSerializerRegistry
Gets the serializer registry for registering custom serializers.- Returns:
- the serializer registry
-