From 958a0601153717720b5888d4c32ba871428d910c Mon Sep 17 00:00:00 2001 From: q13x Date: Tue, 20 Dec 2022 11:28:37 -0800 Subject: [PATCH] some refactoring --- classes.ts | 15 ------------- meta.ts | 3 --- motd.ts | 66 ------------------------------------------------------ 3 files changed, 84 deletions(-) delete mode 100644 classes.ts delete mode 100644 meta.ts delete mode 100644 motd.ts diff --git a/classes.ts b/classes.ts deleted file mode 100644 index 8b073c6..0000000 --- a/classes.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Client } from "minecraft-protocol" -import { WebSocket } from "ws" -import { State } from "./types.js" - -export class ProxiedPlayer { - public username: string - public uuid: string - public clientBrand: string - public state: State - public ws: WebSocket - public ip: string - public remotePort: number - public remoteConnection: Client - public compressionThreshold: number -} \ No newline at end of file diff --git a/meta.ts b/meta.ts deleted file mode 100644 index de715cc..0000000 --- a/meta.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const BRANDING: Readonly = Object.freeze("EaglerXProxy") -export const VERSION: Readonly = "1.0.0" -export const NETWORK_VERSION: Readonly = Object.freeze(BRANDING + "/" + VERSION) \ No newline at end of file diff --git a/motd.ts b/motd.ts deleted file mode 100644 index db12d41..0000000 --- a/motd.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { randomUUID } from "crypto"; -import { WebSocket } from "ws"; -import { ProxiedPlayer } from "./classes.js"; -import { UUID } from "./types.js" - -export type MotdPlayer = { - name: string, - id: UUID -} - -export type MotdJSONRes = { - brand: string, - cracked: true, - data: { - cache: true, - icon: boolean, - max: number, - motd: [string, string], - online: number, - players: string[], - }, - name: string, - secure: false, - time: ReturnType, - type: "motd", - uuid: ReturnType, - vers: string -} - -// a 16384 byte array -export type MotdServerLogo = Int8Array - -export function handleMotd(player: Partial) { - const names = [] - for (const [username, player] of PROXY.players) { - if (names.length > 0) { - names.push(`(and ${PROXY.players.size - names.length} more)`) - break - } else { - names.push(username) - } - } - - player.ws.send(JSON.stringify({ - brand: PROXY.brand, - cracked: true, - data: { - cache: true, - icon: PROXY.MOTD.icon ? true : false, - max: PROXY.playerStats.max, - motd: PROXY.MOTD.motd, - online: PROXY.playerStats.onlineCount, - players: names - }, - name: PROXY.serverName, - secure: false, - time: Date.now(), - type: "motd", - uuid: PROXY.proxyUUID, - vers: PROXY.MOTDVersion - } as MotdJSONRes)) - if (PROXY.MOTD.icon) { - player.ws.send(PROXY.MOTD.icon) - } - player.ws.close() -} \ No newline at end of file