@nativewrappers/common 0.0.62 → 0.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Command.js +18 -4
- package/Kvp.d.ts +1 -1
- package/package.json +1 -2
package/Command.js
CHANGED
|
@@ -3,6 +3,23 @@ const commands = [];
|
|
|
3
3
|
if (GlobalData.IS_SERVER) {
|
|
4
4
|
on("playerJoining", () => emitNet("chat:addSuggestions", source, commands));
|
|
5
5
|
}
|
|
6
|
+
function registerCommand(name, commandHandler, restricted) {
|
|
7
|
+
if (Array.isArray(name))
|
|
8
|
+
return name.forEach((name) => registerCommand(name, commandHandler, restricted));
|
|
9
|
+
RegisterCommand(name, commandHandler, !!restricted);
|
|
10
|
+
if (GlobalData.IS_CLIENT)
|
|
11
|
+
return;
|
|
12
|
+
const ace = `command.${name}`;
|
|
13
|
+
if (typeof restricted === "string") {
|
|
14
|
+
if (IsPrincipalAceAllowed(restricted, ace))
|
|
15
|
+
return;
|
|
16
|
+
return ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(restricted)) {
|
|
19
|
+
restricted.forEach((principal) => !IsPrincipalAceAllowed(principal, ace) &&
|
|
20
|
+
ExecuteCommand(`add_ace ${restricted} ${ace} allow`));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
6
23
|
export class Command {
|
|
7
24
|
name;
|
|
8
25
|
help;
|
|
@@ -12,12 +29,9 @@ export class Command {
|
|
|
12
29
|
this.name = name;
|
|
13
30
|
this.help = help;
|
|
14
31
|
this.params = params;
|
|
15
|
-
const commandHandler = (source, args, raw) => this.call(source, args, raw);
|
|
16
32
|
this.#handler = handler;
|
|
17
33
|
this.name = `/${name}`;
|
|
18
|
-
|
|
19
|
-
? RegisterCommand(name, commandHandler, !!restricted)
|
|
20
|
-
: name.forEach((name) => RegisterCommand(name, commandHandler, !!restricted));
|
|
34
|
+
registerCommand(name, (source, args, raw) => this.call(source, args, raw), restricted);
|
|
21
35
|
if (params) {
|
|
22
36
|
params.forEach((param) => {
|
|
23
37
|
if (param.type)
|
package/Kvp.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class Kvp<Schema extends KvpSchema> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns the value associated with a key as a parsed JSON string.
|
|
21
21
|
*/
|
|
22
|
-
getJson<K extends string, O = KvpObject<K>>(key: K extends ValidJsonKey<O> ? K : never): O extends string ? Schema[O] : null;
|
|
22
|
+
getJson<K extends string, O = KvpObject<K>>(key: K extends ValidJsonKey<O> ? K : never): (O extends string ? Schema[O] : null) | null;
|
|
23
23
|
/**
|
|
24
24
|
* Sets the value associated with a key as a number.
|
|
25
25
|
* @param async set the value using an async operation.
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativewrappers/common",
|
|
3
3
|
"description": "Native wrappers and utilities for use with Cfx.re's scripting runtimes.",
|
|
4
|
-
"author": "Remco Troost <d0p3t>",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.64",
|
|
8
7
|
"repository": {
|
|
9
8
|
"type": "git",
|
|
10
9
|
"url": "https://github.com/nativewrappers/nativewrappers.git"
|