Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyBananaGAME committed Oct 30, 2024
1 parent 3f33d93 commit 08a17d6
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 259 deletions.
503 changes: 272 additions & 231 deletions src/client/client.ts

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/client/framer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class Framer {
private inputHighestSequenceIndex: number[] = new Array(64).fill(0);
private inputOrderIndex: number[] = new Array(64).fill(0);
protected inputOrderingQueue: Map<number, Map<number, Frame>> = new Map();
protected readonly fragmentsQueue: Map<number, Map<number, Frame>> = new Map();
protected readonly fragmentsQueue: Map<number, Map<number, Frame>> =
new Map();

public outputOrderIndex: number[];
public outputSequenceIndex: number[];
Expand All @@ -47,7 +48,6 @@ export class Framer {
for (let index = 0; index < 64; index++) {
this.inputOrderingQueue.set(index, new Map());
}

}

public tick() {
Expand Down Expand Up @@ -93,7 +93,7 @@ export class Framer {
try {
if (this.receivedFrameSequences.has(frameSet.sequence)) {
if (this.client.options.debug)
Logger.debug(`Received duplicate frameset ${frameSet.sequence}`);
Logger.debug(`Received duplicate frameset ${frameSet.sequence}`);
return;
}
this.lostFrameSequences.delete(frameSet.sequence);
Expand Down Expand Up @@ -128,11 +128,11 @@ export class Framer {
try {
this.handleFrame(frame);
} catch (err) {
Logger.error("Error handling frame", (err as Error));
Logger.error("Error handling frame", err as Error);
}
}
} catch (err) {
Logger.error("Error handling frameset", (err as Error));
Logger.error("Error handling frameset", err as Error);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/proto/decorators/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import type { ValidTypes } from "../types";
/**
* Thanks to SerenityJS as an example.
* @param id
* @returns
* @param id
* @returns
*/
export function Create(id: number) {
return (target: typeof BasePacket) => {
Expand Down
2 changes: 1 addition & 1 deletion src/proto/enums/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ export enum Packet {
Reserved8 = 0x84,
Reserved9 = 0x85,
UserPacketEnum = 0x86,
Nack = 0xa0,
Nack = 0xa0,
Ack = 0xc0,
}
2 changes: 1 addition & 1 deletion src/proto/packets/nack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ class Nack extends BasePacket {
}
}

export { Nack };
export { Nack };
4 changes: 2 additions & 2 deletions src/proto/packets/types/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Address extends DataType {
const address = bytes.map((byte) => (byte ^ 0xff).toString()).join(".");
const port = stream.readUShort();
return new Address(address, port, version);
// biome-ignore lint/style/noUselessElse: <explanation>
// biome-ignore lint/style/noUselessElse: <explanation>
} else if (version === 6) {
stream.skip(2);
const port = stream.readUShort();
Expand All @@ -98,7 +98,7 @@ export class Address extends DataType {
addressParts.push(part.toString(16).padStart(4, "0"));
}
const address = addressParts.join(":");
stream.skip(4);
stream.skip(4);
return new Address(address, port, version);
}
return new Address("0.0.0.0", 0, 0);
Expand Down
13 changes: 4 additions & 9 deletions src/proto/packets/types/sys-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,17 @@ export class SystemAddress extends DataType {
addresses.push(address);
}
} catch (error) {
console.error('Error reading system addresses:', error);
console.error("Error reading system addresses:", error);
}
return addresses;
}

public static write(stream: BinaryStream): void {
const addresses: Array<Address> = [
new Address("127.0.0.1", 0, 4),
];
const addresses: Array<Address> = [new Address("127.0.0.1", 0, 4)];
const count = SystemAddress.count === 0 ? 10 : SystemAddress.count;

for (let index = 0; index < count; index++) {
Address.write(
stream,
addresses[index] || new Address("0.0.0.0", 0, 4),
);
Address.write(stream, addresses[index] || new Address("0.0.0.0", 0, 4));
}
}
}
24 changes: 16 additions & 8 deletions src/tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import "reflect-metadata";
import { Client } from "../client/client";

const client = new Client({ address: "hivebedrock.network", port: 19132, protocolVersion: 11, debug: true });
const client = new Client({
address: "hivebedrock.network",
port: 19132,
protocolVersion: 11,
debug: true,
});

client.on("connect", () => {
console.log("Connected to server");
console.log("Connected to server");
});
console.time("connect");
client.connect().then((advertisement) => {
console.log(advertisement);
console.timeEnd("connect");
}).catch((err) => {
console.error(err);
});
client
.connect()
.then((advertisement) => {
console.log(advertisement);
console.timeEnd("connect");
})
.catch((err) => {
console.error(err);
});

0 comments on commit 08a17d6

Please sign in to comment.