hytopia 0.3.1 → 0.3.2

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/server.api.json CHANGED
@@ -23383,6 +23383,348 @@
23383
23383
  "endIndex": 10
23384
23384
  }
23385
23385
  },
23386
+ {
23387
+ "kind": "Class",
23388
+ "canonicalReference": "server!PersistenceManager:class",
23389
+ "docComment": "/**\n * Manages persistence of player and global data.\n *\n * @remarks\n *\n * This class is a singleton accessible with the static property `PersistenceManager.instance`. Convenience methods are also available on the `Player` and `GameServer` classes.\n *\n * @public\n */\n",
23390
+ "excerptTokens": [
23391
+ {
23392
+ "kind": "Content",
23393
+ "text": "export default class PersistenceManager "
23394
+ }
23395
+ ],
23396
+ "fileUrlPath": "src/persistence/PersistenceManager.ts",
23397
+ "releaseTag": "Public",
23398
+ "isAbstract": false,
23399
+ "name": "PersistenceManager",
23400
+ "preserveMemberOrder": false,
23401
+ "members": [
23402
+ {
23403
+ "kind": "Method",
23404
+ "canonicalReference": "server!PersistenceManager#getGlobalData:member(1)",
23405
+ "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",
23406
+ "excerptTokens": [
23407
+ {
23408
+ "kind": "Content",
23409
+ "text": "getGlobalData(key: "
23410
+ },
23411
+ {
23412
+ "kind": "Content",
23413
+ "text": "string"
23414
+ },
23415
+ {
23416
+ "kind": "Content",
23417
+ "text": "): "
23418
+ },
23419
+ {
23420
+ "kind": "Reference",
23421
+ "text": "Promise",
23422
+ "canonicalReference": "!Promise:interface"
23423
+ },
23424
+ {
23425
+ "kind": "Content",
23426
+ "text": "<"
23427
+ },
23428
+ {
23429
+ "kind": "Reference",
23430
+ "text": "Record",
23431
+ "canonicalReference": "!Record:type"
23432
+ },
23433
+ {
23434
+ "kind": "Content",
23435
+ "text": "<string, unknown> | void>"
23436
+ },
23437
+ {
23438
+ "kind": "Content",
23439
+ "text": ";"
23440
+ }
23441
+ ],
23442
+ "isStatic": false,
23443
+ "returnTypeTokenRange": {
23444
+ "startIndex": 3,
23445
+ "endIndex": 7
23446
+ },
23447
+ "releaseTag": "Public",
23448
+ "isProtected": false,
23449
+ "overloadIndex": 1,
23450
+ "parameters": [
23451
+ {
23452
+ "parameterName": "key",
23453
+ "parameterTypeTokenRange": {
23454
+ "startIndex": 1,
23455
+ "endIndex": 2
23456
+ },
23457
+ "isOptional": false
23458
+ }
23459
+ ],
23460
+ "isOptional": false,
23461
+ "isAbstract": false,
23462
+ "name": "getGlobalData"
23463
+ },
23464
+ {
23465
+ "kind": "Method",
23466
+ "canonicalReference": "server!PersistenceManager#getPlayerData:member(1)",
23467
+ "docComment": "/**\n * Get player data from the data persistence service.\n *\n * @param player - The player to get the data from.\n *\n * @returns The data from the persistence layer.\n */\n",
23468
+ "excerptTokens": [
23469
+ {
23470
+ "kind": "Content",
23471
+ "text": "getPlayerData(player: "
23472
+ },
23473
+ {
23474
+ "kind": "Reference",
23475
+ "text": "Player",
23476
+ "canonicalReference": "server!Player:class"
23477
+ },
23478
+ {
23479
+ "kind": "Content",
23480
+ "text": "): "
23481
+ },
23482
+ {
23483
+ "kind": "Reference",
23484
+ "text": "Promise",
23485
+ "canonicalReference": "!Promise:interface"
23486
+ },
23487
+ {
23488
+ "kind": "Content",
23489
+ "text": "<"
23490
+ },
23491
+ {
23492
+ "kind": "Reference",
23493
+ "text": "Record",
23494
+ "canonicalReference": "!Record:type"
23495
+ },
23496
+ {
23497
+ "kind": "Content",
23498
+ "text": "<string, unknown> | void>"
23499
+ },
23500
+ {
23501
+ "kind": "Content",
23502
+ "text": ";"
23503
+ }
23504
+ ],
23505
+ "isStatic": false,
23506
+ "returnTypeTokenRange": {
23507
+ "startIndex": 3,
23508
+ "endIndex": 7
23509
+ },
23510
+ "releaseTag": "Public",
23511
+ "isProtected": false,
23512
+ "overloadIndex": 1,
23513
+ "parameters": [
23514
+ {
23515
+ "parameterName": "player",
23516
+ "parameterTypeTokenRange": {
23517
+ "startIndex": 1,
23518
+ "endIndex": 2
23519
+ },
23520
+ "isOptional": false
23521
+ }
23522
+ ],
23523
+ "isOptional": false,
23524
+ "isAbstract": false,
23525
+ "name": "getPlayerData"
23526
+ },
23527
+ {
23528
+ "kind": "Property",
23529
+ "canonicalReference": "server!PersistenceManager.instance:member",
23530
+ "docComment": "",
23531
+ "excerptTokens": [
23532
+ {
23533
+ "kind": "Content",
23534
+ "text": "static readonly instance: "
23535
+ },
23536
+ {
23537
+ "kind": "Reference",
23538
+ "text": "PersistenceManager",
23539
+ "canonicalReference": "server!PersistenceManager:class"
23540
+ },
23541
+ {
23542
+ "kind": "Content",
23543
+ "text": ";"
23544
+ }
23545
+ ],
23546
+ "isReadonly": true,
23547
+ "isOptional": false,
23548
+ "releaseTag": "Public",
23549
+ "name": "instance",
23550
+ "propertyTypeTokenRange": {
23551
+ "startIndex": 1,
23552
+ "endIndex": 2
23553
+ },
23554
+ "isStatic": true,
23555
+ "isProtected": false,
23556
+ "isAbstract": false
23557
+ },
23558
+ {
23559
+ "kind": "Method",
23560
+ "canonicalReference": "server!PersistenceManager#setGlobalData:member(1)",
23561
+ "docComment": "/**\n * Set global data in the data persistence service. This data is available and shared by all lobbies of your game.\n *\n * @param key - The key to set the data to.\n *\n * @param data - The data to set.\n */\n",
23562
+ "excerptTokens": [
23563
+ {
23564
+ "kind": "Content",
23565
+ "text": "setGlobalData(key: "
23566
+ },
23567
+ {
23568
+ "kind": "Content",
23569
+ "text": "string"
23570
+ },
23571
+ {
23572
+ "kind": "Content",
23573
+ "text": ", data: "
23574
+ },
23575
+ {
23576
+ "kind": "Reference",
23577
+ "text": "Record",
23578
+ "canonicalReference": "!Record:type"
23579
+ },
23580
+ {
23581
+ "kind": "Content",
23582
+ "text": "<string, unknown>"
23583
+ },
23584
+ {
23585
+ "kind": "Content",
23586
+ "text": "): "
23587
+ },
23588
+ {
23589
+ "kind": "Reference",
23590
+ "text": "Promise",
23591
+ "canonicalReference": "!Promise:interface"
23592
+ },
23593
+ {
23594
+ "kind": "Content",
23595
+ "text": "<"
23596
+ },
23597
+ {
23598
+ "kind": "Reference",
23599
+ "text": "Record",
23600
+ "canonicalReference": "!Record:type"
23601
+ },
23602
+ {
23603
+ "kind": "Content",
23604
+ "text": "<string, unknown> | void>"
23605
+ },
23606
+ {
23607
+ "kind": "Content",
23608
+ "text": ";"
23609
+ }
23610
+ ],
23611
+ "isStatic": false,
23612
+ "returnTypeTokenRange": {
23613
+ "startIndex": 6,
23614
+ "endIndex": 10
23615
+ },
23616
+ "releaseTag": "Public",
23617
+ "isProtected": false,
23618
+ "overloadIndex": 1,
23619
+ "parameters": [
23620
+ {
23621
+ "parameterName": "key",
23622
+ "parameterTypeTokenRange": {
23623
+ "startIndex": 1,
23624
+ "endIndex": 2
23625
+ },
23626
+ "isOptional": false
23627
+ },
23628
+ {
23629
+ "parameterName": "data",
23630
+ "parameterTypeTokenRange": {
23631
+ "startIndex": 3,
23632
+ "endIndex": 5
23633
+ },
23634
+ "isOptional": false
23635
+ }
23636
+ ],
23637
+ "isOptional": false,
23638
+ "isAbstract": false,
23639
+ "name": "setGlobalData"
23640
+ },
23641
+ {
23642
+ "kind": "Method",
23643
+ "canonicalReference": "server!PersistenceManager#setPlayerData:member(1)",
23644
+ "docComment": "/**\n * Set player data in the data persistence service. This data is persisted even after a player disconnects, and is retrievable no matter the lobby for your game that they join.\n *\n * @param player - The player to set the data to.\n *\n * @param data - The data to set.\n */\n",
23645
+ "excerptTokens": [
23646
+ {
23647
+ "kind": "Content",
23648
+ "text": "setPlayerData(player: "
23649
+ },
23650
+ {
23651
+ "kind": "Reference",
23652
+ "text": "Player",
23653
+ "canonicalReference": "server!Player:class"
23654
+ },
23655
+ {
23656
+ "kind": "Content",
23657
+ "text": ", data: "
23658
+ },
23659
+ {
23660
+ "kind": "Reference",
23661
+ "text": "Record",
23662
+ "canonicalReference": "!Record:type"
23663
+ },
23664
+ {
23665
+ "kind": "Content",
23666
+ "text": "<string, unknown>"
23667
+ },
23668
+ {
23669
+ "kind": "Content",
23670
+ "text": "): "
23671
+ },
23672
+ {
23673
+ "kind": "Reference",
23674
+ "text": "Promise",
23675
+ "canonicalReference": "!Promise:interface"
23676
+ },
23677
+ {
23678
+ "kind": "Content",
23679
+ "text": "<"
23680
+ },
23681
+ {
23682
+ "kind": "Reference",
23683
+ "text": "Record",
23684
+ "canonicalReference": "!Record:type"
23685
+ },
23686
+ {
23687
+ "kind": "Content",
23688
+ "text": "<string, unknown> | void>"
23689
+ },
23690
+ {
23691
+ "kind": "Content",
23692
+ "text": ";"
23693
+ }
23694
+ ],
23695
+ "isStatic": false,
23696
+ "returnTypeTokenRange": {
23697
+ "startIndex": 6,
23698
+ "endIndex": 10
23699
+ },
23700
+ "releaseTag": "Public",
23701
+ "isProtected": false,
23702
+ "overloadIndex": 1,
23703
+ "parameters": [
23704
+ {
23705
+ "parameterName": "player",
23706
+ "parameterTypeTokenRange": {
23707
+ "startIndex": 1,
23708
+ "endIndex": 2
23709
+ },
23710
+ "isOptional": false
23711
+ },
23712
+ {
23713
+ "parameterName": "data",
23714
+ "parameterTypeTokenRange": {
23715
+ "startIndex": 3,
23716
+ "endIndex": 5
23717
+ },
23718
+ "isOptional": false
23719
+ }
23720
+ ],
23721
+ "isOptional": false,
23722
+ "isAbstract": false,
23723
+ "name": "setPlayerData"
23724
+ }
23725
+ ],
23726
+ "implementsTokenRanges": []
23727
+ },
23386
23728
  {
23387
23729
  "kind": "Class",
23388
23730
  "canonicalReference": "server!Player:class",
@@ -23479,6 +23821,51 @@
23479
23821
  "isAbstract": false,
23480
23822
  "name": "disconnect"
23481
23823
  },
23824
+ {
23825
+ "kind": "Method",
23826
+ "canonicalReference": "server!Player#getPersistedData:member(1)",
23827
+ "docComment": "/**\n * Get the persisted data for the player.\n *\n * @remarks\n *\n * This method is asynchronous and returns a promise that resolves to the player data.\n *\n * @returns The persisted data for the player.\n */\n",
23828
+ "excerptTokens": [
23829
+ {
23830
+ "kind": "Content",
23831
+ "text": "getPersistedData(): "
23832
+ },
23833
+ {
23834
+ "kind": "Reference",
23835
+ "text": "Promise",
23836
+ "canonicalReference": "!Promise:interface"
23837
+ },
23838
+ {
23839
+ "kind": "Content",
23840
+ "text": "<"
23841
+ },
23842
+ {
23843
+ "kind": "Reference",
23844
+ "text": "Record",
23845
+ "canonicalReference": "!Record:type"
23846
+ },
23847
+ {
23848
+ "kind": "Content",
23849
+ "text": "<string, unknown> | void>"
23850
+ },
23851
+ {
23852
+ "kind": "Content",
23853
+ "text": ";"
23854
+ }
23855
+ ],
23856
+ "isStatic": false,
23857
+ "returnTypeTokenRange": {
23858
+ "startIndex": 1,
23859
+ "endIndex": 5
23860
+ },
23861
+ "releaseTag": "Public",
23862
+ "isProtected": false,
23863
+ "overloadIndex": 1,
23864
+ "parameters": [],
23865
+ "isOptional": false,
23866
+ "isAbstract": false,
23867
+ "name": "getPersistedData"
23868
+ },
23482
23869
  {
23483
23870
  "kind": "Property",
23484
23871
  "canonicalReference": "server!Player#id:member",
@@ -23650,6 +24037,73 @@
23650
24037
  "isProtected": false,
23651
24038
  "isAbstract": false
23652
24039
  },
24040
+ {
24041
+ "kind": "Method",
24042
+ "canonicalReference": "server!Player#setPersistedData:member(1)",
24043
+ "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",
24044
+ "excerptTokens": [
24045
+ {
24046
+ "kind": "Content",
24047
+ "text": "setPersistedData(data: "
24048
+ },
24049
+ {
24050
+ "kind": "Reference",
24051
+ "text": "Record",
24052
+ "canonicalReference": "!Record:type"
24053
+ },
24054
+ {
24055
+ "kind": "Content",
24056
+ "text": "<string, unknown>"
24057
+ },
24058
+ {
24059
+ "kind": "Content",
24060
+ "text": "): "
24061
+ },
24062
+ {
24063
+ "kind": "Reference",
24064
+ "text": "Promise",
24065
+ "canonicalReference": "!Promise:interface"
24066
+ },
24067
+ {
24068
+ "kind": "Content",
24069
+ "text": "<"
24070
+ },
24071
+ {
24072
+ "kind": "Reference",
24073
+ "text": "Record",
24074
+ "canonicalReference": "!Record:type"
24075
+ },
24076
+ {
24077
+ "kind": "Content",
24078
+ "text": "<string, unknown> | void>"
24079
+ },
24080
+ {
24081
+ "kind": "Content",
24082
+ "text": ";"
24083
+ }
24084
+ ],
24085
+ "isStatic": false,
24086
+ "returnTypeTokenRange": {
24087
+ "startIndex": 4,
24088
+ "endIndex": 8
24089
+ },
24090
+ "releaseTag": "Public",
24091
+ "isProtected": false,
24092
+ "overloadIndex": 1,
24093
+ "parameters": [
24094
+ {
24095
+ "parameterName": "data",
24096
+ "parameterTypeTokenRange": {
24097
+ "startIndex": 1,
24098
+ "endIndex": 3
24099
+ },
24100
+ "isOptional": false
24101
+ }
24102
+ ],
24103
+ "isOptional": false,
24104
+ "isAbstract": false,
24105
+ "name": "setPersistedData"
24106
+ },
23653
24107
  {
23654
24108
  "kind": "Property",
23655
24109
  "canonicalReference": "server!Player#ui:member",
package/server.d.ts CHANGED
@@ -3001,6 +3001,49 @@ export declare type PathfindingOptions = {
3001
3001
  waypointTimeoutMs?: number;
3002
3002
  };
3003
3003
 
3004
+ /**
3005
+ * Manages persistence of player and global data.
3006
+ *
3007
+ * @remarks
3008
+ * This class is a singleton accessible with the static property
3009
+ * `PersistenceManager.instance`. Convenience methods are also
3010
+ * available on the `Player` and `GameServer` classes.
3011
+ *
3012
+ * @public
3013
+ */
3014
+ export declare class PersistenceManager {
3015
+ static readonly instance: PersistenceManager;
3016
+ /**
3017
+ * Get global data from the data persistence service.
3018
+ * @param key - The key to get the data from.
3019
+ * @returns The data from the persistence layer.
3020
+ */
3021
+ getGlobalData(key: string): Promise<Record<string, unknown> | void>;
3022
+ /**
3023
+ * Get player data from the data persistence service.
3024
+ * @param player - The player to get the data from.
3025
+ * @returns The data from the persistence layer.
3026
+ */
3027
+ getPlayerData(player: Player): Promise<Record<string, unknown> | void>;
3028
+ /**
3029
+ * Set global data in the data persistence service. This
3030
+ * data is available and shared by all lobbies of your game.
3031
+ * @param key - The key to set the data to.
3032
+ * @param data - The data to set.
3033
+ */
3034
+ setGlobalData(key: string, data: Record<string, unknown>): Promise<Record<string, unknown> | void>;
3035
+ /**
3036
+ * Set player data in the data persistence service. This
3037
+ * data is persisted even after a player disconnects, and
3038
+ * is retrievable no matter the lobby for your game that
3039
+ * they join.
3040
+ * @param player - The player to set the data to.
3041
+ * @param data - The data to set.
3042
+ */
3043
+ setPlayerData(player: Player, data: Record<string, unknown>): Promise<Record<string, unknown> | void>;
3044
+
3045
+ }
3046
+
3004
3047
  /**
3005
3048
  * A player in the game.
3006
3049
  *
@@ -3035,6 +3078,20 @@ export declare class Player extends EventRouter implements protocol.Serializable
3035
3078
  get input(): PlayerInput;
3036
3079
  /** The current {@link World} the player is in. */
3037
3080
  get world(): World | undefined;
3081
+ /**
3082
+ * Disconnects the player from the game server.
3083
+ */
3084
+ disconnect(): void;
3085
+ /**
3086
+ * Get the persisted data for the player.
3087
+ *
3088
+ * @remarks
3089
+ * This method is asynchronous and returns a promise that
3090
+ * resolves to the player data.
3091
+ *
3092
+ * @returns The persisted data for the player.
3093
+ */
3094
+ getPersistedData(): Promise<Record<string, unknown> | void>;
3038
3095
  /**
3039
3096
  * Joins a player to a world.
3040
3097
  *
@@ -3051,9 +3108,19 @@ export declare class Player extends EventRouter implements protocol.Serializable
3051
3108
  */
3052
3109
  leaveWorld(): void;
3053
3110
  /**
3054
- * Disconnects the player from the game server.
3111
+ * Set the persisted data for the player. This data can
3112
+ * later be retrieved using {@link Player.getPersistedData},
3113
+ * even if a player disconnects and rejoin a game in the future,
3114
+ * or joins a different HYTOPIA managed lobby of your game.
3115
+ *
3116
+ * @remarks
3117
+ * This method is asynchronous and returns a promise that
3118
+ * resolves to the player data.
3119
+ *
3120
+ * @param data - The data to set.
3121
+ * @returns The persisted data for the player.
3055
3122
  */
3056
- disconnect(): void;
3123
+ setPersistedData(data: Record<string, unknown>): Promise<Record<string, unknown> | void>;
3057
3124
 
3058
3125
 
3059
3126