Skip to content

Commit 9f090df

Browse files
Enhanced JSDoc entries
1 parent f772f68 commit 9f090df

File tree

1 file changed

+70
-33
lines changed

1 file changed

+70
-33
lines changed

src/index.ts

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,46 @@
55
*/
66
import stripJsonComments from "strip-json-comments";
77

8+
/**
9+
* Settings for the framework configuration.
10+
* Are loaded from framework.json
11+
*/
812
export type FrameworkConfig = {
13+
/**
14+
* Whether to automatically detect the framework
15+
*/
916
AutoDetect: boolean;
17+
/**
18+
* The framework to use
19+
*/
1020
Framework: "None" | "QBCore" | "ESX Legacy" | "ESX Infinity" | "Custom";
21+
/**
22+
* The event to listen to for ESX Infinity
23+
*/
1124
ESXEvent: string;
25+
/**
26+
* The resource that exports the custom functions
27+
*/
1228
ExportResource: string;
1329
};
1430

31+
/**
32+
* Framework class
33+
* Used to interact with the framework
34+
*/
1535
export class Framework {
36+
/**
37+
* Local instance of the framework config
38+
*/
1639
private config: FrameworkConfig;
40+
/**
41+
* Local instance of the framework object
42+
* This is the object that is returned by the framework
43+
* It is used to interact with the framework
44+
* It is initialized in the constructor
45+
* It is null if the framework is not initialized and just an empty object if 'None' or 'Custom' is selected
46+
* Due to the nature of the framework, this object is of type 'any' since the type is different for each framework
47+
*/
1748
private framework: any;
1849

1950
constructor() {
@@ -79,32 +110,38 @@ export class Framework {
79110

80111
/**
81112
* Checks if the framework is initialized
82-
* @returns {boolean} whether the framework is initialized
113+
* @returns {boolean} Whether the framework is initialized
83114
*/
84115
public isInitialized(): boolean {
85116
return !!this.framework;
86117
}
87118

88119
/**
89120
* Returns the raw framework object
90-
* @returns {any} framework
121+
* This is the object that is returned by the framework
122+
* It is any since the type is different for each framework
123+
* It is null if the framework is not initialized and just an empty object if 'None' or 'Custom' is selected
124+
* @returns {any} Raw framework object
91125
*/
92126
public getFramework(): any {
93127
return this.framework;
94128
}
95129

96130
/**
97131
* Returns the framework name
98-
* @returns {string} framework name
132+
* It matches the FrameworkConfig.Framework exactly
133+
* Note: This value is case sensitive
134+
* @returns {string} Name of the currently selected framework
99135
*/
100136
public getFrameworkName(): string {
101137
return this.config.Framework;
102138
}
103139

104140
/**
105141
* Get the wallet money of a player
106-
* @param player player id
107-
* @returns {number} wallet money
142+
* Note: This function only uses the default money system of the frameworks and may not work with custom money systems (for example those who utilize items as money)
143+
* @param player Server ID of the player
144+
* @returns {number} The wallet money of the player
108145
*/
109146
public getPlayerWalletMoney(player: number): number {
110147
switch (this.config.Framework) {
@@ -126,9 +163,9 @@ export class Framework {
126163

127164
/**
128165
* Get the money of a specific account of a player
129-
* @param player player id
130-
* @param account account name (e.g. bank)
131-
* @returns {number} account money
166+
* @param player Server ID of the player
167+
* @param account Name of the account (e.g. bank)
168+
* @returns {number} Amount of money in the account
132169
*/
133170
public getPlayerAccountMoney(player: number, account: string): number {
134171
switch (this.config.Framework) {
@@ -159,9 +196,9 @@ export class Framework {
159196

160197
/**
161198
* Add money to the wallet of a player
162-
* @param player player id
163-
* @param amount amount to add
164-
* @returns {void} void
199+
* Note: This function only uses the default money system of the frameworks and may not work with custom money systems (for example those who utilize items as money)
200+
* @param player Server ID of the player
201+
* @param amount Amount to add
165202
*/
166203
public addPlayerWalletMoney(player: number, amount: number): void {
167204
switch (this.config.Framework) {
@@ -191,9 +228,9 @@ export class Framework {
191228

192229
/**
193230
* Remove money from the wallet of a player
194-
* @param player player id
195-
* @param amount amount to remove
196-
* @returns {void} void
231+
* Note: This function only uses the default money system of the frameworks and may not work with custom money systems (for example those who utilize items as money)
232+
* @param player Server ID of the player
233+
* @param amount Amount to remove
197234
*/
198235
public removePlayerWalletMoney(player: number, amount: number): void {
199236
switch (this.config.Framework) {
@@ -223,10 +260,9 @@ export class Framework {
223260

224261
/**
225262
* Add money to a specific account of a player
226-
* @param player player id
227-
* @param account account name (e.g. bank)
228-
* @param amount amount to add
229-
* @returns {void} void
263+
* @param player Server ID of the player
264+
* @param account Name of the account (e.g. bank)
265+
* @param amount Amount to add
230266
*/
231267
public addPlayerAccountMoney(player: number, account: string, amount: number): void {
232268
switch (this.config.Framework) {
@@ -257,10 +293,9 @@ export class Framework {
257293

258294
/**
259295
* Remove money from a specific account of a player
260-
* @param player player id
261-
* @param account account name (e.g. bank)
262-
* @param amount amount to remove
263-
* @returns {void} void
296+
* @param player Server ID of the player
297+
* @param account Name of the account (e.g. bank)
298+
* @param amount Amount to remove
264299
*/
265300
public removePlayerAccountMoney(player: number, account: string, amount: number): void {
266301
switch (this.config.Framework) {
@@ -291,10 +326,10 @@ export class Framework {
291326

292327
/**
293328
* Add an item to the inventory of a player
294-
* @param player player id
295-
* @param item item name
296-
* @param amount amount to add
297-
* @returns {void} void
329+
* Note: This function only uses the default inventory system of the frameworks and may not work with custom inventory systems
330+
* @param player Server ID of the player
331+
* @param item Name of the item to add
332+
* @param amount Amount of the item to add
298333
*/
299334
public addPlayerInventoryItem(player: number, item: string, amount: number): void {
300335
if (amount <= 0) {
@@ -331,10 +366,10 @@ export class Framework {
331366

332367
/**
333368
* Remove an item from the inventory of a player
334-
* @param player player id
335-
* @param item item name
336-
* @param amount amount to remove
337-
* @returns {void} void
369+
* Note: This function only uses the default inventory system of the frameworks and may not work with custom inventory systems
370+
* @param player Server ID of the player
371+
* @param item Name of the item to remove
372+
* @param amount Amount of the item to remove
338373
*/
339374
public removePlayerInventoryItem(player: number, item: string, amount: number): void {
340375
if (amount <= 0) {
@@ -371,9 +406,11 @@ export class Framework {
371406

372407
/**
373408
* Get the amount of an item in the inventory of a player
374-
* @param player player id
375-
* @param item item name
376-
* @returns {number} amount of item
409+
* Returns 0 if the item is not in the inventory
410+
* Note: This function only uses the default inventory system of the frameworks and may not work with custom inventory systems
411+
* @param player Server ID of the player
412+
* @param item The name of the item to get the amount of
413+
* @returns {number} Amount of the item in the inventory
377414
*/
378415
public getPlayerInventoryItemCount(player: number, item: string): number {
379416
switch (this.config.Framework) {

0 commit comments

Comments
 (0)