Interface ConfigManager


public interface ConfigManager
Central service for managing plugin configurations.

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 Details

    • RSPROFILE_GROUP

      static final String RSPROFILE_GROUP
      The configuration group name for RuneScape profile settings.
      See Also:
    • RSPROFILE_DISPLAY_NAME

      static final String RSPROFILE_DISPLAY_NAME
      The key for the display name in RuneScape profiles.
      See Also:
    • RSPROFILE_TYPE

      static final String 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

      <T extends Config> T getConfig(Class<T> clazz)
      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

      List<String> getConfigurationKeys(String prefix)
      Gets all configuration keys matching the specified prefix.
      Parameters:
      prefix - the key prefix to match
      Returns:
      a list of matching configuration keys
    • getRSProfileConfigurationKeys

      List<String> getRSProfileConfigurationKeys(String group, String profile, String keyPrefix)
      Gets all RuneScape profile configuration keys matching the criteria.
      Parameters:
      group - the configuration group
      profile - the profile identifier
      keyPrefix - the key prefix to match
      Returns:
      a list of matching configuration keys
    • getConfiguration

      String getConfiguration(String groupName, String key)
      Gets a configuration value as a string.
      Parameters:
      groupName - the configuration group
      key - the configuration key
      Returns:
      the configuration value, or null if not set
    • getConfiguration

      String getConfiguration(String groupName, String profile, String key)
      Gets a configuration value for a specific profile as a string.
      Parameters:
      groupName - the configuration group
      profile - the profile identifier
      key - the configuration key
      Returns:
      the configuration value, or null if not set
    • getConfiguration

      <T> T getConfiguration(String groupName, String key, Type clazz)
      Gets a configuration value converted to the specified type.
      Type Parameters:
      T - the target type
      Parameters:
      groupName - the configuration group
      key - the configuration key
      clazz - the target type
      Returns:
      the typed configuration value, or null if not set
    • getRSProfileConfiguration

      <T> T getRSProfileConfiguration(String groupName, String key, Type clazz)
      Gets a RuneScape profile configuration value converted to the specified type.
      Type Parameters:
      T - the target type
      Parameters:
      groupName - the configuration group
      key - the configuration key
      clazz - the target type
      Returns:
      the typed configuration value, or null if not set
    • getRSProfileConfiguration

      <T> T getRSProfileConfiguration(String groupName, String key)
      Gets a RuneScape profile configuration value.
      Type Parameters:
      T - the inferred return type
      Parameters:
      groupName - the configuration group
      key - the configuration key
      Returns:
      the configuration value, or null if not set
    • getConfiguration

      <T> T getConfiguration(String groupName, String profile, String key, Type type)
      Gets a configuration value for a specific profile converted to the specified type.
      Type Parameters:
      T - the target type
      Parameters:
      groupName - the configuration group
      profile - the profile identifier
      key - the configuration key
      type - the target type
      Returns:
      the typed configuration value, or null if not set
    • setConfiguration

      void setConfiguration(String groupName, String profile, String key, String value)
      Sets a configuration value for a specific profile.
      Parameters:
      groupName - the configuration group
      profile - the profile identifier
      key - the configuration key
      value - the string value to set
    • setConfiguration

      void setConfiguration(String groupName, String key, String value)
      Sets a configuration value.
      Parameters:
      groupName - the configuration group
      key - the configuration key
      value - the string value to set
    • setConfiguration

      <T> void setConfiguration(String groupName, String profile, String key, T value)
      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 group
      profile - the profile identifier
      key - the configuration key
      value - the value to set
    • setConfiguration

      <T> void setConfiguration(String groupName, String key, T value)
      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 group
      key - the configuration key
      value - the value to set
    • setRSProfileConfiguration

      <T> void setRSProfileConfiguration(String groupName, String key, T value)
      Sets a typed configuration value for the current RuneScape profile.
      Type Parameters:
      T - the value type
      Parameters:
      groupName - the configuration group
      key - the configuration key
      value - the value to set
    • unsetConfiguration

      void unsetConfiguration(String groupName, String profile, String key)
      Removes a configuration value for a specific profile.
      Parameters:
      groupName - the configuration group
      profile - the profile identifier
      key - the configuration key
    • unsetConfiguration

      void unsetConfiguration(String groupName, String key)
      Removes a configuration value.
      Parameters:
      groupName - the configuration group
      key - the configuration key
    • unsetRSProfileConfiguration

      void unsetRSProfileConfiguration(String groupName, String key)
      Removes a configuration value from the current RuneScape profile.
      Parameters:
      groupName - the configuration group
      key - the configuration key
    • getConfigDescriptor

      ConfigDescriptor getConfigDescriptor(Config configurationProxy)
      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

      <T extends Config> void setDefaultConfiguration(T proxy, boolean override)
      Sets default values for all configuration items in a proxy.
      Type Parameters:
      T - the Config type
      Parameters:
      proxy - the configuration proxy
      override - if true, overwrites existing values; if false, only sets unset values
    • stringToObject

      Object stringToObject(String str, Type type)
      Converts a string value to the specified type.
      Parameters:
      str - the string value
      type - the target type
      Returns:
      the converted object
    • objectToString

      String objectToString(Object object)
      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

      Consumer<? super Plugin> getConsumer(String configGroup, String keyName)
      Gets a consumer that can be used to trigger configuration change events.
      Parameters:
      configGroup - the configuration group
      keyName - 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

      void switchProfile(ConfigProfile newProfile)
      Switches to a different configuration profile.
      Parameters:
      newProfile - the profile to switch to
    • sendConfig

      void sendConfig()
      Sends the current configuration to sync services.
    • importAndMigrate

      void importAndMigrate(ProfileLock lock, File from, ConfigProfile targetProfile)
      Imports configuration from a file and migrates it to a target profile.
      Parameters:
      lock - the profile lock for thread safety
      from - the source file to import from
      targetProfile - the profile to import into