hytopia 0.14.20 → 0.14.22

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.
@@ -114,6 +114,19 @@ startServer(world => {
114
114
  world.entityManager.getPlayerEntitiesByPlayer(player).forEach(entity => entity.despawn());
115
115
  });
116
116
 
117
+ /**
118
+ * If a player's connection drops, or they quickly leave and reconnect to the same game,
119
+ * it's considered a reconnect event and not a new join event, so we need to handle
120
+ * that appropriately. In this case, we just need to reload the player's UI. If we had
121
+ * UI data to sync too, we'd want to resync that as well here. RECONNECTED_WORLD is a special
122
+ * event where the player is still in the world (the disconnect timer hasn't happened yet),
123
+ * so the server hasn't closed their connection and therefore did not trigger LEFT_WORLD.
124
+ */
125
+ world.on(PlayerEvent.RECONNECTED_WORLD, ({ player }) => {
126
+ // Reload the player's UI to ensure it's up to date.
127
+ player.ui.load('ui/index.html');
128
+ });
129
+
117
130
  /**
118
131
  * A silly little easter egg command. When a player types
119
132
  * "/rocket" in the game, they'll get launched into the air!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.14.20",
3
+ "version": "0.14.22",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./server.mjs",