Interface ConfigManager
The ConfigManager handles all configuration operations including reading, writing, and persisting configuration values. It supports multiple configuration profiles and RuneScape account-specific settings.
Configuration values are stored as strings and automatically converted to/from the appropriate types when accessed through Config interfaces.
Example usage:
@Inject
private ConfigManager configManager;
public void someMethod() {
// Get a typed configuration proxy
MyConfig config = configManager.getConfig(MyConfig.class);
// Or access raw configuration values
String value = configManager.getConfiguration("myplugin", "someKey");
configManager.setConfiguration("myplugin", "someKey", "newValue");
}
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T extends Config>
TCreates a configuration proxy for the specified Config interface.getConfigDescriptor(Config configurationProxy) Gets the descriptor for a configuration proxy.getConfiguration(String groupName, String key) Gets a configuration value as a string.<T> TgetConfiguration(String groupName, String key, Type clazz) Gets a configuration value converted to the specified type.getConfiguration(String groupName, String profile, String key) Gets a configuration value for a specific profile as a string.<T> TgetConfiguration(String groupName, String profile, String key, Type type) Gets a configuration value for a specific profile converted to the specified type.getConfigurationKeys(String prefix) Gets all configuration keys matching the specified prefix.getConsumer(String configGroup, String keyName) Gets a consumer that can be used to trigger configuration change events.Gets the currently active configuration profile.<T> TgetRSProfileConfiguration(String groupName, String key) Gets a RuneScape profile configuration value.<T> TgetRSProfileConfiguration(String groupName, String key, Type clazz) Gets a RuneScape profile configuration value converted to the specified type.getRSProfileConfigurationKeys(String group, String profile, String keyPrefix) Gets all RuneScape profile configuration keys matching the criteria.Gets the key for the current RuneScape profile.Gets all RuneScape profiles.voidimportAndMigrate(ProfileLock lock, File from, ConfigProfile targetProfile) Imports configuration from a file and migrates it to a target profile.voidload()Loads configuration from persistent storage.objectToString(Object object) Converts an object to its string representation for storage.voidSends the current configuration to sync services.voidsetConfiguration(String groupName, String key, String value) Sets a configuration value.voidsetConfiguration(String groupName, String profile, String key, String value) Sets a configuration value for a specific profile.<T> voidsetConfiguration(String groupName, String profile, String key, T value) Sets a typed configuration value for a specific profile.<T> voidsetConfiguration(String groupName, String key, T value) Sets a typed configuration value.<T extends Config>
voidsetDefaultConfiguration(T proxy, boolean override) Sets default values for all configuration items in a proxy.<T> voidsetRSProfileConfiguration(String groupName, String key, T value) Sets a typed configuration value for the current RuneScape profile.stringToObject(String str, Type type) Converts a string value to the specified type.voidswitchProfile(ConfigProfile newProfile) Switches to a different configuration profile.voidunsetConfiguration(String groupName, String key) Removes a configuration value.voidunsetConfiguration(String groupName, String profile, String key) Removes a configuration value for a specific profile.voidunsetRSProfileConfiguration(String groupName, String key) Removes a configuration value from the current RuneScape profile.
-
Field Details
-
RSPROFILE_GROUP
The configuration group name for RuneScape profile settings.- See Also:
-
RSPROFILE_DISPLAY_NAME
The key for the display name in RuneScape profiles.- See Also:
-
RSPROFILE_TYPE
The key for the profile type in RuneScape profiles.- See Also:
-
-
Method Details
-
load
void load()Loads configuration from persistent storage.This is typically called during client startup to load saved settings.
-
getConfig
Creates a configuration proxy for the specified Config interface.The returned proxy automatically reads and writes values to storage.
- Type Parameters:
T- the Config interface type- Parameters:
clazz- the Config interface class- Returns:
- a proxy implementation of the Config interface
-
getConfigurationKeys
Gets all configuration keys matching the specified prefix.- Parameters:
prefix- the key prefix to match- Returns:
- a list of matching configuration keys
-
getRSProfileConfigurationKeys
Gets all RuneScape profile configuration keys matching the criteria.- Parameters:
group- the configuration groupprofile- the profile identifierkeyPrefix- the key prefix to match- Returns:
- a list of matching configuration keys
-
getConfiguration
Gets a configuration value as a string.- Parameters:
groupName- the configuration groupkey- the configuration key- Returns:
- the configuration value, or null if not set
-
getConfiguration
Gets a configuration value for a specific profile as a string.- Parameters:
groupName- the configuration groupprofile- the profile identifierkey- the configuration key- Returns:
- the configuration value, or null if not set
-
getConfiguration
Gets a configuration value converted to the specified type.- Type Parameters:
T- the target type- Parameters:
groupName- the configuration groupkey- the configuration keyclazz- the target type- Returns:
- the typed configuration value, or null if not set
-
getRSProfileConfiguration
Gets a RuneScape profile configuration value converted to the specified type.- Type Parameters:
T- the target type- Parameters:
groupName- the configuration groupkey- the configuration keyclazz- the target type- Returns:
- the typed configuration value, or null if not set
-
getRSProfileConfiguration
Gets a RuneScape profile configuration value.- Type Parameters:
T- the inferred return type- Parameters:
groupName- the configuration groupkey- the configuration key- Returns:
- the configuration value, or null if not set
-
getConfiguration
Gets a configuration value for a specific profile converted to the specified type.- Type Parameters:
T- the target type- Parameters:
groupName- the configuration groupprofile- the profile identifierkey- the configuration keytype- the target type- Returns:
- the typed configuration value, or null if not set
-
setConfiguration
Sets a configuration value for a specific profile.- Parameters:
groupName- the configuration groupprofile- the profile identifierkey- the configuration keyvalue- the string value to set
-
setConfiguration
Sets a configuration value.- Parameters:
groupName- the configuration groupkey- the configuration keyvalue- the string value to set
-
setConfiguration
Sets a typed configuration value for a specific profile.The value is automatically converted to a string for storage.
- Type Parameters:
T- the value type- Parameters:
groupName- the configuration groupprofile- the profile identifierkey- the configuration keyvalue- the value to set
-
setConfiguration
Sets a typed configuration value.The value is automatically converted to a string for storage.
- Type Parameters:
T- the value type- Parameters:
groupName- the configuration groupkey- the configuration keyvalue- the value to set
-
setRSProfileConfiguration
Sets a typed configuration value for the current RuneScape profile.- Type Parameters:
T- the value type- Parameters:
groupName- the configuration groupkey- the configuration keyvalue- the value to set
-
unsetConfiguration
Removes a configuration value for a specific profile.- Parameters:
groupName- the configuration groupprofile- the profile identifierkey- the configuration key
-
unsetConfiguration
Removes a configuration value.- Parameters:
groupName- the configuration groupkey- the configuration key
-
unsetRSProfileConfiguration
Removes a configuration value from the current RuneScape profile.- Parameters:
groupName- the configuration groupkey- the configuration key
-
getConfigDescriptor
Gets the descriptor for a configuration proxy.The descriptor contains information about all sections, titles, and items defined in the configuration.
- Parameters:
configurationProxy- the configuration proxy instance- Returns:
- the configuration descriptor
-
setDefaultConfiguration
Sets default values for all configuration items in a proxy.- Type Parameters:
T- the Config type- Parameters:
proxy- the configuration proxyoverride- if true, overwrites existing values; if false, only sets unset values
-
stringToObject
Converts a string value to the specified type.- Parameters:
str- the string valuetype- the target type- Returns:
- the converted object
-
objectToString
Converts an object to its string representation for storage.- Parameters:
object- the object to convert- Returns:
- the string representation
-
getRSProfiles
List<RuneScapeProfile> getRSProfiles()Gets all RuneScape profiles.- Returns:
- a list of RuneScape profiles
-
getConsumer
Gets a consumer that can be used to trigger configuration change events.- Parameters:
configGroup- the configuration groupkeyName- the configuration key- Returns:
- a consumer for the specified configuration
-
getProfile
ConfigProfile getProfile()Gets the currently active configuration profile.- Returns:
- the active profile
-
getRSProfileKey
String getRSProfileKey()Gets the key for the current RuneScape profile.- Returns:
- the RuneScape profile key
-
switchProfile
Switches to a different configuration profile.- Parameters:
newProfile- the profile to switch to
-
sendConfig
void sendConfig()Sends the current configuration to sync services. -
importAndMigrate
Imports configuration from a file and migrates it to a target profile.- Parameters:
lock- the profile lock for thread safetyfrom- the source file to import fromtargetProfile- the profile to import into
-