Plugin configuration

While plugins can handle configuration on their own, the framework has built-in support for configuration using the confort configuration library..

Retrieving a configuration

Configuration references can be injected into plugin classes (or wherever the InjectionService is manually called by a plugin).
The fields in question must additionally be annotated with @Config.
The annotation currently accepts two parameters (id and category) with the third (format) is there for future use.

  • id directly influences the file name. At the moment the file will be called <id>.json
  • category puts the configuration file in a sub-directory of the plugins configuration directory

The plugin configuration directory is named after the plugin id and will be located below the framework configuration directory. (Which normally will be config.)

Configuration types

The following field types are supported:

  • java.nio.file.Path: A representation of the configuration file.
  • java.io.File: A representation of the configuration file.
  • de.mlessmann.confort.api.IConfig: A config representation of the configuration file and contents. See Confort for more information on this.

🚧

Keep in mind

Even if a plugin manually loads the configuration, it is recommended to retrieve the file representations using injection to keep the outer behavior in sync with the framework and other plugins.

Example

package de.fearnixx.jeak;

import de.fearnixx.jeak.reflect.Config;
import de.fearnixx.jeak.reflect.Inject;
import de.fearnixx.jeak.reflect.JeakBotPlugin;

@JeakBotPlugin(id = "sometestplugin")
public class TestPlugin {
  
  @Inject
  @Config(id = "testConfiguration")
  public IConfig configurationRepresentation;
}