@zardoy/flying-squid 0.0.104 → 0.0.105

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.
Files changed (2) hide show
  1. package/dist/index.js +6 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -108,16 +108,16 @@ class MCServer extends events_1.EventEmitter {
108
108
  server._server = oldServer?._server ?? (0, minecraft_protocol_1.createServer)({
109
109
  ...options,
110
110
  });
111
+ const connPendingUsernames = new Set();
111
112
  server._server.on('connection', (client) => {
112
113
  const loginOld = client['_events'].login_start;
113
- const pendingUsernames = new Set();
114
114
  if (typeof loginOld === 'function') {
115
115
  client['_events'].login_start = async (packet) => {
116
116
  const packetUsername = packet.username.toLowerCase();
117
- if (pendingUsernames.has(packetUsername)) {
117
+ if (connPendingUsernames.has(packetUsername)) {
118
118
  client.end('A player with this username is already connecting');
119
119
  }
120
- pendingUsernames.add(packetUsername);
120
+ connPendingUsernames.add(packetUsername);
121
121
  try {
122
122
  const username = (await server.customGetUsername?.(packet, client)) ?? packetUsername;
123
123
  if (client.ended)
@@ -132,9 +132,11 @@ class MCServer extends events_1.EventEmitter {
132
132
  }
133
133
  }
134
134
  catch (err) {
135
- pendingUsernames.delete(packetUsername);
136
135
  client.end('An error occurred while connecting to the server');
137
136
  }
137
+ finally {
138
+ connPendingUsernames.delete(packetUsername);
139
+ }
138
140
  };
139
141
  }
140
142
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zardoy/flying-squid",
3
3
  "description": "A minecraft server written in TS",
4
- "version": "0.0.104",
4
+ "version": "0.0.105",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",