From 82f28aa8d013a0b94bb5d82a2ea6947db88392c5 Mon Sep 17 00:00:00 2001 From: WorldEditAxe <84165981+WorldEditAxe@users.noreply.github.com> Date: Wed, 21 Jun 2023 10:34:06 +0000 Subject: [PATCH] fix EaglerProxyAAS + bump to v1.0.1 --- src/meta.ts | 2 +- src/plugins/EagProxyAAS/auth.ts | 6 +-- src/plugins/EagProxyAAS/metadata.json | 2 +- src/plugins/EagProxyAAS/utils.ts | 59 +++++++++++++++------------ 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/meta.ts b/src/meta.ts index e2b5f81..39ee95f 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -5,7 +5,7 @@ export const BRIDGE_VERSION: Readonly = f(1) // adapter meta export const PROXY_BRANDING: Readonly = f("EaglerProxy") -export const PROXY_VERSION: Readonly = f("1.0.6") +export const PROXY_VERSION: Readonly = f("1.0.7") export const NETWORK_VERSION: Readonly = f(0x03) export const VANILLA_PROTOCOL_VERSION: Readonly = f(47) diff --git a/src/plugins/EagProxyAAS/auth.ts b/src/plugins/EagProxyAAS/auth.ts index 19249c9..b3ca240 100644 --- a/src/plugins/EagProxyAAS/auth.ts +++ b/src/plugins/EagProxyAAS/auth.ts @@ -35,9 +35,9 @@ export function auth(): EventEmitter { const emitter = new EventEmitter() const userIdentifier = randomUUID() const flow = new Authflow(userIdentifier, ({ username, cacheName }) => new InMemoryCache(), { - authTitle: Titles.MinecraftNintendoSwitch, - flow: 'live', - deviceType: "Nintendo" + authTitle: Titles.MinecraftJava, + flow: 'sisu', + deviceType: "Win32" }, code => { console.log = () => {} emitter.emit('code', code) diff --git a/src/plugins/EagProxyAAS/metadata.json b/src/plugins/EagProxyAAS/metadata.json index c51a5ac..2cca3a2 100644 --- a/src/plugins/EagProxyAAS/metadata.json +++ b/src/plugins/EagProxyAAS/metadata.json @@ -1,7 +1,7 @@ { "name": "EaglerProxy as a Service", "id": "eagpaas", - "version": "1.0.0", + "version": "1.0.1", "entry_point": "index.js", "requirements": [{ "id": "eaglerproxy", diff --git a/src/plugins/EagProxyAAS/utils.ts b/src/plugins/EagProxyAAS/utils.ts index cc76c2b..754d7bb 100644 --- a/src/plugins/EagProxyAAS/utils.ts +++ b/src/plugins/EagProxyAAS/utils.ts @@ -84,9 +84,9 @@ export function awaitCommand(client: Client, filter: (msg: string) => boolean): }) } -export function sendMessage(client: Client, msg: string) { +export function sendMessage(client: Client, msg: string, json?: any) { client.write('chat', { - message: JSON.stringify({ text: msg }), + message: JSON.stringify({ text: msg, ...json }), position: 1 }) } @@ -223,6 +223,7 @@ export async function onConnect(client: ClientState) { client.lastStatusUpdate = Date.now() updateState(client.gameClient, 'SERVER') sendMessage(client.gameClient, `Provide a server to join. ${Enums.ChatColor.GOLD}/join [port]${Enums.ChatColor.RESET}.`) + sendMessage(client.gameClient, "(providing a custom port to a SRV record server domain may potentially cause issues)", { color: "gray" }) let host: string, port: number while (true) { const msg = await awaitCommand(client.gameClient, msg => msg.startsWith("/join")), parsed = msg.split(/ /gi, 3) @@ -230,33 +231,37 @@ export async function onConnect(client: ClientState) { else if (parsed.length > 3 && isNaN(parseInt(parsed[2]))) sendMessage(client.gameClient, `A valid port number has to be passed! ${Enums.ChatColor.GOLD}/join [port]${Enums.ChatColor.RESET}.`) else { host = parsed[1] - if (parsed.length > 3) port = parseInt(parsed[2]) + if (parsed.length >= 3) port = parseInt(parsed[2]) port = port ?? 25565 - break - } - } - try { - await PLUGIN_MANAGER.proxy.players.get(client.gameClient.username).switchServers({ - host: host, - port: port, - version: "1.8.8", - username: savedAuth.selectedProfile.name, - auth: 'mojang', - keepAlive: false, - session: { - accessToken: savedAuth.accessToken, - clientToken: savedAuth.selectedProfile.id, - selectedProfile: { - id: savedAuth.selectedProfile.id, - name: savedAuth.selectedProfile.name + + try { + await PLUGIN_MANAGER.proxy.players.get(client.gameClient.username).switchServers({ + host: host, + port: port, + version: "1.8.8", + username: savedAuth.selectedProfile.name, + auth: 'mojang', + keepAlive: false, + session: { + accessToken: savedAuth.accessToken, + clientToken: savedAuth.selectedProfile.id, + selectedProfile: { + id: savedAuth.selectedProfile.id, + name: savedAuth.selectedProfile.name + } + }, + skipValidation: true, + hideErrors: true + }) + } catch (err) { + if (!client.gameClient.ended) { + sendMessage(client.gameClient, `Something went wrong whilst switching servers: ${err.message}.`, { color: "red" }) + if (err.code == "ENOTFOUND") { + sendMessage(client.gameClient, `Please check that the provided IP/hostname is correct, and try again.`, { color: "red" }) + } } - }, - skipValidation: true, - hideErrors: true - }) - } catch (err) { - if (!client.gameClient.ended) { - client.gameClient.end(Enums.ChatColor.RED + `Something went wrong whilst switching servers: ${err.message}`) + } + break } } } catch (err) {