From 61b667ac495778465b1983e5ccdc9db3f5c60ca3 Mon Sep 17 00:00:00 2001 From: Holly Date: Tue, 7 Nov 2023 01:50:35 +0000 Subject: [PATCH] Read multiple packets per chunk --- package-lock.json | 8 ++++---- package.json | 2 +- server/MPClient.ts | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30f2419..5d24ef6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "bufferstuff": "^1.3.4", + "bufferstuff": "^1.4.2", "hsconsole": "^1.0.2" }, "devDependencies": { @@ -563,9 +563,9 @@ "dev": true }, "node_modules/bufferstuff": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/bufferstuff/-/bufferstuff-1.3.4.tgz", - "integrity": "sha512-oBaMs5roIpkG242dWSoS38BWeVxlpTKVhRTRnGmZy5/6H+XU6YJMGa6jmPl7ychEnOqpuSA8wiq2k12zPt4BDA==" + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/bufferstuff/-/bufferstuff-1.4.2.tgz", + "integrity": "sha512-iCULTXTrD9O4C06u+gjgQ3RtVNXAfxoBmQbAh1nMRO7QENVNuC/UvbFk25x/PDMA9yhdkJtfLo2dwxSJvEjlSg==" }, "node_modules/call-bind": { "version": "1.0.2", diff --git a/package.json b/package.json index 3f85823..dfd6b3b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "homepage": "https://github.com/tgpholly/mc-beta-server#readme", "dependencies": { - "bufferstuff": "^1.3.4", + "bufferstuff": "^1.4.2", "hsconsole": "^1.0.2" }, "devDependencies": { diff --git a/server/MPClient.ts b/server/MPClient.ts index 0d6ab45..1006caf 100644 --- a/server/MPClient.ts +++ b/server/MPClient.ts @@ -83,7 +83,11 @@ export class MPClient { case Packet.Animation: this.handlePacketAnimation(new PacketAnimation().readData(reader)); break; case Packet.EntityAction: this.handlePacketEntityAction(new PacketEntityAction().readData(reader)); break; case Packet.DisconnectKick: this.handleDisconnectKick(); break; - default: Console.printWarn(`UNIMPLEMENTED PACKET: ${Packet[packetId]}`); break; + default: return Console.printWarn(`UNIMPLEMENTED PACKET: ${Packet[packetId]}`); + } + + if (reader.readOffset < reader.length - 1) { + this.handlePacket(reader); } }