yolkbot 0.1.1-alpha.3 → 0.1.1-alpha.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers (self) bot in under 10 lines.",
4
- "version": "0.1.1-alpha.3",
4
+ "version": "0.1.1-alpha.4",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
package/src/api.js CHANGED
@@ -2,10 +2,10 @@ import axios from 'axios';
2
2
 
3
3
  import yolkws from './socket.js';
4
4
 
5
- import { FirebaseKey, IsBrowser, UserAgent } from '#constants';
5
+ import { FirebaseKey, ProxiesEnabled, UserAgent } from '#constants';
6
6
 
7
7
  let SocksProxyAgent;
8
- if (!IsBrowser) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
8
+ if (ProxiesEnabled) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
9
9
 
10
10
  const queryServices = async (request, proxy = '', instance = 'shellshock.io') => {
11
11
  let ws;
@@ -91,7 +91,7 @@ async function loginWithCredentials(email, password, prox = '', instance = 'shel
91
91
  'user-agent': UserAgent,
92
92
  'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
93
93
  },
94
- httpsAgent: (!IsBrowser && prox) ? new SocksProxyAgent(prox) : false
94
+ httpsAgent: (ProxiesEnabled && prox) ? new SocksProxyAgent(prox) : false
95
95
  })
96
96
  body = request.data
97
97
  token = body.idToken;
@@ -143,7 +143,7 @@ async function loginWithRefreshToken(refreshToken, prox = '', instance = 'shells
143
143
  'user-agent': UserAgent,
144
144
  'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
145
145
  },
146
- httpsAgent: (!IsBrowser && prox) ? new SocksProxyAgent(prox) : false
146
+ httpsAgent: (ProxiesEnabled && prox) ? new SocksProxyAgent(prox) : false
147
147
  })
148
148
  body = request.data
149
149
  token = body.id_token;
@@ -185,7 +185,7 @@ async function loginAnonymously(prox = '', instance = 'shellshock.io') {
185
185
  'user-agent': UserAgent,
186
186
  'x-client-version': 'Chrome/JsCore/9.17.2/FirebaseCore-web'
187
187
  },
188
- httpsAgent: (!IsBrowser && prox) ? new SocksProxyAgent(prox) : false
188
+ httpsAgent: (ProxiesEnabled && prox) ? new SocksProxyAgent(prox) : false
189
189
  });
190
190
 
191
191
  const token = body.idToken;
package/src/bot.js CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  ItemTypes,
22
22
  Movements,
23
23
  PlayTypes,
24
+ ProxiesEnabled,
24
25
  ShellStreaks
25
26
  } from '#constants';
26
27
 
@@ -50,7 +51,7 @@ export class Bot {
50
51
  Intents = intents;
51
52
 
52
53
  constructor(params = {}) {
53
- if (params.proxy && IsBrowser)
54
+ if (params.proxy && !ProxiesEnabled)
54
55
  throw new Error('proxies do not work and hence are not supported in the browser');
55
56
 
56
57
  this.intents = params.intents || [];
@@ -71,6 +71,8 @@ export const PlayTypes = {
71
71
  joinPrivate: 2
72
72
  }
73
73
 
74
+ export const ProxiesEnabled = !IsBrowser && typeof Bun == 'undefined';
75
+
74
76
  export const ShellStreaks = {
75
77
  HardBoiled: 1,
76
78
  EggBreaker: 2,
package/src/matchmaker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { loginAnonymously } from '#api';
2
- import { GameModes, IsBrowser, PlayTypes } from '#constants';
2
+ import { GameModes, PlayTypes, ProxiesEnabled } from '#constants';
3
3
 
4
4
  import yolkws from './socket.js';
5
5
 
@@ -21,13 +21,10 @@ export class Matchmaker {
21
21
  constructor(params = {}) {
22
22
  if (!params.instance) params.instance = 'shellshock.io';
23
23
 
24
- if (params.proxy && IsBrowser)
25
- throw new Error('proxies do not work and hence are not supported in the browser');
26
-
27
24
  if (params.sessionId) this.sessionId = params.sessionId;
28
25
  else this.#createSessionId(params.instance);
29
26
 
30
- if (params.proxy && IsBrowser) throw new Error('proxies do not work and hence are not supported in the browser');
27
+ if (params.proxy && !ProxiesEnabled) throw new Error('proxies do not work and hence are not supported in the browser');
31
28
  else if (params.proxy) this.proxy = params.proxy;
32
29
 
33
30
  this.#createSocket(params.instance);
@@ -20,11 +20,14 @@ class NodeList {
20
20
  constructor(raw) {
21
21
  const now = Date.now();
22
22
  this.list = [];
23
- const addedPositions = new Set();
23
+ const addedPositions = {};
24
24
 
25
25
  for (const meshName of Object.keys(raw.data)) {
26
26
  for (const nodeData of raw.data[meshName]) {
27
- addedPositions.add(`${nodeData.x},${nodeData.y},${nodeData.z}`);
27
+ addedPositions[(
28
+ (nodeData.x << 16) |
29
+ (nodeData.y << 8) |
30
+ (nodeData.z))] = true;
28
31
  this.add(new MapNode(meshName, nodeData));
29
32
  }
30
33
  }
@@ -32,8 +35,11 @@ class NodeList {
32
35
  for (let x = 0; x < raw.width; x++) {
33
36
  for (let y = 0; y < raw.height; y++) {
34
37
  for (let z = 0; z < raw.depth; z++) {
35
- const posKey = `${x},${y},${z}`;
36
- if (!addedPositions.has(posKey)) {
38
+ if (!addedPositions[(
39
+ (x << 16) |
40
+ (y << 8) |
41
+ (z)
42
+ )]) {
37
43
  this.add(new MapNode('SPECIAL.__yolkbot_air__.none', { x: x, y: y, z: z }));
38
44
  }
39
45
  }
package/src/socket.js CHANGED
@@ -1,12 +1,11 @@
1
1
  import NodeWebSocket from 'ws';
2
2
 
3
- import { IsBrowser, UserAgent } from '#constants';
3
+ import { IsBrowser, ProxiesEnabled, UserAgent } from '#constants';
4
4
 
5
- // eslint-disable-next-line no-undef
6
5
  const WS = IsBrowser ? window.WebSocket : NodeWebSocket;
7
6
 
8
7
  let SocksProxyAgent;
9
- if (!IsBrowser) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
8
+ if (ProxiesEnabled) SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
10
9
 
11
10
  class yolkws extends WS {
12
11
  constructor(url, proxy) {
@@ -71,6 +71,8 @@ export declare const PlayTypes: {
71
71
  joinPrivate: number;
72
72
  };
73
73
 
74
+ export declare const ProxiesEnabled: boolean;
75
+
74
76
  export declare const ShellStreaks: {
75
77
  HardBoiled: number;
76
78
  EggBreaker: number;