hytopia 0.10.13 → 0.10.15
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/docs/server.chatmanager.handlecommand.md +72 -0
- package/docs/server.chatmanager.md +14 -0
- package/docs/server.persistencemanager.getglobaldata.md +18 -2
- package/docs/server.persistencemanager.md +1 -1
- package/docs/server.persistencemanager.setglobaldata.md +2 -2
- package/docs/server.player.getpersisteddata.md +1 -1
- package/docs/server.player.setpersisteddata.md +1 -1
- package/package.json +1 -1
- package/server.api.json +88 -7
- package/server.d.ts +18 -4
- package/server.mjs +144 -144
@@ -0,0 +1,72 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ChatManager](./server.chatmanager.md) > [handleCommand](./server.chatmanager.handlecommand.md)
|
4
|
+
|
5
|
+
## ChatManager.handleCommand() method
|
6
|
+
|
7
|
+
Handle a command if it exists.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
handleCommand(player: Player, message: string): boolean;
|
13
|
+
```
|
14
|
+
|
15
|
+
## Parameters
|
16
|
+
|
17
|
+
<table><thead><tr><th>
|
18
|
+
|
19
|
+
Parameter
|
20
|
+
|
21
|
+
|
22
|
+
</th><th>
|
23
|
+
|
24
|
+
Type
|
25
|
+
|
26
|
+
|
27
|
+
</th><th>
|
28
|
+
|
29
|
+
Description
|
30
|
+
|
31
|
+
|
32
|
+
</th></tr></thead>
|
33
|
+
<tbody><tr><td>
|
34
|
+
|
35
|
+
player
|
36
|
+
|
37
|
+
|
38
|
+
</td><td>
|
39
|
+
|
40
|
+
[Player](./server.player.md)
|
41
|
+
|
42
|
+
|
43
|
+
</td><td>
|
44
|
+
|
45
|
+
The player that sent the command.
|
46
|
+
|
47
|
+
|
48
|
+
</td></tr>
|
49
|
+
<tr><td>
|
50
|
+
|
51
|
+
message
|
52
|
+
|
53
|
+
|
54
|
+
</td><td>
|
55
|
+
|
56
|
+
string
|
57
|
+
|
58
|
+
|
59
|
+
</td><td>
|
60
|
+
|
61
|
+
The full message.
|
62
|
+
|
63
|
+
|
64
|
+
</td></tr>
|
65
|
+
</tbody></table>
|
66
|
+
|
67
|
+
**Returns:**
|
68
|
+
|
69
|
+
boolean
|
70
|
+
|
71
|
+
True if a command was handled, false otherwise.
|
72
|
+
|
@@ -60,6 +60,20 @@ Description
|
|
60
60
|
</th></tr></thead>
|
61
61
|
<tbody><tr><td>
|
62
62
|
|
63
|
+
[handleCommand(player, message)](./server.chatmanager.handlecommand.md)
|
64
|
+
|
65
|
+
|
66
|
+
</td><td>
|
67
|
+
|
68
|
+
|
69
|
+
</td><td>
|
70
|
+
|
71
|
+
Handle a command if it exists.
|
72
|
+
|
73
|
+
|
74
|
+
</td></tr>
|
75
|
+
<tr><td>
|
76
|
+
|
63
77
|
[registerCommand(command, callback)](./server.chatmanager.registercommand.md)
|
64
78
|
|
65
79
|
|
@@ -9,7 +9,7 @@ Get global data from the data persistence service.
|
|
9
9
|
**Signature:**
|
10
10
|
|
11
11
|
```typescript
|
12
|
-
getGlobalData(key: string): Promise<Record<string, unknown> |
|
12
|
+
getGlobalData(key: string, maxRetries?: number): Promise<Record<string, unknown> | undefined>;
|
13
13
|
```
|
14
14
|
|
15
15
|
## Parameters
|
@@ -45,12 +45,28 @@ string
|
|
45
45
|
The key to get the data from.
|
46
46
|
|
47
47
|
|
48
|
+
</td></tr>
|
49
|
+
<tr><td>
|
50
|
+
|
51
|
+
maxRetries
|
52
|
+
|
53
|
+
|
54
|
+
</td><td>
|
55
|
+
|
56
|
+
number
|
57
|
+
|
58
|
+
|
59
|
+
</td><td>
|
60
|
+
|
61
|
+
_(Optional)_ The maximum number of retries to attempt in the event of failure.
|
62
|
+
|
63
|
+
|
48
64
|
</td></tr>
|
49
65
|
</tbody></table>
|
50
66
|
|
51
67
|
**Returns:**
|
52
68
|
|
53
|
-
Promise<Record<string, unknown> \|
|
69
|
+
Promise<Record<string, unknown> \| undefined>
|
54
70
|
|
55
71
|
The data from the persistence layer.
|
56
72
|
|
@@ -9,7 +9,7 @@ Set global data in the data persistence service. This data is available and shar
|
|
9
9
|
**Signature:**
|
10
10
|
|
11
11
|
```typescript
|
12
|
-
setGlobalData(key: string, data: Record<string, unknown>): Promise<Record<string, unknown> |
|
12
|
+
setGlobalData(key: string, data: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
|
13
13
|
```
|
14
14
|
|
15
15
|
## Parameters
|
@@ -66,5 +66,5 @@ The data to set.
|
|
66
66
|
|
67
67
|
**Returns:**
|
68
68
|
|
69
|
-
Promise<Record<string, unknown> \|
|
69
|
+
Promise<Record<string, unknown> \| undefined>
|
70
70
|
|
@@ -19,5 +19,5 @@ The persisted data for the player.
|
|
19
19
|
|
20
20
|
## Remarks
|
21
21
|
|
22
|
-
This method returns the player persisted data.
|
22
|
+
This method returns the player persisted data. If it returns undefined, the player data failed to load and your game logic should handle this case appropriately.
|
23
23
|
|
@@ -56,5 +56,5 @@ The persisted data for the player.
|
|
56
56
|
|
57
57
|
## Remarks
|
58
58
|
|
59
|
-
This method is asynchronous and returns a promise that resolves to the player data.
|
59
|
+
This method is asynchronous and returns a promise that resolves to the player data. Data is set using shallow merge of the existing data. It is recommended that you provide a changed data object for your saved data structure rather than the entire data object to avoid edge cases with data persistence or overwrites.
|
60
60
|
|
package/package.json
CHANGED
package/server.api.json
CHANGED
@@ -6301,6 +6301,71 @@
|
|
6301
6301
|
"name": "ChatManager",
|
6302
6302
|
"preserveMemberOrder": false,
|
6303
6303
|
"members": [
|
6304
|
+
{
|
6305
|
+
"kind": "Method",
|
6306
|
+
"canonicalReference": "server!ChatManager#handleCommand:member(1)",
|
6307
|
+
"docComment": "/**\n * Handle a command if it exists.\n *\n * @param player - The player that sent the command.\n *\n * @param message - The full message.\n *\n * @returns True if a command was handled, false otherwise.\n */\n",
|
6308
|
+
"excerptTokens": [
|
6309
|
+
{
|
6310
|
+
"kind": "Content",
|
6311
|
+
"text": "handleCommand(player: "
|
6312
|
+
},
|
6313
|
+
{
|
6314
|
+
"kind": "Reference",
|
6315
|
+
"text": "Player",
|
6316
|
+
"canonicalReference": "server!Player:class"
|
6317
|
+
},
|
6318
|
+
{
|
6319
|
+
"kind": "Content",
|
6320
|
+
"text": ", message: "
|
6321
|
+
},
|
6322
|
+
{
|
6323
|
+
"kind": "Content",
|
6324
|
+
"text": "string"
|
6325
|
+
},
|
6326
|
+
{
|
6327
|
+
"kind": "Content",
|
6328
|
+
"text": "): "
|
6329
|
+
},
|
6330
|
+
{
|
6331
|
+
"kind": "Content",
|
6332
|
+
"text": "boolean"
|
6333
|
+
},
|
6334
|
+
{
|
6335
|
+
"kind": "Content",
|
6336
|
+
"text": ";"
|
6337
|
+
}
|
6338
|
+
],
|
6339
|
+
"isStatic": false,
|
6340
|
+
"returnTypeTokenRange": {
|
6341
|
+
"startIndex": 5,
|
6342
|
+
"endIndex": 6
|
6343
|
+
},
|
6344
|
+
"releaseTag": "Public",
|
6345
|
+
"isProtected": false,
|
6346
|
+
"overloadIndex": 1,
|
6347
|
+
"parameters": [
|
6348
|
+
{
|
6349
|
+
"parameterName": "player",
|
6350
|
+
"parameterTypeTokenRange": {
|
6351
|
+
"startIndex": 1,
|
6352
|
+
"endIndex": 2
|
6353
|
+
},
|
6354
|
+
"isOptional": false
|
6355
|
+
},
|
6356
|
+
{
|
6357
|
+
"parameterName": "message",
|
6358
|
+
"parameterTypeTokenRange": {
|
6359
|
+
"startIndex": 3,
|
6360
|
+
"endIndex": 4
|
6361
|
+
},
|
6362
|
+
"isOptional": false
|
6363
|
+
}
|
6364
|
+
],
|
6365
|
+
"isOptional": false,
|
6366
|
+
"isAbstract": false,
|
6367
|
+
"name": "handleCommand"
|
6368
|
+
},
|
6304
6369
|
{
|
6305
6370
|
"kind": "Method",
|
6306
6371
|
"canonicalReference": "server!ChatManager#registerCommand:member(1)",
|
@@ -35178,7 +35243,7 @@
|
|
35178
35243
|
{
|
35179
35244
|
"kind": "Method",
|
35180
35245
|
"canonicalReference": "server!PersistenceManager#getGlobalData:member(1)",
|
35181
|
-
"docComment": "/**\n * Get global data from the data persistence service.\n *\n * @param key - The key to get the data from.\n *\n * @returns The data from the persistence layer.\n */\n",
|
35246
|
+
"docComment": "/**\n * Get global data from the data persistence service.\n *\n * @param key - The key to get the data from.\n *\n * @param maxRetries - The maximum number of retries to attempt in the event of failure.\n *\n * @returns The data from the persistence layer.\n */\n",
|
35182
35247
|
"excerptTokens": [
|
35183
35248
|
{
|
35184
35249
|
"kind": "Content",
|
@@ -35188,6 +35253,14 @@
|
|
35188
35253
|
"kind": "Content",
|
35189
35254
|
"text": "string"
|
35190
35255
|
},
|
35256
|
+
{
|
35257
|
+
"kind": "Content",
|
35258
|
+
"text": ", maxRetries?: "
|
35259
|
+
},
|
35260
|
+
{
|
35261
|
+
"kind": "Content",
|
35262
|
+
"text": "number"
|
35263
|
+
},
|
35191
35264
|
{
|
35192
35265
|
"kind": "Content",
|
35193
35266
|
"text": "): "
|
@@ -35208,7 +35281,7 @@
|
|
35208
35281
|
},
|
35209
35282
|
{
|
35210
35283
|
"kind": "Content",
|
35211
|
-
"text": "<string, unknown> |
|
35284
|
+
"text": "<string, unknown> | undefined>"
|
35212
35285
|
},
|
35213
35286
|
{
|
35214
35287
|
"kind": "Content",
|
@@ -35217,8 +35290,8 @@
|
|
35217
35290
|
],
|
35218
35291
|
"isStatic": false,
|
35219
35292
|
"returnTypeTokenRange": {
|
35220
|
-
"startIndex":
|
35221
|
-
"endIndex":
|
35293
|
+
"startIndex": 5,
|
35294
|
+
"endIndex": 9
|
35222
35295
|
},
|
35223
35296
|
"releaseTag": "Public",
|
35224
35297
|
"isProtected": false,
|
@@ -35231,6 +35304,14 @@
|
|
35231
35304
|
"endIndex": 2
|
35232
35305
|
},
|
35233
35306
|
"isOptional": false
|
35307
|
+
},
|
35308
|
+
{
|
35309
|
+
"parameterName": "maxRetries",
|
35310
|
+
"parameterTypeTokenRange": {
|
35311
|
+
"startIndex": 3,
|
35312
|
+
"endIndex": 4
|
35313
|
+
},
|
35314
|
+
"isOptional": true
|
35234
35315
|
}
|
35235
35316
|
],
|
35236
35317
|
"isOptional": false,
|
@@ -35314,7 +35395,7 @@
|
|
35314
35395
|
},
|
35315
35396
|
{
|
35316
35397
|
"kind": "Content",
|
35317
|
-
"text": "<string, unknown> |
|
35398
|
+
"text": "<string, unknown> | undefined>"
|
35318
35399
|
},
|
35319
35400
|
{
|
35320
35401
|
"kind": "Content",
|
@@ -35497,7 +35578,7 @@
|
|
35497
35578
|
{
|
35498
35579
|
"kind": "Method",
|
35499
35580
|
"canonicalReference": "server!Player#getPersistedData:member(1)",
|
35500
|
-
"docComment": "/**\n * Get the persisted data for the player.\n *\n * @remarks\n *\n * This method returns the player persisted data.\n *\n * @returns The persisted data for the player.\n */\n",
|
35581
|
+
"docComment": "/**\n * Get the persisted data for the player.\n *\n * @remarks\n *\n * This method returns the player persisted data. If it returns undefined, the player data failed to load and your game logic should handle this case appropriately.\n *\n * @returns The persisted data for the player.\n */\n",
|
35501
35582
|
"excerptTokens": [
|
35502
35583
|
{
|
35503
35584
|
"kind": "Content",
|
@@ -35704,7 +35785,7 @@
|
|
35704
35785
|
{
|
35705
35786
|
"kind": "Method",
|
35706
35787
|
"canonicalReference": "server!Player#setPersistedData:member(1)",
|
35707
|
-
"docComment": "/**\n * Set the persisted data for the player. This data can later be retrieved using {@link Player.getPersistedData}, even if a player disconnects and rejoin a game in the future, or joins a different HYTOPIA managed lobby of your game.\n *\n * @remarks\n *\n * This method is asynchronous and returns a promise that resolves to the player data.\n *\n * @param data - The data to set.\n *\n * @returns The persisted data for the player.\n */\n",
|
35788
|
+
"docComment": "/**\n * Set the persisted data for the player. This data can later be retrieved using {@link Player.getPersistedData}, even if a player disconnects and rejoin a game in the future, or joins a different HYTOPIA managed lobby of your game.\n *\n * @remarks\n *\n * This method is asynchronous and returns a promise that resolves to the player data. Data is set using shallow merge of the existing data. It is recommended that you provide a changed data object for your saved data structure rather than the entire data object to avoid edge cases with data persistence or overwrites.\n *\n * @param data - The data to set.\n *\n * @returns The persisted data for the player.\n */\n",
|
35708
35789
|
"excerptTokens": [
|
35709
35790
|
{
|
35710
35791
|
"kind": "Content",
|
package/server.d.ts
CHANGED
@@ -836,6 +836,13 @@ export declare class ChatManager extends EventRouter {
|
|
836
836
|
* ```
|
837
837
|
*/
|
838
838
|
sendBroadcastMessage(message: string, color?: string): void;
|
839
|
+
/**
|
840
|
+
* Handle a command if it exists.
|
841
|
+
* @param player - The player that sent the command.
|
842
|
+
* @param message - The full message.
|
843
|
+
* @returns True if a command was handled, false otherwise.
|
844
|
+
*/
|
845
|
+
handleCommand(player: Player, message: string): boolean;
|
839
846
|
/**
|
840
847
|
* Send a system message to a specific player, only visible to them.
|
841
848
|
* @param player - The player to send the message to.
|
@@ -4333,9 +4340,10 @@ export declare class PersistenceManager {
|
|
4333
4340
|
/**
|
4334
4341
|
* Get global data from the data persistence service.
|
4335
4342
|
* @param key - The key to get the data from.
|
4343
|
+
* @param maxRetries - The maximum number of retries to attempt in the event of failure.
|
4336
4344
|
* @returns The data from the persistence layer.
|
4337
4345
|
*/
|
4338
|
-
getGlobalData(key: string): Promise<Record<string, unknown> |
|
4346
|
+
getGlobalData(key: string, maxRetries?: number): Promise<Record<string, unknown> | undefined>;
|
4339
4347
|
|
4340
4348
|
/**
|
4341
4349
|
* Set global data in the data persistence service. This
|
@@ -4343,7 +4351,7 @@ export declare class PersistenceManager {
|
|
4343
4351
|
* @param key - The key to set the data to.
|
4344
4352
|
* @param data - The data to set.
|
4345
4353
|
*/
|
4346
|
-
setGlobalData(key: string, data: Record<string, unknown>): Promise<Record<string, unknown> |
|
4354
|
+
setGlobalData(key: string, data: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
|
4347
4355
|
|
4348
4356
|
|
4349
4357
|
}
|
@@ -4396,7 +4404,9 @@ export declare class Player extends EventRouter implements protocol.Serializable
|
|
4396
4404
|
* Get the persisted data for the player.
|
4397
4405
|
*
|
4398
4406
|
* @remarks
|
4399
|
-
* This method returns the player persisted data.
|
4407
|
+
* This method returns the player persisted data. If it returns
|
4408
|
+
* undefined, the player data failed to load and your game
|
4409
|
+
* logic should handle this case appropriately.
|
4400
4410
|
*
|
4401
4411
|
* @returns The persisted data for the player.
|
4402
4412
|
*/
|
@@ -4426,7 +4436,11 @@ export declare class Player extends EventRouter implements protocol.Serializable
|
|
4426
4436
|
*
|
4427
4437
|
* @remarks
|
4428
4438
|
* This method is asynchronous and returns a promise that
|
4429
|
-
* resolves to the player data.
|
4439
|
+
* resolves to the player data. Data is set using shallow
|
4440
|
+
* merge of the existing data. It is recommended that you
|
4441
|
+
* provide a changed data object for your saved data structure
|
4442
|
+
* rather than the entire data object to avoid edge cases with
|
4443
|
+
* data persistence or overwrites.
|
4430
4444
|
*
|
4431
4445
|
* @param data - The data to set.
|
4432
4446
|
* @returns The persisted data for the player.
|