Skip to content

DataSpec

abstract class DataSpec(val title: Component, val id: String = title.string.toSnakeCase())

A group of config fields, declared by subclassing this and adding fields with the by boolean(...), by int(...), etc. delegates below.

Each delegate call registers a field under an id derived from the property name (snake_cased), stores the field's FieldType and default value, and - on the client - mirrors the field into ClientDataSpec so Cloth Config can render it. The delegate itself just reads the current value back out of this category's backing maps, so config values are read with plain property access (e.g. MyConfig.General.enableFeature).

CategorySpec is a DataSpec subclass used for a ConfigSpec's top-level sections (and supports nested CategorySpec.subcategories for grouping in the UI). Subclass DataSpec directly instead for non-category values embedded as fields via spec/specList/specMap.

Parameters

  • title: Display title shown in the Cloth Config UI.

  • id: Stable identifier used as this category's key in its parent and in the serialized file. Defaults to the snake_cased title.

Inheritors

Constructors

DataSpec

constructor(title: Component, id: String = title.string.toSnakeCase())

Parameters

  • title: Display title shown in the Cloth Config UI.

  • id: Stable identifier used as this category's key in its parent and in the serialized file. Defaults to the snake_cased title.

Properties

client

Client-side mirror of this category, used to build the Cloth Config UI.

id

val id: String

Parameters

  • id: Stable identifier used as this category's key in its parent and in the serialized file. Defaults to the snake_cased title.

isEnabled

open val isEnabled: Boolean = true

Whether this category is currently active. When false, Cloth Config hides/disables the category's fields in the UI. Override with a get() that reads another field (e.g. a parent toggle) to make this category conditional.

title

val title: Component

Parameters

  • title: Display title shown in the Cloth Config UI.