Guide 04
Give addons typed, persistent settings.
Addon configuration loads before the addon lifecycle and persists changes in the addon's own data directory.
Define typed settings
Derive a record from AddonConfig and use it as the generic argument for your addon. Config is ready before OnAddonLoaded runs, and Enabled controls whether the load callback is invoked.
InventoryAddon.cs
using Lithium.Addons;
namespace Lithium.Inventory;
public sealed record InventoryConfig : AddonConfig
{
public int SlotCount { get; set; } = 32;
}
[Addon("thepanicdept.lithium_inventory", "Lithium Inventory")]
public sealed class InventoryAddon : Addon<InventoryConfig>
{
protected override void OnAddonLoaded()
{
Log.Info($"Slots: {Config.SlotCount}");
}
}Persist changes
Modify the current Config object and call SaveConfig after initialization. Lithium stores settings under the manifest id, keeping each addon's data isolated.