Default Configuration Element Types
The ConfigSpec object has an army of methods for default configuration element types. Let's enumerate them:
ConfigSpec#boolwhich sets aninitialboolean for a givenproperty.ConfigSpec#intValuewhich sets aninitialinteger for a givenproperty.ConfigSpec#doubleValuewhich sets aninitialdouble floating point for a givenproperty.ConfigSpec#stringwhich sets aninitialstring for a givenproperty.ConfigSpec#identifierwhich sets aninitialidentifier for a givenproperty.ConfigSpec#colorwhich sets aninitialcolor for a givenproperty.ConfigSpec#poswhich sets aninitialblock position for a givenproperty.ConfigSpec#vec3which sets aninitial3-dimensional vector for a givenproperty.ConfigSpec#intRangewhich sets aninitialinteger for a range between a specifiedstart(inclusive) andend(inclusive) for a givenproperty.ConfigSpec#doubleRangewhich sets aninitialdouble floating point for a range between a specifiedstart(inclusive) andend(inclusive) for a givenproperty.ConfigSpec#enumValuewhich sets aninitialenumeration field for a givenproperty.ConfigSpec#listwhich setsinitialentries managed by specifiedentryCodecandentryStreamCodec, for a givenproperty.ConfigSpec#map, which setsinitialentries managed by specifiedentryCodec,entryStreamCodec,valueCodec,valueStreamCodec, for a givenproperty.
Custom Configuration Element Types
You are also able to provide your own configuration element types, thanks to the ConfigSpec#element method.
You will need to provide an initial value of your T type, a Codec<T> for file encoding and decoding purposes, a StreamCodec<T> for networking purposes, and a ConfigSchemaNode.
Look at ConfigSchemaNode#of static methods to create them.
Nodes allow you to define a specified Class<?> value for the property, which allows to ensure type-safety for it.
You can also define a Validation, either INHERITORS, which accepts values inheriting from the type, or STRICT, which only allows the given type.
Lastly, you can define a Context, which can then be retrieved from the ConfigSchema, and which is immutable. In example, it's used by int ranges and double ranges to store their boundaries. You can find example implementations with the IntRangeContext and DoubleRangeContext classes.
