Skip to content

Server

abstract class Server(
    mod: Mod, 
    title: Component = Component.literal("Server"), 
    id: String = title.string.toSnakeCase()
) : ConfigSpec

Constructors

Server

constructor(
    mod: Mod, 
    title: Component = Component.literal("Server"), 
    id: String = title.string.toSnakeCase()
)

Types

Companion

object Companion

Properties

categories

Top-level sections of this config.

configFolder

filename

open val filename: String

Path of the config file, relative to configFolder, without extension.

id

open override val id: String

Parameters

  • id: Unique identifier for this config, used to derive the default filename and register the network channel. Defaults to the snake-cased title.

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 filename and locate the config directory.

predicate

open override val predicate: () -> Boolean

synchronized

open override val synchronized: Boolean = true

title

open override val title: Component

Parameters

  • title: Display title of the config, shown as the Cloth Config screen title.

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.