Context API

Reference every public member exposed by LitherarpAddonContext, grouped by responsibility and realm.

Identity and lifecycle ownership

MemberRealmContract
string AddonId { get; }bothNormalized owner id used for namespacing and teardown.
string PackageIdent { get; }bothPackage ident selected by the operator.
bool IsHost { get; }bothTrue for an authoritative host context.
bool HasCapability(string capability)bothChecks the effective requested and operator-granted capability set.
Scene Scene { get; }bothScene associated with this activation. An exceptional early client activation can receive a null scene reference, so validate it before use.
bool IsWorldReady { get; }hostTrue after map and persistent-world bootstrap completed.
bool IsClientWorldReady { get; }clientTrue 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)hostRuns now when ready, or registers a tracked one-shot callback. Returns false on invalid realm or callback.
bool RunWhenClientWorldReady(Action<Scene> callback)clientRuns 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)bothWrites an addon-prefixed information log.
void Warning(string message)bothWrites an addon-prefixed warning log.
bool RecordLog(LitherarpLogCategory category, string message, string detail = "", LitherarpPlayer? actor = null, LitherarpPlayer? target = null)hostAdds 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)bothDisposes 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)bothRegisters cleanup in reverse order. The context retains at most 4,096 actions; late or surplus cleanup runs immediately.
GameObject? TrackGameObject(GameObject? gameObject)bothDestroys a valid tracked object on normal addon disable.
T? TrackComponent<T>(T? component) where T : ComponentbothDestroys a valid tracked component on normal addon disable.
CancellationTokenSource TrackCancellation(CancellationTokenSource cancellation)bothCancels 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

MemberRealmContract
LitherarpAddonConfigHandle? RegisterConfigFile(string displayName, string defaultJson, Action? onReloaded = null)hostRegisters configs/addons/<id>.json, Admin Console editing and hot reload. The callback invalidates the public snapshot.
void RegisterPublicSnapshotSection(Func<object> provider)hostPublishes one JSON object in the regular public config snapshot.
bool InvalidatePublicSnapshot()hostMarks public config state dirty after provider data changes.
bool TryGetPublicSection(out JsonElement section)bothReads this addon's last applied public section. On the host it reads the provider value indirectly after synchronization.
bool SetPlayerSection(LitherarpPlayer? player, object? value)hostTargets one player's client with a JSON object. The UTF-8 limit is 8,000 bytes.
bool TryGetMyPlayerSection(out JsonElement section)clientReads the local player's private section.
int PlayerSectionRevision { get; }clientRevision counter for cheap UI change detection.
bool ApplyStatusEffect(LitherarpPlayer? target, string effectId, float durationSeconds, float tickIntervalSeconds, Action<LitherarpStatusEffect>? onTick, Action<LitherarpStatusEffect>? onExpired = null)hostApplies or refreshes a namespaced timed effect.
bool ApplyDamageOverTime(LitherarpPlayer? target, string effectId, float damagePerTick, float durationSeconds, float tickIntervalSeconds = 1f)hostApplies periodic damage through the normal player damage pipeline.
bool RemoveStatusEffect(LitherarpPlayer? target, string effectId)hostRemoves this addon's effect from a player.
bool HasStatusEffect(LitherarpPlayer? target, string effectId)hostTests this addon's effect on a player.
Returned or callback typePublic contract
LitherarpAddonConfigHandlePath, GetRawJson() and Deserialize<T>(). Reads always use the latest successful reload; deserialization failure returns a fresh T.
LitherarpStatusEffectTarget, 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.

MemberRealmContract
void RegisterScreenPanel(string objectName, int zIndex, Func<GameObject, Component> attach)clientRegisters a tracked persistent screen panel.
bool RegisterAdminPanel(string panelId, string label, string icon, string permissionNode, string description, RenderFragment content, int order = 0)clientRegisters an Addon Tools page with an addon permission node.
bool SetCorePanelEnabled<T>(bool enabled) where T : ComponentclientHides 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)clientRegisters a native phone app.
bool OverrideCorePhoneApp(LitherarpPhoneApp app, string? label = null, string? icon = null, int? order = null, RenderFragment? content = null, Action<LitherarpPhoneAppInputContext>? inputHandler = null)clientAdds a reversible metadata, content or input override layer to a core phone app.
bool SetCorePhoneAppEnabled(LitherarpPhoneApp app, bool enabled)clientHides or restores a core phone app with tracked teardown.
bool RegisterToolMode<T>(string permissionNode = "") where T : ToolModebothRegisters a Toolgun mode using its type-derived id.
bool RegisterToolMode<T>(string modeId, string permissionNode) where T : ToolModebothRegisters a Toolgun mode under an explicit id.
bool RegisterToolAction(string modeId, string action, Action<LitherarpAddonToolActionContext> handler)hostRegisters 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)bothRegisters a code-defined item for this realm.
bool OverrideItem(LitherarpItemDefinition definition, int priority = LitherarpAddonRegistryPriority.Default)bothAdds a reversible item replacement layer.
bool SuppressItem(string itemId, int priority = LitherarpAddonRegistryPriority.Default)bothAdds a reversible item suppression layer.
bool RegisterConsumable(string itemId, string useLabel, string icon, Func<LitherarpAddonConsumableUseContext, bool> handler, Func<LitherarpItemStack, bool>? clientCanUse = null)bothRegisters 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)bothAdds stock to the native weed or meth dealer.
bool RegisterJob(LitherarpJobsConfig.JobConfigEntry entry)hostAdds a runtime job and syncs the resolved registry.
bool OverrideJob(LitherarpJobsConfig.JobConfigEntry entry, int priority = LitherarpAddonRegistryPriority.Default)hostAdds a reversible job replacement layer.
bool SuppressJob(string jobId, int priority = LitherarpAddonRegistryPriority.Default)hostAdds a reversible job suppression layer.
bool RegisterShopEntityTab(LitherarpShopConfig.ShopEntityTabEntry entry)hostAdds a runtime entity shop tab.
bool RegisterShopEntityItem(LitherarpShopConfig.ShopEntityItemEntry entry)hostAdds a runtime entity shop item.
bool RegisterWeaponDealerItem(LitherarpShopConfig.WeaponDealerItemEntry entry)hostAdds a runtime weapon dealer item.
bool RegisterFoodDealerItem(LitherarpShopConfig.FoodDealerItemEntry entry)hostAdds a runtime food dealer item.
bool OverrideShopEntityTab(LitherarpShopConfig.ShopEntityTabEntry entry, int priority = LitherarpAddonRegistryPriority.Default)hostReplaces an entity shop tab by id.
bool SuppressShopEntityTab(string id, int priority = LitherarpAddonRegistryPriority.Default)hostSuppresses an entity shop tab by id.
bool OverrideShopEntityItem(LitherarpShopConfig.ShopEntityItemEntry entry, int priority = LitherarpAddonRegistryPriority.Default)hostReplaces an entity shop item by id.
bool SuppressShopEntityItem(string id, int priority = LitherarpAddonRegistryPriority.Default)hostSuppresses an entity shop item by id.
bool OverrideWeaponDealerItem(LitherarpShopConfig.WeaponDealerItemEntry entry, int priority = LitherarpAddonRegistryPriority.Default)hostReplaces a weapon dealer item by id.
bool SuppressWeaponDealerItem(string id, int priority = LitherarpAddonRegistryPriority.Default)hostSuppresses a weapon dealer item by id.
bool OverrideFoodDealerItem(LitherarpShopConfig.FoodDealerItemEntry entry, int priority = LitherarpAddonRegistryPriority.Default)hostReplaces a food dealer item by id.
bool SuppressFoodDealerItem(string id, int priority = LitherarpAddonRegistryPriority.Default)hostSuppresses a food dealer item by id.
bool RegisterNpc(LitherarpNpcConfig.NpcConfigEntry entry)hostRegisters and immediately spawns a runtime NPC.
bool RegisterNpcKind(string kind, Func<Scene, LitherarpNpcDefinition, GameObject?> builder)hostRegisters a custom configured NPC type.
bool OverrideNpc(string npcId, Func<Scene, LitherarpNpcDefinition, GameObject?> builder)hostReplaces or suppresses one configured NPC by id.
bool OverrideNpcType(string npcType, Func<Scene, LitherarpNpcDefinition, GameObject?> builder)hostReplaces or suppresses every configured NPC of a type.
bool DecorateNpc(string npcId, Action<GameObject, LitherarpNpcDefinition> decorator)hostMutates one NPC after it is built.
bool DecorateNpcType(string npcType, Action<GameObject, LitherarpNpcDefinition> decorator)hostMutates every NPC of a type after build.
bool RegisterClothing(LitherarpClothingConfig.ExtraClothingConfig entry)hostAdds a runtime clothing catalog entry.
bool OverrideClothing(LitherarpClothingConfig.ExtraClothingConfig entry, int priority = LitherarpAddonRegistryPriority.Default)hostReplaces a clothing entry by resource path.
bool SuppressClothing(string resourcePath, int priority = LitherarpAddonRegistryPriority.Default)hostSuppresses a clothing entry by resource path.
bool RegisterChatCommand(string commandName, string description, Action<LitherarpChatCommandInvocation> handler, bool allowWhileRestricted = false)hostRegisters 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)hostRegisters a command with explicit usage, suggestion visibility, restriction and addon-scoped permission policy.

Services and networking

MemberRealmContract
bool RegisterService<T>(string name, T service, string version = "1.0.0") where T : classbothPublishes a typed in-process service owned by this addon.
bool TryGetService<T>(string ownerAddonId, string name, out T? service, out string version) where T : classbothGets a typed service and its version.
bool TryGetService<T>(string ownerAddonId, string name, string versionConstraint, out T? service, out string version) where T : classbothGets a typed service only when its version satisfies the constraint.
bool SubscribeAddonEvent(string publisherAddonId, string topic, Action<JsonElement> handler, int priority = 0)bothSubscribes to a namespaced local JSON event.
bool PublishAddonEvent(string topic, object? payload = null)bothPublishes a local JSON event under this addon's id.
bool RegisterNetworkMessage(string messageName, LitherarpAddonNetworkDirection direction, Action<LitherarpAddonNetworkMessageContext> handler, LitherarpAddonNetworkOptions? options = null)bothRegisters a validated network message handler.
bool SendNetworkToHost(string messageName, object? payload = null)clientSerializes 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)hostSends one message to the selected player's client handler.
bool SendNetworkToConnection(Connection? connection, string messageName, object? payload = null)hostSends to an active connection before or after its player pawn exists.
bool BroadcastNetwork(string messageName, object? payload = null)hostBroadcasts one message to every client handler.

Storage, localization and policy

MemberRealmContract
LitherarpAddonDataResult<T> LoadServerData<T>(int currentVersion, string key = "state", Func<int, JsonElement, T>? migrate = null) where T : class, new()hostLoads 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 : classhostSaves 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()hostLoads 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 : classhostSaves a named versioned map or world document.
IReadOnlyList<string> ListServerDataKeys()hostLists normalized server document keys.
IReadOnlyList<string> ListWorldDataKeys(string? worldId = null)hostLists normalized document keys for a map or world.
bool FlushAddonData()hostSynchronously flushes cached player, server and world documents.
T LoadPlayerData<T>(long steamId) where T : class, new()hostLoads 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()hostLoads a named versioned player document.
bool SavePlayerData<T>(long steamId, T data, bool synchronous = false) where T : classhostSaves the legacy player blob.
bool SavePlayerData<T>(long steamId, T data, int schemaVersion, string key = "state", bool synchronous = false) where T : classhostSaves a named versioned player document.
void RegisterLocalization(string language, IReadOnlyDictionary<string, string> entries)hostRegisters runtime language entries and syncs them to clients.
bool RegisterWhitelistAdmissionHandler(Action<LitherarpAddonAdmissionRequest> handler, int priority = LitherarpAddonRegistryPriority.Default)hostRegisters one capability-gated whitelist-stage handler.
bool RegisterPermissionNode(string node, string label, string description = "")bothDeclares addon.<id>.<node> for operator discovery.
bool HasPermission(LitherarpPlayer? player, string node)bothChecks 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)hostReleases a property group, door or penthouse identifier.
bool EvictProperty(DoorAccess access, float refundFraction, out string message)hostReleases a concrete door property.
int EvictAllProperties(long ownerSteamId, float refundFraction, out int totalRefund)hostReleases all properties for a Steam id.