Table of Contents

Class SyncedConfig

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll

Reads a plugin's live config entry on a server or a client through an adapter's ConfigEntryCommand (default ValheimCLI plugin), so a test can compare the value each side uses after a join or an admin change. The observation reads the ConfigEntry itself on each side; how the mod syncs it (ServerSync embedded in the mod, Jötunn, its own RPC) is the mod's business, and a synced mod sets the client's entry. Values compare as the text BepInEx would write to the file, whatever the entry's type. Nothing here writes config: the change under test is the mod's own (an admin command, a server-side file edit).

public static class SyncedConfig
Inheritance
object
SyncedConfig

Fields

Source

public const string Source = "bepinex-config"

Field Value

string

Methods

Parse(JsonElement)

Parses a reply; anything malformed or incomplete throws rather than reading as a missing entry.

public static ConfigValue Parse(JsonElement data)

Parameters

data JsonElement

Returns

ConfigValue

Read(GameActor, string, string, string, string)

The entry section/key of plugin guid in actor's process, through capabilityPath (for example valheim.observe/config). A reply about another entry, or an incomplete one, throws.

public static ConfigValue Read(GameActor actor, string capabilityPath, string guid, string section, string key)

Parameters

actor GameActor
capabilityPath string
guid string
section string
key string

Returns

ConfigValue

RequireSame(ConfigValue, ConfigValue)

Throws unless both sides have the entry with the same value and type, naming both: for example after a join, where a synced mod's client must use the server's value.

public static void RequireSame(ConfigValue server, ConfigValue client)

Parameters

server ConfigValue
client ConfigValue

Token(string)

Percent-encodes one argument (Enable Mod becomes Enable%20Mod): extension arguments are single tokens, and BepInEx sections and keys may hold spaces. The adapter decodes it.

public static string Token(string text)

Parameters

text string

Returns

string

WaitForValue(GameActor, string, string, string, string, string, TimeSpan, TimeSpan, Func<TimeSpan, CancellationToken, Task>?, CancellationToken)

Waits until the entry reads expected (the file's text form) in actor's process and returns it, re-reading at most interval apart, or sooner when changed completes. A plugin that is not loaded or an entry that does not exist fails at once (WaitFailedException): that value can never arrive. Expiry throws WaitTimeoutException with the last value read.

public static Task<ConfigValue> WaitForValue(GameActor actor, string capabilityPath, string guid, string section, string key, string expected, TimeSpan timeout, TimeSpan interval, Func<TimeSpan, CancellationToken, Task>? changed = null, CancellationToken cancellation = default)

Parameters

actor GameActor
capabilityPath string
guid string
section string
key string
expected string
timeout TimeSpan
interval TimeSpan
changed Func<TimeSpan, CancellationToken, Task>
cancellation CancellationToken

Returns

Task<ConfigValue>