Skip to content

Commit

Permalink
Fix documentation for addClientSideModDependency and add new `modIs…
Browse files Browse the repository at this point in the history
…Installed` 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 <me@rdil.rocks>
  • Loading branch information
atampy25 and RDIL committed Dec 3, 2022
1 parent a86e27c commit 9969168
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions components/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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.
*
Expand Down

0 comments on commit 9969168

Please sign in to comment.