From 99691686165ea046113c83b93aa081d25482a221 Mon Sep 17 00:00:00 2001 From: atampy25 <24306974+atampy25@users.noreply.github.com> Date: Sat, 3 Dec 2022 13:33:14 +1000 Subject: [PATCH] Fix documentation for `addClientSideModDependency` and add new `modIsInstalled` function with more sensible naming and semantics (#51) * Fix documentation and add new function Signed-off-by: atampy25 <24306974+atampy25@users.noreply.github.com> Co-authored-by: Reece Dunham --- components/controller.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/components/controller.ts b/components/controller.ts index 65876b25..12715e0c 100644 --- a/components/controller.ts +++ b/components/controller.ts @@ -427,11 +427,13 @@ export class Controller { } /** - * Adds a dependency on a client side mod through the Simple Mod Framework. - * See the cookbook for a usage example! + * You should use {@link modIsInstalled} instead! + * + * Returns whether a mod is UNAVAILABLE. * * @param modId The mod's ID. - * @returns If the mod is available. You will probably want to abort plugin initialization if false is returned. + * @returns If the mod is unavailable. You should probably abort initialization if true is returned. Also returns true if the `overrideFrameworkChecks` flag is set. + * @deprecated since v5.5.0 */ public addClientSideModDependency(modId: string): boolean { return ( @@ -440,6 +442,19 @@ export class Controller { ) } + /** + * Returns whether a mod is available and installed. + * + * @param modId The mod's ID. + * @returns If the mod is available (or the `overrideFrameworkChecks` flag is set). You should probably abort initialisation if false is returned. + */ + public modIsInstalled(modId: string): boolean { + return ( + this.installedMods.includes(modId) || + getFlag("overrideFrameworkChecks") === true + ) + } + /** * Starts the service and loads in all contracts. *