forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
72 lines (72 loc) · 2.59 KB
/
index.d.ts
File metadata and controls
72 lines (72 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { CommandResult, Dimension, Entity, Player } from "@minecraft/server";
/**
* Main class for custom command functions, with the player that execute
* this command with additional arguments split in an iterable iterator
* string array.
*/
export declare class Command {
private __player;
argv: IterableIterator<string>;
get player(): Player;
get argv0(): string;
constructor(argv: string[], player: Player);
}
/**
* Contains a method that lets you run console commands within
* Minecraft.
*/
export declare class Commands {
/**
* @remarks
* Runs a particular command synchronously from the context.
* @param commandString
* Command to run. Note that command strings should not start
* with slash.
* @param target
* Target to be used as context for the command to run
* within.
* @returns
* For commands that return data, returns a CommandResult with
* an indicator of command results.
* @throws This function can throw errors.
*/
static run(commandString: string, target?: Dimension | Entity): CommandResult;
/**
* @remarks
* Runs a particular command asynchronously from the context.
* Where possible - and especially for
* long-running operations - you should use runCommandAsync
* over runCommand.
* @param commandString
* Command to run. Note that command strings should not start
* with slash.
* @param target
* Target to be used as context for the command to run
* within.
* @returns
* For commands that return data, returns a CommandResult with
* an indicator of command results.
* @throws This function can throw errors.
*/
static runAsync(commandString: string, target?: Dimension | Entity): Promise<CommandResult>;
/**
* @remarks
* Registers a new custom command. This command will become
* available in Minecraft via [prefix][command].
* @param prefix
* The prefix of this specific command. (Case sensitive)
* @param command
* Name of this specific command. (Case sensitive)
* @param commandFunction
* Implementation of the command function.
* @throws
* This function can throw error: You are not allow to register a new slash command.
* @example example1.js
* ```typescript
* Commands.register("!", "test", function (arg) {
* arg.player.runCommandAsync(`say ${arg.argv0} ${JSON.stringify([...arg.argv])}`);
* });
* ```
*/
static register(prefix: string, command: string, commandFunction: (arg: Command) => void): void;
}