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.
A collection can be placed in two ways, and doesn't need to know which:
-
Top-level, as a nested
objectinside aConfigContainer/ConfigGroup-directoryresolves under that container's own path. -
As a field, via
DataSpec.configSpecList/DataSpec.configSpecMap-directoryresolves as a subfolder next to the owningConfigSpec's own file (e.g.MyConfig/presets/).
Either way, whatever attaches this collection assigns baseFolder before calling init.
Parameters¶
-
directory: Subfolder (under whatever
baseFolderresolves to) this collection's files live in. Defaults toid. -
synchronized: Whether
factoryproducesConfigSpec.Serverentries that should sync to clients, server-authoritative: the server broadcasts which entries exist (a client's own add/remove is disabled in the UI - seebuildCollectionEntry), and an existing entry's values sync like a normalConfigSpec.Server's (permission-gated edits, reverted with a message if denied). All entries share one channel, registered once at attach time - a fresh payload type per entry can't be negotiated once the server has already accepted connections, so entries can't each get their own the way a standaloneConfigSpec.Serverdoes. -
factory: Builds a new/loading entry for the given entry id (typically its filename).
Inheritors¶
Properties¶
directory¶
Parameters
- directory: Subfolder (under whatever
baseFolderresolves to) this collection's files live in. Defaults toid.
id¶
Stable identifier - this node's path segment when nested under a ConfigGroup.
synchronized¶
val synchronized: Boolean
Parameters
- synchronized: Whether
factoryproducesConfigSpec.Serverentries that should sync to clients, server-authoritative: the server broadcasts which entries exist (a client's own add/remove is disabled in the UI - seebuildCollectionEntry), and an existing entry's values sync like a normalConfigSpec.Server's (permission-gated edits, reverted with a message if denied). All entries share one channel, registered once at attach time - a fresh payload type per entry can't be negotiated once the server has already accepted connections, so entries can't each get their own the way a standaloneConfigSpec.Serverdoes.
title¶
open override val title: Component
Display title shown for this node's row in its parent's screen.
Functions¶
add¶
Creates, saves, and registers a new entry for entryId. For a synchronized collection, only ever call this server-side - see the class doc.
remove¶
Deletes entryId's file and drops it from this collection. No-op if absent. For a synchronized collection, only ever call this server-side - see the class doc.