net.kernelpanicsoft.archie.config¶
Types¶
CategorySpec¶
abstract class CategorySpec(title: Component, id: String = title.string.toSnakeCase()) : DataSpec
A top-level section of a ConfigSpec, or a nested subsection of another CategorySpec. Declared as a nested singleton object inside a ConfigSpec or a parent CategorySpec - ConfigSpec.categories and subcategories both discover their members by reflecting over nested objects, so there's nothing to override or register manually.
ClientConfigContainer¶
class ClientConfigContainer(container: ConfigContainer)
Client-side mirror of a ConfigContainer. If exactly one of ConfigContainer.children is visible, buildConfigContainer opens that child's own screen directly; with more than one, it builds a screen listing an "Edit" entry per child that drills into it. See buildNodeListScreen.
ClientConfigGroup¶
class ClientConfigGroup(group: ConfigGroup)
Client-side mirror of a ConfigGroup, built lazily as ConfigGroup.client. See buildNodeListScreen.
ClientConfigSpec¶
class ClientConfigSpec(spec: ConfigSpec)
Client-side mirror of a ConfigSpec, built lazily as ConfigSpec.client; builds the Cloth Config UI screen.
ClientDataSpec¶
class ClientDataSpec(spec: DataSpec)
Client-side mirror of a DataSpec, built lazily as DataSpec.client. Every boolean/ int/... method here is called by its DataSpec counterpart (via net.kernelpanicsoft.archie.util.onClient) with matching parameters, and queues a ConfigEntryBuilder-based entry that reads from and writes back into the same backing maps on spec. buildRoot/buildSub then turn the queued entries into an actual Cloth Config ConfigCategory/SubCategoryListEntry. None of this is called directly by mod authors - see DataSpec for the public DSL.
Comment¶
A comment-list entry id paired with a factory for the Cloth Config TextListEntry it renders as.
CommonKeyCode¶
@Serializable
data class CommonKeyCode(
val type: CommonKeyCode.Type,
val key: Int,
val modifiers: Set<CommonKeyCode.Modifier>
)
A serializable, client-independent representation of a keybind, used by DataSpec.keycode fields so config files don't depend on Cloth Config's ModifierKeyCode. Convert to/from the client type with toClient/toCommon.
ConfigContainer¶
abstract class ConfigContainer(val mod: Mod, val title: Component = Component.literal(mod.name))
The single per-mod root of the config system, declared as a singleton object holding one or more nested ConfigNodes - ConfigSpecs, ConfigGroups (folders), and ConfigSpecCollections (dynamic, directory-backed collections):
ConfigGroup¶
abstract class ConfigGroup(val title: Component, val id: String = title.string.toSnakeCase()) : ConfigNode
A folder grouping other ConfigNodes (config specs, nested groups, and collections), declared as a nested singleton object inside a ConfigContainer or another ConfigGroup:
ConfigNode¶
sealed interface ConfigNode
Something a ConfigContainer or ConfigGroup can hold as a child and show as a row in its Cloth Config screen: a ConfigSpec (an "Edit" row opening its own screen), a ConfigGroup (a folder - an "Edit" row opening a subscreen listing its own children), or a ConfigSpecCollection (an "Edit" row opening an add/remove list screen).
ConfigSpec¶
sealed class ConfigSpec : ConfigNode
The root of a mod's config. ConfigSpec is sealed - declare one or more nested singleton objects subclassing Common, Client, Server, or Startup (nested inside a ConfigContainer) depending on when the config should load and whether it should sync. categories are discovered automatically from nested CategorySpec objects - no need to override anything:
ConfigSpecCollection¶
sealed class ConfigSpecCollection<T : ConfigSpec> : ConfigNode
A directory-backed, runtime-managed collection of independent ConfigSpec files - one file per entry, each an ordinary ConfigSpec instance built by factory rather than a singleton object, since the number of entries isn't known at compile time. Existing files are discovered and loaded from directory on init. Its Cloth Config UI (a native add/remove net.kernelpanicsoft.archie.config.builder.ListFieldBuilder/net.kernelpanicsoft.archie.config.builder.MapFieldBuilder row, see ConfigSpecList/ConfigSpecMap) edits a scratch copy and only calls reconcile on save; add/remove act immediately instead, for programmatic use. Declare ConfigSpecList or ConfigSpecMap, not this directly.
ConfigSpecList¶
class ConfigSpecList<T : ConfigSpec>(
title: Component,
id: String = title.string.toSnakeCase(),
directory: String = id,
synchronized: Boolean = false,
factory: (entryId: String) -> T
) : ConfigSpecCollection<T>
A ConfigSpecCollection exposed as an ordered entries list.
ConfigSpecMap¶
class ConfigSpecMap<T : ConfigSpec>(
title: Component,
id: String = title.string.toSnakeCase(),
directory: String = id,
synchronized: Boolean = false,
factory: (entryId: String) -> T
) : ConfigSpecCollection<T>
A ConfigSpecCollection exposed as a entries map keyed by each entry's id (its filename).
DataSpec¶
A group of config fields, declared by subclassing this and adding fields with the by boolean(...), by int(...), etc. delegates below.
IConfigSerializer¶
interface IConfigSerializer
Reads and writes a ConfigSpec to/from a specific file format (JSON, JSON5, TOML, ...). Built-in implementations live in net.kernelpanicsoft.archie.config.serializer; ConfigSpec.fileSerializer picks one per-platform by default.
Functions¶
toCommon¶
fun ModifierKeyCode.toCommon(): CommonKeyCode
Converts a Cloth Config ModifierKeyCode to the serializable CommonKeyCode.
toSnakeCase¶
fun String.toSnakeCase(): String
Converts this string to snake_case, splitting on both spaces and camelCase humps. Used to derive field/category ids from titles and delegated property names (e.g. "Max Items" and maxItems both become max_items).