Common¶
abstract class Common(
mod: Mod,
title: Component = Component.literal("Common"),
id: String = title.string.toSnakeCase()
) : ConfigSpec
Inheritors¶
Constructors¶
Common¶
constructor(
mod: Mod,
title: Component = Component.literal("Common"),
id: String = title.string.toSnakeCase()
)
Properties¶
categories¶
val categories: List<CategorySpec>
Top-level sections of this config.
configFolder¶
var configFolder: Path
filename¶
Path of the config file, relative to configFolder, without extension.
id¶
Parameters
isLoaded¶
Whether load has run at least once, or (for a synced spec) a value has been received from the server.
mod¶
val mod: Mod
Parameters
- mod: The owning mod, used to derive the default
filenameand locate the config directory.
predicate¶
synchronized¶
open val synchronized: Boolean = false
title¶
open override val title: Component
Parameters
- title: Display title of the config, shown as the Cloth Config screen title.
type¶
val type: ConfigSpec.Type
Functions¶
init¶
open override fun init()
Registers all categories (and their subcategories) and, for a synchronized spec, registers this spec's NetworkChannel plus the player-join/quit listeners that push it to joining clients and reset isLoaded on disconnect.
This does not load the config file or touch the client UI - each of Common, Client, Server, and Startup overrides this to additionally register the lifecycle event (documented on that subclass) that calls load at the right time. The client-side settings screen is built and registered separately, once every nested spec in the container is initialized, by ConfigContainer.initClient. Call ConfigContainer.init, not this method directly.
load¶
fun load()
Reads the config file via fileSerializer, creating it with defaults if absent, marks isLoaded, and attaches/scans every DataSpec.configSpecList/DataSpec.configSpecMap field reachable from categories - deferred to here, rather than init, since configFolder isn't final until just before this runs (a Server spec only repoints it at the per-world folder right before calling load).
save¶
fun save()
Writes the current values of every field in categories to the config file via fileSerializer.