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.
- package/boilerplate/index.ts +13 -0
- package/package.json +1 -1
- package/server.mjs +82 -81
package/boilerplate/index.ts
CHANGED
|
@@ -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