@minecraft/server-admin 1.0.0-beta.1.26.3-stable → 1.0.0-beta.1.26.30-preview.25
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/README.md +8 -8
- package/index.d.ts +315 -27
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# `@minecraft/server-admin`
|
|
2
|
-
|
|
3
|
-
Contains types related to administering a Bedrock Dedicated Server. These types allow for the configuration of variables and secrets in JSON files in the Bedrock Dedicated Server folder. These types cannot be used on Minecraft clients or within Minecraft Realms.
|
|
4
|
-
|
|
5
|
-
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
6
|
-
|
|
7
|
-
See full documentation for this module here:
|
|
8
|
-
|
|
1
|
+
# `@minecraft/server-admin`
|
|
2
|
+
|
|
3
|
+
Contains types related to administering a Bedrock Dedicated Server. These types allow for the configuration of variables and secrets in JSON files in the Bedrock Dedicated Server folder. These types cannot be used on Minecraft clients or within Minecraft Realms.
|
|
4
|
+
|
|
5
|
+
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
6
|
+
|
|
7
|
+
See full documentation for this module here:
|
|
8
|
+
|
|
9
9
|
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-admin/minecraft-server-admin
|
package/index.d.ts
CHANGED
|
@@ -40,6 +40,68 @@ export class AdminBeforeEvents {
|
|
|
40
40
|
readonly asyncPlayerJoin: AsyncPlayerJoinBeforeEventSignal;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Controls the allow list for the server. Only available on
|
|
45
|
+
* dedicated server.
|
|
46
|
+
*/
|
|
47
|
+
export class AllowList {
|
|
48
|
+
private constructor();
|
|
49
|
+
/**
|
|
50
|
+
* @remarks
|
|
51
|
+
* This property can't be edited in restricted-execution mode.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* @remarks
|
|
57
|
+
* Adds a player to the server's allow list.
|
|
58
|
+
*
|
|
59
|
+
* @param player
|
|
60
|
+
* Player or player name that should be added to the allow
|
|
61
|
+
* list.
|
|
62
|
+
* @throws This function can throw errors.
|
|
63
|
+
*
|
|
64
|
+
* {@link AllowListModificationError}
|
|
65
|
+
*
|
|
66
|
+
* {@link minecraftserver.InvalidEntityError}
|
|
67
|
+
*/
|
|
68
|
+
add(player: minecraftserver.Player | string): void;
|
|
69
|
+
/**
|
|
70
|
+
* @remarks
|
|
71
|
+
* Returns if the player is in the server's allow list.
|
|
72
|
+
*
|
|
73
|
+
* @param player
|
|
74
|
+
* Player or player name that should be checked for.
|
|
75
|
+
* @throws This function can throw errors.
|
|
76
|
+
*
|
|
77
|
+
* {@link minecraftserver.InvalidEntityError}
|
|
78
|
+
*/
|
|
79
|
+
contains(player: minecraftserver.Player | string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* @remarks
|
|
82
|
+
* Reloads the server's allow list from disk.
|
|
83
|
+
*
|
|
84
|
+
* @throws This function can throw errors.
|
|
85
|
+
*
|
|
86
|
+
* {@link AllowListFileReloadError}
|
|
87
|
+
*/
|
|
88
|
+
reloadFile(): void;
|
|
89
|
+
/**
|
|
90
|
+
* @remarks
|
|
91
|
+
* Removes a player from the server's allow list.
|
|
92
|
+
*
|
|
93
|
+
* @param player
|
|
94
|
+
* Player or player name that should be removed from the allow
|
|
95
|
+
* list.
|
|
96
|
+
* @throws This function can throw errors.
|
|
97
|
+
*
|
|
98
|
+
* {@link AllowListModificationError}
|
|
99
|
+
*
|
|
100
|
+
* {@link minecraftserver.InvalidEntityError}
|
|
101
|
+
*/
|
|
102
|
+
remove(player: minecraftserver.Player | string): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
43
105
|
/**
|
|
44
106
|
* The data available before a player joins the world.
|
|
45
107
|
*/
|
|
@@ -120,6 +182,117 @@ export class AsyncPlayerJoinBeforeEventSignal {
|
|
|
120
182
|
unsubscribe(callback: (arg0: AsyncPlayerJoinBeforeEvent) => Promise<void>): boolean;
|
|
121
183
|
}
|
|
122
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Contains apis that are only available when in Bedrock
|
|
187
|
+
* Dedicated Server.
|
|
188
|
+
*/
|
|
189
|
+
export class DedicatedServerUtils {
|
|
190
|
+
private constructor();
|
|
191
|
+
/**
|
|
192
|
+
* @remarks
|
|
193
|
+
* Returns an object that manages the server's allow list.
|
|
194
|
+
*
|
|
195
|
+
*/
|
|
196
|
+
readonly allowList: AllowList;
|
|
197
|
+
/**
|
|
198
|
+
* @remarks
|
|
199
|
+
* Returns an object that manages the level's storage.
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
readonly levelStorage: LevelStorage;
|
|
203
|
+
/**
|
|
204
|
+
* @remarks
|
|
205
|
+
* Reloads the cdn configuration from disk.
|
|
206
|
+
*
|
|
207
|
+
* @throws This function can throw errors.
|
|
208
|
+
*
|
|
209
|
+
* {@link minecraftcommon.EngineError}
|
|
210
|
+
*/
|
|
211
|
+
reloadCDNConfig(): void;
|
|
212
|
+
/**
|
|
213
|
+
* @remarks
|
|
214
|
+
* Reloads the permissions for the server from disk.
|
|
215
|
+
*
|
|
216
|
+
* @throws This function can throw errors.
|
|
217
|
+
*
|
|
218
|
+
* {@link minecraftcommon.EngineError}
|
|
219
|
+
*/
|
|
220
|
+
reloadPermissions(): void;
|
|
221
|
+
/**
|
|
222
|
+
* @remarks
|
|
223
|
+
* Reloads the script configuration for the server from disk.
|
|
224
|
+
*
|
|
225
|
+
* @throws This function can throw errors.
|
|
226
|
+
*
|
|
227
|
+
* {@link minecraftcommon.EngineError}
|
|
228
|
+
*/
|
|
229
|
+
reloadScriptingConfig(): void;
|
|
230
|
+
/**
|
|
231
|
+
* @remarks
|
|
232
|
+
* Shuts down the dedicated server.
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
stopServer(): void;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Controls how the server saves to disk. Only available on
|
|
240
|
+
* dedicated server.
|
|
241
|
+
*/
|
|
242
|
+
export class LevelStorage {
|
|
243
|
+
private constructor();
|
|
244
|
+
/**
|
|
245
|
+
* @remarks
|
|
246
|
+
* Disables the server writing to the world files and begins
|
|
247
|
+
* creating a snapshot.
|
|
248
|
+
*
|
|
249
|
+
* @throws This function can throw errors.
|
|
250
|
+
*
|
|
251
|
+
* {@link LevelStorageSaveStateChangeError}
|
|
252
|
+
*/
|
|
253
|
+
saveHold(): void;
|
|
254
|
+
/**
|
|
255
|
+
* @remarks
|
|
256
|
+
* Returns the path and size of every file in the current
|
|
257
|
+
* snapshot if a snapshot is being taken.
|
|
258
|
+
*
|
|
259
|
+
* @throws This function can throw errors.
|
|
260
|
+
*
|
|
261
|
+
* {@link LevelStorageSaveStateChangeError}
|
|
262
|
+
*/
|
|
263
|
+
saveQuery(): LevelStorageQuerySnapshotFile[];
|
|
264
|
+
/**
|
|
265
|
+
* @remarks
|
|
266
|
+
* Re-enables server writing world state to files and removes
|
|
267
|
+
* snapshot.
|
|
268
|
+
*
|
|
269
|
+
* @throws This function can throw errors.
|
|
270
|
+
*
|
|
271
|
+
* {@link LevelStorageSaveStateChangeError}
|
|
272
|
+
*/
|
|
273
|
+
saveResume(): void;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Contains information about a file that was gathered during a
|
|
278
|
+
* snapshot.
|
|
279
|
+
*/
|
|
280
|
+
export class LevelStorageQuerySnapshotFile {
|
|
281
|
+
private constructor();
|
|
282
|
+
/**
|
|
283
|
+
* @remarks
|
|
284
|
+
* The path to the file in the snapshot.
|
|
285
|
+
*
|
|
286
|
+
*/
|
|
287
|
+
readonly fileName: string;
|
|
288
|
+
/**
|
|
289
|
+
* @remarks
|
|
290
|
+
* The size of the file in the snapshot.
|
|
291
|
+
*
|
|
292
|
+
*/
|
|
293
|
+
readonly fileSize: number;
|
|
294
|
+
}
|
|
295
|
+
|
|
123
296
|
/**
|
|
124
297
|
* This represents a placeholder object that represents a
|
|
125
298
|
* secret string. The contents of that string are not available
|
|
@@ -134,28 +307,28 @@ export class SecretString {
|
|
|
134
307
|
* configuration.
|
|
135
308
|
* @example getPlayerProfile.ts
|
|
136
309
|
* ```typescript
|
|
137
|
-
* import { variables, secrets } from
|
|
138
|
-
* import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from
|
|
310
|
+
* import { variables, secrets } from '@minecraft/server-admin';
|
|
311
|
+
* import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from '@minecraft/server-net';
|
|
139
312
|
*
|
|
140
313
|
* const serverUrl = variables.get('serverEndpoint');
|
|
141
314
|
*
|
|
142
315
|
* function getPlayerProfile(playerId: string): Promise<HttpResponse> {
|
|
143
|
-
*
|
|
316
|
+
* const req = new HttpRequest(serverUrl + 'getPlayerProfile');
|
|
144
317
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
318
|
+
* req.body = JSON.stringify({
|
|
319
|
+
* playerId,
|
|
320
|
+
* });
|
|
148
321
|
*
|
|
149
|
-
*
|
|
322
|
+
* const authTokenSec = secrets.get('authtoken');
|
|
150
323
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
324
|
+
* if (!authTokenSec) {
|
|
325
|
+
* throw new Error('authtoken secret not defined.');
|
|
326
|
+
* }
|
|
154
327
|
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
328
|
+
* req.method = HttpRequestMethod.Post;
|
|
329
|
+
* req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];
|
|
157
330
|
*
|
|
158
|
-
*
|
|
331
|
+
* return http.request(req);
|
|
159
332
|
* }
|
|
160
333
|
* ```
|
|
161
334
|
*/
|
|
@@ -187,28 +360,28 @@ export class ServerSecrets {
|
|
|
187
360
|
* configuration.
|
|
188
361
|
* @example getPlayerProfile.ts
|
|
189
362
|
* ```typescript
|
|
190
|
-
* import { variables, secrets } from
|
|
191
|
-
* import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from
|
|
363
|
+
* import { variables, secrets } from '@minecraft/server-admin';
|
|
364
|
+
* import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from '@minecraft/server-net';
|
|
192
365
|
*
|
|
193
366
|
* const serverUrl = variables.get('serverEndpoint');
|
|
194
367
|
*
|
|
195
368
|
* function getPlayerProfile(playerId: string): Promise<HttpResponse> {
|
|
196
|
-
*
|
|
369
|
+
* const req = new HttpRequest(serverUrl + 'getPlayerProfile');
|
|
197
370
|
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
371
|
+
* req.body = JSON.stringify({
|
|
372
|
+
* playerId,
|
|
373
|
+
* });
|
|
201
374
|
*
|
|
202
|
-
*
|
|
375
|
+
* const authTokenSec = secrets.get('authtoken');
|
|
203
376
|
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
377
|
+
* if (!authTokenSec) {
|
|
378
|
+
* throw new Error('authtoken secret not defined.');
|
|
379
|
+
* }
|
|
207
380
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
381
|
+
* req.method = HttpRequestMethod.Post;
|
|
382
|
+
* req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];
|
|
210
383
|
*
|
|
211
|
-
*
|
|
384
|
+
* return http.request(req);
|
|
212
385
|
* }
|
|
213
386
|
* ```
|
|
214
387
|
*/
|
|
@@ -265,6 +438,42 @@ export interface TransferPlayerNetherNetOptions {
|
|
|
265
438
|
netherNetId: string;
|
|
266
439
|
}
|
|
267
440
|
|
|
441
|
+
/**
|
|
442
|
+
* An error that is thrown when the allow list file fails to
|
|
443
|
+
* reload.
|
|
444
|
+
*/
|
|
445
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
446
|
+
export class AllowListFileReloadError extends Error {
|
|
447
|
+
private constructor();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* An error which is thrown when modifying the allow list has
|
|
452
|
+
* failed.
|
|
453
|
+
*/
|
|
454
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
455
|
+
export class AllowListModificationError extends Error {
|
|
456
|
+
private constructor();
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* An error which is thrown when attempting to deop a player
|
|
461
|
+
* which cannot have their permissions removed.
|
|
462
|
+
*/
|
|
463
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
464
|
+
export class CannotDeopPlayerError extends Error {
|
|
465
|
+
private constructor();
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* An error which is thrown when attempting to kick a player
|
|
470
|
+
* who cannot be kicked.
|
|
471
|
+
*/
|
|
472
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
473
|
+
export class CannotKickPlayerError extends Error {
|
|
474
|
+
private constructor();
|
|
475
|
+
}
|
|
476
|
+
|
|
268
477
|
/**
|
|
269
478
|
* An error that is thrown when trying to interact with a join
|
|
270
479
|
* event and the player is disconnected.
|
|
@@ -279,9 +488,81 @@ export class DisconnectedError extends Error {
|
|
|
279
488
|
* This property can be read in early-execution mode.
|
|
280
489
|
*
|
|
281
490
|
*/
|
|
282
|
-
id: string;
|
|
491
|
+
readonly id: string;
|
|
283
492
|
}
|
|
284
493
|
|
|
494
|
+
/**
|
|
495
|
+
* An error that is thrown when level storage save state
|
|
496
|
+
* management are used out of sequence or are repeated in an
|
|
497
|
+
* invalid way.
|
|
498
|
+
*/
|
|
499
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
500
|
+
export class LevelStorageSaveStateChangeError extends Error {
|
|
501
|
+
private constructor();
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* An error which is thrown when attempting to op a player that
|
|
506
|
+
* already has op permissions.
|
|
507
|
+
*/
|
|
508
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
509
|
+
export class PlayerAlreadyOpError extends Error {
|
|
510
|
+
private constructor();
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* @remarks
|
|
515
|
+
* Removes the player's op permissions.
|
|
516
|
+
*
|
|
517
|
+
* This function can't be called in restricted-execution mode.
|
|
518
|
+
*
|
|
519
|
+
* @param player
|
|
520
|
+
* Player to remove permissions from.
|
|
521
|
+
* @throws This function can throw errors.
|
|
522
|
+
*
|
|
523
|
+
* {@link CannotDeopPlayerError}
|
|
524
|
+
*
|
|
525
|
+
* {@link minecraftcommon.EngineError}
|
|
526
|
+
*
|
|
527
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
528
|
+
*/
|
|
529
|
+
export function deopPlayer(player: minecraftserver.Player): void;
|
|
530
|
+
/**
|
|
531
|
+
* @remarks
|
|
532
|
+
* Kicks a player from the server.
|
|
533
|
+
*
|
|
534
|
+
* This function can't be called in restricted-execution mode.
|
|
535
|
+
*
|
|
536
|
+
* @param player
|
|
537
|
+
* Player to kick.
|
|
538
|
+
* @param reason
|
|
539
|
+
* Reason for kicking the player.
|
|
540
|
+
* @throws This function can throw errors.
|
|
541
|
+
*
|
|
542
|
+
* {@link CannotKickPlayerError}
|
|
543
|
+
*
|
|
544
|
+
* {@link minecraftcommon.EngineError}
|
|
545
|
+
*
|
|
546
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
547
|
+
*/
|
|
548
|
+
export function kickPlayer(player: minecraftserver.Player, reason?: string): void;
|
|
549
|
+
/**
|
|
550
|
+
* @remarks
|
|
551
|
+
* Gives the player op permissions.
|
|
552
|
+
*
|
|
553
|
+
* This function can't be called in restricted-execution mode.
|
|
554
|
+
*
|
|
555
|
+
* @param player
|
|
556
|
+
* Player to add permissions to.
|
|
557
|
+
* @throws This function can throw errors.
|
|
558
|
+
*
|
|
559
|
+
* {@link minecraftcommon.EngineError}
|
|
560
|
+
*
|
|
561
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
562
|
+
*
|
|
563
|
+
* {@link PlayerAlreadyOpError}
|
|
564
|
+
*/
|
|
565
|
+
export function opPlayer(player: minecraftserver.Player): void;
|
|
285
566
|
/**
|
|
286
567
|
* @remarks
|
|
287
568
|
* Transfer player to another server.
|
|
@@ -299,6 +580,13 @@ export function transferPlayer(
|
|
|
299
580
|
options: TransferPlayerIpPortOptions | TransferPlayerNetherNetOptions,
|
|
300
581
|
): void;
|
|
301
582
|
export const beforeEvents: AdminBeforeEvents;
|
|
583
|
+
/**
|
|
584
|
+
* @remarks
|
|
585
|
+
* A globally available, optional object that contains
|
|
586
|
+
* dedicated-server only apis.
|
|
587
|
+
*
|
|
588
|
+
*/
|
|
589
|
+
export const dedicatedServer: DedicatedServerUtils | undefined;
|
|
302
590
|
/**
|
|
303
591
|
* @remarks
|
|
304
592
|
* A globally available object that returns a list of
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@minecraft/server-admin",
|
|
3
|
-
"version": "1.0.0-beta.1.26.
|
|
4
|
-
"description": "",
|
|
5
|
-
"contributors": [
|
|
6
|
-
{
|
|
7
|
-
"name": "Jake Shirley",
|
|
8
|
-
"email": "jake@xbox.com"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "Mike Ammerlaan",
|
|
12
|
-
"email": "mikeam@microsoft.com"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"@minecraft/common": "^1.0.0",
|
|
17
|
-
"@minecraft/server": "^1.17.0 || ^2.0.0"
|
|
18
|
-
},
|
|
19
|
-
"license": "MIT"
|
|
1
|
+
{
|
|
2
|
+
"name": "@minecraft/server-admin",
|
|
3
|
+
"version": "1.0.0-beta.1.26.30-preview.25",
|
|
4
|
+
"description": "",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Jake Shirley",
|
|
8
|
+
"email": "jake@xbox.com"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Mike Ammerlaan",
|
|
12
|
+
"email": "mikeam@microsoft.com"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@minecraft/common": "^1.0.0",
|
|
17
|
+
"@minecraft/server": "^1.17.0 || ^2.0.0"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT"
|
|
20
20
|
}
|