Interface PluginConfigSource
-
- All Known Implementing Classes:
PluginConfigSourceImpl
public interface PluginConfigSource
This interface provides a mechanism for plugins to store configuration settings in a separate configuration file (rather than the main client configuration file).Important: If you are using this class for a plugin which previously used to store configuration settings in the main configuration file (which is what most existing plugins do), you should call the
forceSettingsMigration()
method to get existing settings moved over - please read the comments for that file if you need to do that.To create an instance of this file, you need to call
PluginConfig.enableExternalConfigSource()
. Once you have an instance, you then need to callinitialize()
to configure it - though there are additional methods that you can call for additional configuration.Note: Only for implementation by Core, not plugins.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
forceSettingsMigration()
If your plugin previously used to store data in the main configuration file, you can call this method (which needs to be done soon after initialization) which will move all monitored parameters over to this object.java.io.File
getConfigFile()
Returns a file object which represents the location of the configuration file that this object interacts with.void
initialize()
This initializes this configuration object and gets the external configuration file integrated with the client.void
save(boolean force)
Manually saves the configuration settings recorded by this object to disk.void
setConfigFilename(java.lang.String filename)
This method sets the filename for the configuration file that this object links to - this must be done before theinitialize()
method is called.
-
-
-
Method Detail
-
initialize
void initialize()
This initializes this configuration object and gets the external configuration file integrated with the client.It performs the following steps:
- Loads the data of any existing config file into the client.
- Registers all parameters in the file to be stored inside this configuration file (so all changes will be stored here).
- Adds a hook to allow it to be automatically saved when the client autosaves its own internal configuration files.
- Adds a hook to intercept any configuration settings created and used by the plugin and stores it internally (rather than being saved in the main the client config file).
-
setConfigFilename
void setConfigFilename(java.lang.String filename)
This method sets the filename for the configuration file that this object links to - this must be done before theinitialize()
method is called.- Parameters:
filename
- The filename to use.
-
getConfigFile
java.io.File getConfigFile()
Returns a file object which represents the location of the configuration file that this object interacts with.
-
save
void save(boolean force)
Manually saves the configuration settings recorded by this object to disk. This isn't normally required, as the client will automatically save the configuration file when the main configuration file is saved, but you can choose to save on demand if you wish.- Parameters:
force
- true if you want the file to be written to regardless of whether there are any changes, false if you only want to save the file if there are unsaved changes.
-
forceSettingsMigration
void forceSettingsMigration()
If your plugin previously used to store data in the main configuration file, you can call this method (which needs to be done soon after initialization) which will move all monitored parameters over to this object.You have to call this method before you initialize the object. It's also recommended that if you call this method, that you call
save(boolean)
to save any settings copied across - probably best to be done as the last thing of thePlugin.initialize(PluginInterface)
method.
-
-