Context API
Reference every public member exposed by LitherarpAddonContext, grouped by responsibility and realm.
Identity and lifecycle ownership
| Member | Realm | Contract |
|---|---|---|
string AddonId { get; } | both | Normalized owner id used for namespacing and teardown. |
string PackageIdent { get; } | both | Package ident selected by the operator. |
bool IsHost { get; } | both | True for an authoritative host context. |
bool HasCapability(string capability) | both | Checks the effective requested and operator-granted capability set. |
Scene Scene { get; } | both | Scene associated with this activation. An exceptional early client activation can receive a null scene reference, so validate it before use. |
bool IsWorldReady { get; } | host | True after map and persistent-world bootstrap completed. |
bool IsClientWorldReady { get; } | client | True after this process activated the verified addon snapshot for the current client scene. It becomes false while a replacement snapshot is reconciled. |
bool RunWhenWorldReady(Action<Scene> callback) | host | Runs now when ready, or registers a tracked one-shot callback. Returns false on invalid realm or callback. |
bool RunWhenClientWorldReady(Action<Scene> callback) | client | Runs once after the current client snapshot barrier, or immediately when that barrier is already ready. A newly hot-activated addon queues during reconciliation and runs only after the complete snapshot succeeds. |
void Info(string message) | both | Writes an addon-prefixed information log. |
void Warning(string message) | both | Writes an addon-prefixed warning log. |
bool RecordLog(LitherarpLogCategory category, string message, string detail = "", LitherarpPlayer? actor = null, LitherarpPlayer? target = null) | host | Adds an Admin Console log entry owned by this addon. Message and detail are truncated to 512 and 2,048 UTF-16 characters. |
IDisposable Track(IDisposable disposable) | both | Disposes a subscription or other handle at teardown. The context retains at most 4,096 handles; a surplus handle is disposed immediately. |
void OnTeardown(Action action) | both | Registers cleanup in reverse order. The context retains at most 4,096 actions; late or surplus cleanup runs immediately. |
GameObject? TrackGameObject(GameObject? gameObject) | both | Destroys a valid tracked object on normal addon disable. |
T? TrackComponent<T>(T? component) where T : Component | both | Destroys a valid tracked component on normal addon disable. |
CancellationTokenSource TrackCancellation(CancellationTokenSource cancellation) | both | Cancels and disposes a source at teardown. |
Once teardown begins, context registration and gameplay mutation entry points reject new work. Reads, logging and cleanup remain usable. Track disposes a late handle immediately, and OnTeardown runs a late cleanup action immediately. This closes the race where an asynchronous continuation finishes after deactivation.
Config, sync and effects
| Member | Realm | Contract |
|---|---|---|
LitherarpAddonConfigHandle? RegisterConfigFile(string displayName, string defaultJson, Action? onReloaded = null) | host | Registers configs/addons/<id>.json, Admin Console editing and hot reload. The callback invalidates the public snapshot. |
void RegisterPublicSnapshotSection(Func<object> provider) | host | Publishes one JSON object in the regular public config snapshot. |
bool InvalidatePublicSnapshot() | host | Marks public config state dirty after provider data changes. |
bool TryGetPublicSection(out JsonElement section) | both | Reads this addon's last applied public section. On the host it reads the provider value indirectly after synchronization. |
bool SetPlayerSection(LitherarpPlayer? player, object? value) | host | Targets one player's client with a JSON object. The UTF-8 limit is 8,000 bytes. |
bool TryGetMyPlayerSection(out JsonElement section) | client | Reads the local player's private section. |
int PlayerSectionRevision { get; } | client | Revision counter for cheap UI change detection. |
bool ApplyStatusEffect(LitherarpPlayer? target, string effectId, float durationSeconds, float tickIntervalSeconds, Action<LitherarpStatusEffect>? onTick, Action<LitherarpStatusEffect>? onExpired = null) | host | Applies or refreshes a namespaced timed effect. |
bool ApplyDamageOverTime(LitherarpPlayer? target, string effectId, float damagePerTick, float durationSeconds, float tickIntervalSeconds = 1f) | host | Applies periodic damage through the normal player damage pipeline. |
bool RemoveStatusEffect(LitherarpPlayer? target, string effectId) | host | Removes this addon's effect from a player. |
bool HasStatusEffect(LitherarpPlayer? target, string effectId) | host | Tests this addon's effect on a player. |
| Returned or callback type | Public contract |
|---|---|
LitherarpAddonConfigHandle | Path, GetRawJson() and Deserialize<T>(). Reads always use the latest successful reload; deserialization failure returns a fresh T. |
LitherarpStatusEffect | Target, EffectId, Source, AppliedAt, ExpiresAt and computed RemainingSeconds. |
UI, content and registries
Registration and overlay behavior is expanded on Registries and overrides and UI and content.
| Member | Realm | Contract |
|---|---|---|
void RegisterScreenPanel(string objectName, int zIndex, Func<GameObject, Component> attach) | client | Registers a tracked persistent screen panel. |
bool RegisterAdminPanel(string panelId, string label, string icon, string permissionNode, string description, RenderFragment content, int order = 0) | client | Registers an Addon Tools page with an addon permission node. |
bool SetCorePanelEnabled<T>(bool enabled) where T : Component | client | Hides or restores an allowed core panel for this activation. |
bool RegisterPhoneApp(string appId, string label, string icon, RenderFragment content, int order = 100, Action<LitherarpPhoneAppInputContext>? inputHandler = null) | client | Registers a native phone app. |
bool OverrideCorePhoneApp(LitherarpPhoneApp app, string? label = null, string? icon = null, int? order = null, RenderFragment? content = null, Action<LitherarpPhoneAppInputContext>? inputHandler = null) | client | Adds a reversible metadata, content or input override layer to a core phone app. |
bool SetCorePhoneAppEnabled(LitherarpPhoneApp app, bool enabled) | client | Hides or restores a core phone app with tracked teardown. |
bool RegisterToolMode<T>(string permissionNode = "") where T : ToolMode | both | Registers a Toolgun mode using its type-derived id. |
bool RegisterToolMode<T>(string modeId, string permissionNode) where T : ToolMode | both | Registers a Toolgun mode under an explicit id. |
bool RegisterToolAction(string modeId, string action, Action<LitherarpAddonToolActionContext> handler) | host | Registers a custom host action. The handler validates input, calls TryAuthorize immediately before mutation, performs the mutation, then calls Commit only on success. |
bool RegisterRuntimeItem(LitherarpItemDefinition definition) | both | Registers a code-defined item for this realm. |
bool OverrideItem(LitherarpItemDefinition definition, int priority = LitherarpAddonRegistryPriority.Default) | both | Adds a reversible item replacement layer. |
bool SuppressItem(string itemId, int priority = LitherarpAddonRegistryPriority.Default) | both | Adds a reversible item suppression layer. |
bool RegisterConsumable(string itemId, string useLabel, string icon, Func<LitherarpAddonConsumableUseContext, bool> handler, Func<LitherarpItemStack, bool>? clientCanUse = null) | both | Registers a backpack consumable with a host effect and optional client predicate. |
bool RegisterDealerProduct(LitherarpDealerKind dealer, string itemId, string label, string icon, Func<LitherarpItemStack, int> pricePerUnit) | both | Adds stock to the native weed or meth dealer. |
bool RegisterJob(LitherarpJobsConfig.JobConfigEntry entry) | host | Adds a runtime job and syncs the resolved registry. |
bool OverrideJob(LitherarpJobsConfig.JobConfigEntry entry, int priority = LitherarpAddonRegistryPriority.Default) | host | Adds a reversible job replacement layer. |
bool SuppressJob(string jobId, int priority = LitherarpAddonRegistryPriority.Default) | host | Adds a reversible job suppression layer. |
bool RegisterShopEntityTab(LitherarpShopConfig.ShopEntityTabEntry entry) | host | Adds a runtime entity shop tab. |
bool RegisterShopEntityItem(LitherarpShopConfig.ShopEntityItemEntry entry) | host | Adds a runtime entity shop item. |
bool RegisterWeaponDealerItem(LitherarpShopConfig.WeaponDealerItemEntry entry) | host | Adds a runtime weapon dealer item. |
bool RegisterFoodDealerItem(LitherarpShopConfig.FoodDealerItemEntry entry) | host | Adds a runtime food dealer item. |
bool OverrideShopEntityTab(LitherarpShopConfig.ShopEntityTabEntry entry, int priority = LitherarpAddonRegistryPriority.Default) | host | Replaces an entity shop tab by id. |
bool SuppressShopEntityTab(string id, int priority = LitherarpAddonRegistryPriority.Default) | host | Suppresses an entity shop tab by id. |
bool OverrideShopEntityItem(LitherarpShopConfig.ShopEntityItemEntry entry, int priority = LitherarpAddonRegistryPriority.Default) | host | Replaces an entity shop item by id. |
bool SuppressShopEntityItem(string id, int priority = LitherarpAddonRegistryPriority.Default) | host | Suppresses an entity shop item by id. |
bool OverrideWeaponDealerItem(LitherarpShopConfig.WeaponDealerItemEntry entry, int priority = LitherarpAddonRegistryPriority.Default) | host | Replaces a weapon dealer item by id. |
bool SuppressWeaponDealerItem(string id, int priority = LitherarpAddonRegistryPriority.Default) | host | Suppresses a weapon dealer item by id. |
bool OverrideFoodDealerItem(LitherarpShopConfig.FoodDealerItemEntry entry, int priority = LitherarpAddonRegistryPriority.Default) | host | Replaces a food dealer item by id. |
bool SuppressFoodDealerItem(string id, int priority = LitherarpAddonRegistryPriority.Default) | host | Suppresses a food dealer item by id. |
bool RegisterNpc(LitherarpNpcConfig.NpcConfigEntry entry) | host | Registers and immediately spawns a runtime NPC. |
bool RegisterNpcKind(string kind, Func<Scene, LitherarpNpcDefinition, GameObject?> builder) | host | Registers a custom configured NPC type. |
bool OverrideNpc(string npcId, Func<Scene, LitherarpNpcDefinition, GameObject?> builder) | host | Replaces or suppresses one configured NPC by id. |
bool OverrideNpcType(string npcType, Func<Scene, LitherarpNpcDefinition, GameObject?> builder) | host | Replaces or suppresses every configured NPC of a type. |
bool DecorateNpc(string npcId, Action<GameObject, LitherarpNpcDefinition> decorator) | host | Mutates one NPC after it is built. |
bool DecorateNpcType(string npcType, Action<GameObject, LitherarpNpcDefinition> decorator) | host | Mutates every NPC of a type after build. |
bool RegisterClothing(LitherarpClothingConfig.ExtraClothingConfig entry) | host | Adds a runtime clothing catalog entry. |
bool OverrideClothing(LitherarpClothingConfig.ExtraClothingConfig entry, int priority = LitherarpAddonRegistryPriority.Default) | host | Replaces a clothing entry by resource path. |
bool SuppressClothing(string resourcePath, int priority = LitherarpAddonRegistryPriority.Default) | host | Suppresses a clothing entry by resource path. |
bool RegisterChatCommand(string commandName, string description, Action<LitherarpChatCommandInvocation> handler, bool allowWhileRestricted = false) | host | Registers a slash or bang command. The slash form is published to autocomplete with a default /name usage. Built-in names remain reserved. |
bool RegisterChatCommand(string commandName, string description, LitherarpChatCommandOptions options, Action<LitherarpChatCommandInvocation> handler) | host | Registers a command with explicit usage, suggestion visibility, restriction and addon-scoped permission policy. |
Services and networking
| Member | Realm | Contract |
|---|---|---|
bool RegisterService<T>(string name, T service, string version = "1.0.0") where T : class | both | Publishes a typed in-process service owned by this addon. |
bool TryGetService<T>(string ownerAddonId, string name, out T? service, out string version) where T : class | both | Gets a typed service and its version. |
bool TryGetService<T>(string ownerAddonId, string name, string versionConstraint, out T? service, out string version) where T : class | both | Gets a typed service only when its version satisfies the constraint. |
bool SubscribeAddonEvent(string publisherAddonId, string topic, Action<JsonElement> handler, int priority = 0) | both | Subscribes to a namespaced local JSON event. |
bool PublishAddonEvent(string topic, object? payload = null) | both | Publishes a local JSON event under this addon's id. |
bool RegisterNetworkMessage(string messageName, LitherarpAddonNetworkDirection direction, Action<LitherarpAddonNetworkMessageContext> handler, LitherarpAddonNetworkOptions? options = null) | both | Registers a validated network message handler. |
bool SendNetworkToHost(string messageName, object? payload = null) | client | Serializes and sends one message to the host handler. A listen host uses the same validation path. |
bool SendNetworkToPlayer(LitherarpPlayer? player, string messageName, object? payload = null) | host | Sends one message to the selected player's client handler. |
bool SendNetworkToConnection(Connection? connection, string messageName, object? payload = null) | host | Sends to an active connection before or after its player pawn exists. |
bool BroadcastNetwork(string messageName, object? payload = null) | host | Broadcasts one message to every client handler. |
Storage, localization and policy
| Member | Realm | Contract |
|---|---|---|
LitherarpAddonDataResult<T> LoadServerData<T>(int currentVersion, string key = "state", Func<int, JsonElement, T>? migrate = null) where T : class, new() | host | Loads a named versioned server document and optionally migrates it. |
bool SaveServerData<T>(T data, int schemaVersion = 1, string key = "state", bool synchronous = false) where T : class | host | Saves a named versioned server document. |
LitherarpAddonDataResult<T> LoadWorldData<T>(int currentVersion, string key = "state", string? worldId = null, Func<int, JsonElement, T>? migrate = null) where T : class, new() | host | Loads a named versioned map or world document. |
bool SaveWorldData<T>(T data, int schemaVersion = 1, string key = "state", string? worldId = null, bool synchronous = false) where T : class | host | Saves a named versioned map or world document. |
IReadOnlyList<string> ListServerDataKeys() | host | Lists normalized server document keys. |
IReadOnlyList<string> ListWorldDataKeys(string? worldId = null) | host | Lists normalized document keys for a map or world. |
bool FlushAddonData() | host | Synchronously flushes cached player, server and world documents. |
T LoadPlayerData<T>(long steamId) where T : class, new() | host | Loads the legacy one-blob-per-player document. |
LitherarpAddonDataResult<T> LoadPlayerData<T>(long steamId, int currentVersion, string key = "state", Func<int, JsonElement, T>? migrate = null) where T : class, new() | host | Loads a named versioned player document. |
bool SavePlayerData<T>(long steamId, T data, bool synchronous = false) where T : class | host | Saves the legacy player blob. |
bool SavePlayerData<T>(long steamId, T data, int schemaVersion, string key = "state", bool synchronous = false) where T : class | host | Saves a named versioned player document. |
void RegisterLocalization(string language, IReadOnlyDictionary<string, string> entries) | host | Registers runtime language entries and syncs them to clients. |
bool RegisterWhitelistAdmissionHandler(Action<LitherarpAddonAdmissionRequest> handler, int priority = LitherarpAddonRegistryPriority.Default) | host | Registers one capability-gated whitelist-stage handler. |
bool RegisterPermissionNode(string node, string label, string description = "") | both | Declares addon.<id>.<node> for operator discovery. |
bool HasPermission(LitherarpPlayer? player, string node) | both | Checks the local permission view for addon.<id>.<node>. Client checks are suitable for presentation; the host check remains authoritative for mutations. |
bool EvictProperty(string identifier, float refundFraction, out string message) | host | Releases a property group, door or penthouse identifier. |
bool EvictProperty(DoorAccess access, float refundFraction, out string message) | host | Releases a concrete door property. |
int EvictAllProperties(long ownerSteamId, float refundFraction, out int totalRefund) | host | Releases all properties for a Steam id. |