mirror of
https://github.com/WorldEditAxe/eaglerproxy.git
synced 2024-11-21 21:16:05 -08:00
Eaglercraft skin support
This commit is contained in:
parent
50f3dd011b
commit
b8c8a67355
27
listener.ts
27
listener.ts
|
@ -1,8 +1,8 @@
|
||||||
import { ProxiedPlayer } from "./classes.js";
|
import { EAGLERCRAFT_SKIN_CHANNEL_NAME } from "./eaglerPacketDef.js";
|
||||||
|
import { processClientReqPacket, unpackChannelMessage } from "./eaglerSkin.js";
|
||||||
import { Logger } from "./logger.js";
|
import { Logger } from "./logger.js";
|
||||||
import { handleMotd } from "./motd.js";
|
import { State, ProxiedPlayer } from "./types.js";
|
||||||
import { State } from "./types.js";
|
import { doHandshake, handleMotd } from "./utils.js";
|
||||||
import { doHandshake } from "./utils.js";
|
|
||||||
|
|
||||||
const logger = new Logger("PacketHandler")
|
const logger = new Logger("PacketHandler")
|
||||||
|
|
||||||
|
@ -13,13 +13,28 @@ export function handlePacket(packet: Buffer, client: ProxiedPlayer) {
|
||||||
} else if (!(client as any)._handled) {
|
} else if (!(client as any)._handled) {
|
||||||
;(client as any)._handled = true
|
;(client as any)._handled = true
|
||||||
doHandshake(client, packet)
|
doHandshake(client, packet)
|
||||||
|
.catch(err => {
|
||||||
|
logger.warn(`Error occurred whilst handling handshake! Error: ${err.stack ?? err}`)
|
||||||
|
})
|
||||||
|
} else if (!(client as any)._handled && packet[0] == 0x17) {
|
||||||
|
const decoded = unpackChannelMessage(packet)
|
||||||
|
if (decoded.channel == EAGLERCRAFT_SKIN_CHANNEL_NAME) {
|
||||||
|
client.queuedEaglerSkinPackets.push(decoded)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (client.state == State.POST_HANDSHAKE) {
|
} else if (client.state == State.POST_HANDSHAKE) {
|
||||||
if (!client.remoteConnection || client.remoteConnection.socket.closed) {
|
if (!client.remoteConnection || client.remoteConnection.socket.closed) {
|
||||||
logger.warn(`Player ${client.username} is marked as post handshake, but is disconnected from the game server? Disconnecting due to illegal state.`)
|
logger.warn(`Received packet from player ${client.username} that is marked as post handshake, but is disconnected from the game server? Disconnecting due to illegal state.`)
|
||||||
client.ws.close()
|
client.ws.close()
|
||||||
} else {
|
} else {
|
||||||
client.remoteConnection.writeRaw(packet)
|
if (packet[0] == 0x17) {
|
||||||
|
const decoded = unpackChannelMessage(packet)
|
||||||
|
if (decoded.channel == EAGLERCRAFT_SKIN_CHANNEL_NAME) {
|
||||||
|
processClientReqPacket(decoded, client)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client.remoteConnection.writeRaw(packet)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user