forked from dzx-dzx/lxl-dts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lxl.d.ts
537 lines (502 loc) · 18.9 KB
/
lxl.d.ts
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
declare enum DimensionID {
Unknown = -1,
Overworld,
Nether,
End
}
declare enum DirectionID {
North,
East,
South,
West
}
declare enum GameModeID {
Survival,
Creative,
Adventure,
Spectator
}
declare enum MessageID {
Raw,
Chat,
Popup,
Tip,
Json
}
declare type PermissionID = 0 | 1 | 2 | 3 | 4
declare type Integer = number
declare type Float = number
declare enum Format {
Black = "§0",
DarkBlue = "§1",
DarkGreen = "§2",
DarkAqua = "§3",
DarkRed = "§4",
DarkPurple = "§5",
Gold = "§6",
Gray = "§7",
DarkGray = "§8",
Blue = "§9",
Green = "§a",
Aqua = "§b",
Red = "§c",
LightPurple = "§d",
Yellow = "§e",
White = "§f",
MinecoinGold = "§g",
Bold = "§l",
Italics = "§o",
Underline = "§n",
StrikeThrough = "§m",
Random = "§k",
Clear = "§r"
}
declare enum LogLevel {
Slient,
Fatal,
Error,
Warn,
Info,
Debug
}
declare interface IntPos {
x: Integer,
y: Integer,
z: Integer,
dim: string,
dimid: DimensionID
}
declare interface FloatPos {
x: Float,
y: Float,
z: Float,
dim: string,
dimid: DimensionID
}
declare interface Player {
readonly name: string,
readonly pos: FloatPos,
readonly blockPos: IntPos,
readonly realName: string,
readonly xuid: string,
readonly uuid: string,
readonly permLevel: PermissionID,
readonly gameMode: GameModeID,
readonly maxHealth: Integer,
readonly health: Integer,
readonly inAir: boolean,
readonly inWater: Boolean,
readonly sneaking: boolean,
readonly speed: Float,
readonly direction: DirectionID
isOp(): boolean
kick(msg?: string): boolean
disconnect(msg?: string): boolean
tell(msg: string, type?: MessageID): boolean
sendText(msg: string, type?: MessageID): boolean
runcmd(cmd: string): boolean
teleport(pos: IntPos | FloatPos): boolean
teleport(x: number, y: number, z: number, dimid: DimensionID): boolean
kill(): boolean
hurt(damage: Integer): boolean
setOnFire(time: Integer): boolean
rename(newname: string): boolean
getDevice(): Device
getHand(): Item
getOffHand(): Item
getInventory(): Container
getArmor(): Container
getEnderChest(): Container
giveItem(item: Item): boolean
clearItem(type: string): Integer
refreshItems(): boolean
refreshChunks(): boolean
setPermLevel(level: PermissionID): boolean
setGameMode(mode: GameModeID): boolean
addLevel(count: Integer): boolean
transServer(server: string, port: Integer): boolean
crash(): boolean
setSidebar(title: string, data: any, sortOrder: number): boolean
removeSidebar(): boolean
setBossBar(title: string, percent: Integer): boolean
removeBossBar(): boolean
getNbt(): NbtCompound
setNbt(nbt: NbtCompound): boolean
addTag(tag: string): boolean
removeTag(tag: string): boolean
hasTag(tag: string): boolean
getAllTags(): string[]
getAbilities(): any
getAttributes(): any[]
getScore(name: string): Integer
setScore(name: string, value: Integer): boolean
addScore(name: string, value: Integer): boolean
reduceScore(name: string, value: Integer): boolean
deleteScore(name: string): boolean
sendModalForm(title: string, content: string, button1: string, callback: (player: Player, result: 0 | 1 | undefined) => void): Integer | undefined
sendSimpleForm(title: string, content: string, buttons: string[], images: string[], callback: (player: Player, id: Integer | undefined) => void): Integer | undefined
sendCustomForm(json: string, callback: (player: Player, data: [undefined, ...any[]]) => void): Integer | undefined
sendForm(fm: SimpleForm, callback: (player: Player, id: Integer | undefined) => void): Integer | null
sendForm(fm: CustomForm, callback: (player: Player, data: any[] | undefined) => void): Integer | null
setExtraData(name: string, data: any): boolean
getExtraData(name: string): any
delExtraData(name: string): any
}
declare interface Block {
readonly name: string
readonly type: string
readonly id: Integer
readonly pos: IntPos
getNbt(): NbtCompound
setNbt(nbt: NbtCompound): boolean
getBlockState(): any
hasContainer(): boolean
getContainer(): Container
hasBlockEntity(): boolean
getBlockEntity(): BlockEntity | undefined
removeBlockEntity(): boolean
}
declare interface Device {
readonly ip: string
readonly avgPing: Integer
readonly avgPacketLoss: Float
readonly os: "Android" | "iOS" | "OSX" | "Amazon" | "GearVR" | "Hololens" | "Windows10" | "Win32" | "TVOS" | "PlayStation" | "Nintendo" | "Xbox" | "WindowsPhone" | "Unknown"
readonly clientId: string
}
declare interface Entity {
readonly name: string
readonly type: string
readonly id: Integer
readonly pos: FloatPos
readonly blockPos: IntPos
readonly maxHealth: Integer
readonly health: Integer
readonly inAir: boolean
readonly inWater: boolean
readonly speed: Float
teleport(pos: IntPos | FloatPos): boolean
teleport(x: Integer, y: Integer, z: Integer, dimid: DimensionID): boolean
kill(): boolean
hurt(damage: Integer): boolean
setOnFire(time: Integer): boolean
isPlayer(): boolean
toPlayer(): Player | undefined
getArmor(): Container
hasContainer(): boolean
getContainer(): Container
refreshItems(): boolean
addTag(tag: string): boolean
removeTag(tag: string): boolean
hasTag(tag: string): boolean
getAllTags(): string[]
getNbt(): NbtCompound
setNbt(nbt: NbtCompound): boolean
}
declare interface Item {
readonly name: string
readonly type: string
readonly id: Integer
readonly count: Integer
readonly aux: Integer
clone(): Item | undefined
setNull(): boolean
set(item: Item): boolean
setAux(item: Item, aux: Integer): boolean
getNbt(): NbtCompound
setNbt(nbt: NbtCompound): boolean
setLore(names: string[]): boolean
}
declare interface BlockEntity {
readonly pos: IntPos
readonly type: Integer
getNbt(): NbtCompound
setNbt(nbt: NbtCompound): boolean
getBlock(): Block
}
declare interface Container {
readonly size: Integer
readonly type: string
addItem(item: Item): boolean
addItemToFirstEmptySlot(item: Item): boolean
hasRoomFor(item: Item): boolean
getItem(index: Integer): Item
setItem(index: Integer, item: Item): boolean
getAllItems(): Item[]
removeAllItems(): boolean
isEmpty(): boolean
}
declare interface Objective {
readonly name: string
readonly displayName: string
getScore(target: Player | string): Integer
setScore(target: Player | string, score: Integer): Integer | undefined
addScore(target: Player | string, score: Integer): Integer | undefined
reduceScore(target: Player | string, score: Integer): Integer | undefined
deleteScore(target: Player | string): boolean
setDisplay(slot: "sidebar" | "belowname" | "list", sortOrder?: 0 | 1): boolean
}
declare interface nbt {
getType(): any
toString(space?: Integer): string
toSNBT(): string
toBinaryNBT(): ArrayBuffer
destroy(): boolean
}
declare interface NbtCompound extends nbt {
getKeys(): string[]
getTypeOf(key: string): any
setTag(key: string, tag: NbtCompound | NbtValue | NbtList): boolean
getTag(key: string): NbtCompound | NbtValue | NbtList
removeTag(key: string): NbtCompound
setEnd(key: string): NbtList
setByte(key: string, data: any): NbtList
setShort(key: string, data: any): NbtList
setInt(key: string, data: any): NbtList
setLong(key: string, data: any): NbtList
setFloat(key: string, data: any): NbtList
setDouble(key: string, data: any): NbtList
setString(key: string, data: any): NbtList
getData(key: string): NbtList | NbtCompound | undefined
toObject(): any
}
declare interface NbtValue extends nbt {
set(data: any): boolean
get(): any
}
declare interface NbtList extends nbt {
getSize(): Integer
getTypeOf(index: Integer): any
setTag(index: Integer, tag: NbtCompound | NbtValue | NbtList): boolean
getTag(index: Integer): NbtCompound | NbtValue | NbtList
addTag(tag: NbtCompound | NbtValue | NbtList): NbtList
removeTag(index: Integer): NbtList
setEnd(index: Integer): NbtList
setByte(index: Integer, data: any): NbtList
setShort(index: Integer, data: any): NbtList
setInt(index: Integer, data: any): NbtList
setLong(index: Integer, data: any): NbtList
setFloat(index: Integer, data: any): NbtList
setDouble(index: Integer, data: any): NbtList
setString(index: Integer, data: any): NbtList
getData(index: Integer): NbtList | NbtCompound | undefined
toArray(): any[]
}
declare interface SimpleForm {
setTitle(title: string): SimpleForm
setContent(content: string): SimpleForm
addButton(text: string, image?: string): SimpleForm
}
declare interface CustomForm {
setTitle(title: string): CustomForm
addLabel(text: string): CustomForm
addInput(title: string, placeholder?: string, _default?: string): CustomForm
addSwitch(title: string, _default?: boolean): CustomForm
addDropdown(title: string, items: string[], _default?: Integer): CustomForm
addSlider(title: string, min: Integer, max: Integer, step?: Integer, _default?: Integer): CustomForm
addStepSlider(title: string, items: string[], _default: Integer): CustomForm
}
declare interface Conf {
reload(): boolean
close(): boolean
getPath(): string
read(): string
write(content: string): boolean
}
declare interface JSONConf extends Conf {
init(name: string, _default: any): any
set(name: string, data: any): boolean
get(name: string, _default?: any): any
delete(name: string): boolean
}
declare interface INIConf extends Conf {
init(section: string, name: string, _default: Integer | Float | string | boolean): any
set(section: string, name: string, data: Integer | Float | string | boolean): boolean
getStr(section: string, name: string, _default?: string): string
getInt(section: string, name: string, _default?: Integer): Integer
getFloat(section: string, name: string, _default?: Float): Float
getBool(section: string, name: string, _default?: boolean): boolean
delete(section: string, name: string): boolean
}
declare interface DB {
set(name: string, data: any): boolean
get(name: string): any
delete(name: string): boolean
listKey(): string[]
close(): boolean
}
declare interface File {
readonly path: string
readonly absolutePath: string
readonly size: Integer
readSync(cnt: number): string | ArrayBuffer
readLineSync(): string | undefined
readAllSync(): string | ArrayBuffer | undefined
writeSync(str: string | ArrayBuffer): boolean
writeLineSync(str: string): boolean
read(cnt: number, callback: (result: string | ArrayBuffer | undefined) => void): boolean
readLine(callback: (result: string | undefined) => void): boolean
readAll(callback: (result: string | ArrayBuffer | undefined) => void): boolean
write(str: string | ArrayBuffer, callback: (result: string | ArrayBuffer | undefined) => void): boolean
writeLine(str: string, callback: (result: string | undefined) => void): boolean
seekTo(pos: number, isRelative: boolean): boolean
setSize(size: number): boolean
close(): boolean
flush(): boolean
errorCode(): Integer
clear(): boolean
createDir(dir: string): boolean
mkdir(dir: string): boolean
delete(path: string): boolean
exists(path: string): boolean
copy(from: string, to: string): boolean
move(from: string, to: string): boolean
rename(from: string, to: string): boolean
getFileSize(path: string): Integer
checkIsDir(path: string): boolean
getFilesList(dir: string): string[]
}
declare interface WSClient {
readonly status: any
connect(target: string): boolean
send(msg: string | ArrayBuffer): boolean
listen(event: "onTextReceived", callback: (msg: string) => void): boolean
listen(event: "onBinaryReceived", callback: (data: ArrayBuffer) => void): boolean
listen(event: "onError", callback: (msg: string) => void): boolean
listen(event: "onLostConnection", callback: (code: Integer) => void): boolean
close(): boolean
shutdown(): boolean
errorCode(): Integer
}
declare function log(...args: any[]): void
declare function colorLog(color: string, ...args: any[]): void
declare function setTimeout(func: () => void, msec: Integer): Integer | undefined
declare function setTimeout(code: string, msec: Integer): Integer | undefined
declare function setInterval(code: string, msec: Integer): Integer | undefined
declare function clearInterval(taskid: Integer): boolean | undefined
declare namespace mc {
function newIntPos(x: Integer, y: Integer, z: Integer, dimid: DimensionID): IntPos
function newFloatPos(x: Float, y: Float, z: Float, dimid: DimensionID): FloatPos
function runcmd(cmd: string): boolean
function runcmdEx(cmd: string): { success: boolean, output: string }
function regPlayerCmd(cmd: string, description: string, callback: (player: Player, args: string[]) => void, level: PermissionID): boolean
function regConsoleCmd(cmd: string, description: string, callback: (args: string[]) => void): boolean
function sendCmdOutput(output: string): boolean
function getPlayer(info: string): Player | undefined
function getOnlinePlayers(): Player[]
function broadcast(msg: string, type?: MessageID): boolean
function getBlock(pos: IntPos): Block
function getBlock(x: Integer, y: Integer, z: Integer, dimid: DimensionID): Block
function setBlock(pos: IntPos, block: Block): boolean
function setblock(x: Integer, y: Integer, z: Integer, dimid: DimensionID, block: Block): Block
function spawnParticle(pos: IntPos | FloatPos, type: string): boolean
function spawnParticle(x: Integer, y: Integer, z: Integer, dimid: DimensionID, type: string): boolean
function spawnMob(name: string, pos: IntPos | FloatPos): Entity
function spawnMob<T extends Integer | Float>(name: string, x: T, y: T, z: T, dimid: DimensionID): Entity | undefined
function explode(pos: IntPos | FloatPos, source: Entity | undefined, power: Float, range: Float, isDestroy: boolean, isFire: boolean): boolean
function explode<T extends Integer | Float>(x: T, y: T, z: T, dimid: DimensionID, source: Entity | undefined, power: Float, range: Float, isDestroy: boolean, isFire: boolean): boolean
function newItem(name: string, count: Integer): Item | undefined
function newItem(nbt: NbtCompound): Item | null
function spawnItem(item: Item, pos: IntPos | FloatPos): Entity | undefined
function spawnItem<T extends Integer | Float>(item: Item, x: T, y: T, z: T, dimid: DimensionID): Entity | undefined
function newScoreObjective(name: string, displayName: string): Objective | undefined
function getScoreObjective(name: string): Objective | undefined
function getAllScoreObjectives(): Objective[]
function getDisplayObjective(slot: "sidebar" | "belowname" | "list"): Objective | undefined
function removeScoreObjective(name: string): boolean
function clearDisplayObjective(slot: "sidebar" | "belowname" | "list"): boolean
function getBDSVersion(): string
function setMotd(motd: string): boolean
function listen(event: string, callback: (...args: any[]) => boolean | void): boolean
function newSimpleForm(): SimpleForm
function newCustomForm(): CustomForm
}
declare namespace NBT {
function createTag(type: any, data?: any): NbtValue | NbtList | NbtCompound | undefined
function parseSNBT(snbt: string): NbtCompound | undefined
function parseBinaryNBT(nbt: ArrayBuffer): NbtCompound | undefined
}
declare namespace logger {
function setConsole(isOpen: boolean, logLevel: number): void
function setFile(filePath: string, logLevel: number): void
function setPlayer(player: Player, logLevel: number): void
function log(...args: any[]): void
function debug(...args: any[]): void
function info(...args: any[]): void
function warn(...args: any[]): void
function error(...args: any[]): void
function fatal(...args: any[]): void
function setTitle(title: string): void
function setLogLevel(level: LogLevel): void
}
declare var lxl: {
version: () => {
major: Integer
minor: Integer
revision: Integer
isBeta: boolean
},
requireVersion: (major: Integer, minor?: Integer, revision?: Integer) => boolean
listPlugins: () => string[],
require: (path: string, remotePath?: string) => boolean,
loadLangPack: (path: string) => Integer | undefined
"export": (func: (...args: any[]) => any, name: string) => boolean,
"import": (name: string) => ((...args: any[]) => any),
"eval": (str: string) => any
}
declare namespace data {
function openConfig(path: string, format?: "json", _default?: string): JSONConf | undefined
function openConfig(path: string, format: "ini", _default?: string): INIConf | undefined
function openDB(dir: string): DB | undefined
function name2xuid(name: string): string | undefined
function xuid2name(xuid: string): string | undefined
function toJson(_var: any, space?: Integer): string | undefined
function parseJson(json: string): any
function toMD5(str: string): string
function toSHA1(str: string): string
}
declare namespace money {
function set(xuid: string, money: Integer): boolean
function get(xuid: string): Integer
function add(xuid: string, money: Integer): boolean
function reduce(xuid: string, money: Integer): boolean
function trans(xuid1: string, xuid2: string, money: Integer, note?: string): boolean
function getHistory(xuid: string, time: Integer): Array<{
from: string
to: string
money: Integer
time: string
note: string
}>
function clearHistory(time: Integer): boolean
}
declare enum file {
ReadMode,
WriteMode,
AppendMode
}
declare namespace file {
function readFrom(path: string): string | undefined
function writeTo(path: string, text: string): boolean
function writeLine(path: string, text: string): boolean
function open(path: string, mode: file, isBinary?: boolean): File | undefined
}
declare namespace network {
function httpGet(url: string, callback: (status: Integer, result: string | -1) => void): boolean
function httpPost(url: string, data: string, type: string, callback: (status: Integer, result: string | -1) => void): boolean
function newWebsocket(): WSClient
}
declare namespace system {
function cmd(cmd: string, callback: (exitcode: Integer, output: string) => void, timeLimit?: Integer): boolean
function newProcess(process: string, callback: (exitcode: Integer, output: string) => void, timeLimit?: Integer): boolean
function getTimeStr(): string
function getTimeObj(): {
Y: Integer
M: Integer
D: Integer
h: Integer
m: Integer
s: Integer
ms: Integer
}
function randomGuid(): string
}