Repository navigation
Configuration Files
Trin Wasinger edited this page Oct 9, 2026
·
2 revisions
Specter supports reading and writing data and comments with Groovy-based config files via io.github.sianabeeblebrox.specter.config.Config.
- Configuration files should contain a single Groovy expression with an optional doc-comment.
- Map and list literals not within a different expression are wrapped in
ConfigMapandConfigListrespectively.- The underlying AST structure of their values is preserved unless overwritten.
- Doc-comments attached to lists, maps, and map entries are preserved and can be programmatically manipulated via
setComment(String)andgetComment(). - Entries can be assigned a Groovy expression or an arbitrary value.
- When assigning an expression, it is evaluated to get the new value, and the underlying expression is stored for serialization.
- When assigning any other value, an attempt is made to create an expression representing it for serialization. Primitives, boxed primitives, enums, records, strings, gstrings, numeric ranges, tuples, maps, and lists are fully supported. Groovy closures are supported if the corresponding source is still available.
[
/**
* User's first and last name
*/
name: 'Jane Doe',
age: 23,
details: [
favorite_color: new com.example.Color(0xff00ff),
favorite_number: 11+2*3
],
tags: ['uwu', 'o/']
]-
io.github.sianabeeblebrox.specter.config.*can be used independent of the rest of Specter! - While a powerful intended feature, parsing config can execute arbitrary Groovy code!
- File extension is irrelevant for parsing configuration files; however, don't use one that Specter will load automatically if placing configuration files within the mods folder! Try creating a file association in your editor if you want syntax highlighting.
- For more details, see the Javadoc.