Creating Your First Config

Now that you've installed the dependency and have access to the library code we can go ahead and start creating your first config. Configs in Resourceful Config are annotation based meaning that everything for a config must have a corresponding annotation.

Your First Config Class

To create your first config class you need to annotate a class with the @Config annotation this annotation has 3 parameters but we can just care about the value one for now as the other 2 it has default values. The value parameter in this case is the name of the config and is limited to basic characters as it is used for the name of the config file. The other 2 parameters it has are categories which we will get into later and version version is used in conjunction with a config patcher which you can optionally register with your config to allow you to update between versions to make your config fix itself on updates.

Heres what it should look like.

@Config(value = "demo")
public class DemoConfig {
    // Your config entries...
}

Note

Config class have certain restrictions they must follow. The following are restrictions that a config class must follow.

  • Class must have the public access modifier

  • Class must be static if it is an inner class of another

  • Class must not be an enum, interface, annotation, or a record.

Last updated