blockmine 1.5.7 → 1.6.0

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.
@@ -160,6 +160,7 @@ process.on('message', async (message) => {
160
160
  version: config.server.version,
161
161
  auth: 'offline',
162
162
  hideErrors: false,
163
+ chat: 'enabled',
163
164
  };
164
165
 
165
166
  if (config.proxyHost && config.proxyPort) {
@@ -210,8 +211,39 @@ process.on('message', async (message) => {
210
211
  const userData = await UserService.getUser(username, bot.config.id, bot.config);
211
212
  if (!userData) return null;
212
213
 
214
+ const permissions = userData.permissionsSet ? Array.from(userData.permissionsSet) : [];
215
+
213
216
  return {
214
- ...userData,
217
+ id: userData.id,
218
+ username: userData.username,
219
+ isOwner: userData.isOwner,
220
+ isBlacklisted: userData.isBlacklisted,
221
+ permissions: permissions,
222
+ groups: userData.groups,
223
+ hasPermission: (permissionName) => {
224
+ if (userData.isOwner) return true;
225
+ if (!permissionName) return false;
226
+
227
+ if (permissions.includes(permissionName)) {
228
+ return true;
229
+ }
230
+
231
+ const permissionParts = permissionName.split('.');
232
+ if (permissionParts.length > 1) {
233
+ const domain = permissionParts[0];
234
+ const wildcard = `${domain}.*`;
235
+ if (permissions.includes(wildcard)) {
236
+ return true;
237
+ }
238
+ }
239
+
240
+ if (permissions.includes('*')) {
241
+ return true;
242
+ }
243
+
244
+ return false;
245
+ },
246
+ hasGroup: (groupName) => userData.hasGroup(groupName),
215
247
  addGroup: (group) => bot.api.performUserAction(username, 'addGroup', { group }),
216
248
  removeGroup: (group) => bot.api.performUserAction(username, 'removeGroup', { group }),
217
249
  addPermission: (permission) => bot.api.performUserAction(username, 'addPermission', { permission }),
@@ -484,6 +516,10 @@ process.on('message', async (message) => {
484
516
  }
485
517
  });
486
518
 
519
+ bot.on('death', () => {
520
+ sendEvent('botDied', { user: { username: bot.username } });
521
+ });
522
+
487
523
  bot.on('kicked', (reason) => {
488
524
  let reasonText;
489
525
  try { reasonText = JSON.parse(reason).text || reason; } catch (e) { reasonText = reason; }
@@ -509,11 +545,13 @@ process.on('message', async (message) => {
509
545
  });
510
546
 
511
547
  bot.on('entitySpawn', (entity) => {
548
+ if (!isReady) return;
512
549
  const serialized = serializeEntity(entity);
513
550
  sendEvent('entitySpawn', { entity: serialized });
514
551
  });
515
552
 
516
553
  bot.on('entityMoved', (entity) => {
554
+ if (!isReady) return;
517
555
  const now = Date.now();
518
556
  const lastSent = entityMoveThrottles.get(entity.id);
519
557
  if (!lastSent || now - lastSent > 500) {
@@ -523,6 +561,7 @@ process.on('message', async (message) => {
523
561
  });
524
562
 
525
563
  bot.on('entityGone', (entity) => {
564
+ if (!isReady) return;
526
565
  sendEvent('entityGone', { entity: serializeEntity(entity) });
527
566
  entityMoveThrottles.delete(entity.id);
528
567
  });
@@ -531,7 +570,7 @@ process.on('message', async (message) => {
531
570
  sendLog('[Event: spawn] Бот заспавнился в мире.');
532
571
  setTimeout(() => {
533
572
  isReady = true;
534
- sendLog('[BotProcess] Бот готов к приему событий playerJoined/playerLeft.');
573
+ sendLog('[BotProcess] Бот готов к приему событий.');
535
574
  }, 3000);
536
575
  });
537
576
  } catch (err) {
@@ -149,6 +149,9 @@ class EventGraphManager {
149
149
  case 'playerLeft':
150
150
  context.user = args.user;
151
151
  break;
152
+ case 'botDied':
153
+ context.user = args.user;
154
+ break;
152
155
  case 'tick':
153
156
  break;
154
157
  case 'entitySpawn':