@minecraft/server-admin 1.0.0-beta.1.21.80-preview.22 → 1.0.0-beta.1.21.80-preview.27
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/index.d.ts +88 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -26,6 +26,75 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import * as minecraftcommon from '@minecraft/common';
|
|
28
28
|
import * as minecraftserver from '@minecraft/server';
|
|
29
|
+
export class AdminBeforeEvents {
|
|
30
|
+
private constructor();
|
|
31
|
+
/**
|
|
32
|
+
* @remarks
|
|
33
|
+
* This event is fired before a player joins the world. Unlike
|
|
34
|
+
* other before events, this event is a before event that you
|
|
35
|
+
* can delay several ticks by not resolving the promise
|
|
36
|
+
* returned in the subscribe function. If the promise is
|
|
37
|
+
* rejected, the client is rejected.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
readonly asyncPlayerJoin: AsyncPlayerJoinBeforeEventSignal;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The data available before a player joins the world.
|
|
45
|
+
*/
|
|
46
|
+
export class AsyncPlayerJoinBeforeEvent {
|
|
47
|
+
private constructor();
|
|
48
|
+
/**
|
|
49
|
+
* @remarks
|
|
50
|
+
* The player's name
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/**
|
|
55
|
+
* @remarks
|
|
56
|
+
* An identifier that can be used to identify a player across
|
|
57
|
+
* sessions.
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
readonly persistentId: string;
|
|
61
|
+
/**
|
|
62
|
+
* @remarks
|
|
63
|
+
* Call this to disconnect a player. They will be allowed to
|
|
64
|
+
* try to join again.
|
|
65
|
+
*
|
|
66
|
+
* @throws This function can throw errors.
|
|
67
|
+
*
|
|
68
|
+
* {@link DisconnectedError}
|
|
69
|
+
*/
|
|
70
|
+
disconnect(reason?: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* @remarks
|
|
73
|
+
* Will return true if the player is still waiting to join the
|
|
74
|
+
* world. If they disconnect then it will return false.
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
isValid(): boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class AsyncPlayerJoinBeforeEventSignal {
|
|
81
|
+
private constructor();
|
|
82
|
+
/**
|
|
83
|
+
* @remarks
|
|
84
|
+
* Add a callback that's ran before a player joins the world.
|
|
85
|
+
* This callback returns a promise and the player won't join
|
|
86
|
+
* until that promise is resolved. If the promise is not
|
|
87
|
+
* resolved within a reasonable time, the player joining will
|
|
88
|
+
* be rejected. If the player joining leaves/disconnects, then
|
|
89
|
+
* the event data's isValid will return false.
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
subscribe(
|
|
93
|
+
callback: (arg0: AsyncPlayerJoinBeforeEvent) => Promise<void>,
|
|
94
|
+
): (arg0: AsyncPlayerJoinBeforeEvent) => Promise<void>;
|
|
95
|
+
unsubscribe(callback: (arg0: AsyncPlayerJoinBeforeEvent) => Promise<void>): boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
29
98
|
/**
|
|
30
99
|
* This represents a placeholder object that represents a
|
|
31
100
|
* secret string. The contents of that string are not available
|
|
@@ -136,7 +205,24 @@ export class ServerVariables {
|
|
|
136
205
|
* This function can be called in early-execution mode.
|
|
137
206
|
*
|
|
138
207
|
*/
|
|
139
|
-
get(name: string):
|
|
208
|
+
get(name: string): unknown | undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* An error that is thrown when trying to interact with a join
|
|
213
|
+
* event and the player is disconnected.
|
|
214
|
+
*/
|
|
215
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
216
|
+
export class DisconnectedError extends Error {
|
|
217
|
+
private constructor();
|
|
218
|
+
/**
|
|
219
|
+
* @remarks
|
|
220
|
+
* The id of the player that was disconnected.
|
|
221
|
+
*
|
|
222
|
+
* This property can be read in early-execution mode.
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
id: string;
|
|
140
226
|
}
|
|
141
227
|
|
|
142
228
|
/**
|
|
@@ -154,6 +240,7 @@ export class ServerVariables {
|
|
|
154
240
|
* @throws This function can throw errors.
|
|
155
241
|
*/
|
|
156
242
|
export function transferPlayer(player: minecraftserver.Player, host: string, port: number): void;
|
|
243
|
+
export const beforeEvents: AdminBeforeEvents;
|
|
157
244
|
/**
|
|
158
245
|
* @remarks
|
|
159
246
|
* A globally available object that returns a list of
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minecraft/server-admin",
|
|
3
|
-
"version": "1.0.0-beta.1.21.80-preview.
|
|
3
|
+
"version": "1.0.0-beta.1.21.80-preview.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@minecraft/common": "^1.0.0",
|
|
17
|
-
"@minecraft/server": "^1.17.0 || ^2.0.0-beta.1.21.80-preview.
|
|
17
|
+
"@minecraft/server": "^1.17.0 || ^2.0.0-beta.1.21.80-preview.27"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT"
|
|
20
20
|
}
|