Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyBananaGAME committed Oct 22, 2024
1 parent 7542e88 commit 630c137
Show file tree
Hide file tree
Showing 31 changed files with 920 additions and 769 deletions.
7 changes: 5 additions & 2 deletions src/Connection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Client as RakNetClient, type Advertisement } from "@sanctumterra/raknet";
import {
Client as RakNetClient,
type Advertisement,
} from "@sanctumterra/raknet";

import {
type ClientOptions,
Expand Down Expand Up @@ -71,7 +74,7 @@ class Connection extends Listener {
this.raknet = new RakNetClient({
host: this.options.host,
port: this.options.port,
debug: this.options.debug
debug: this.options.debug,
});
this.data = new ClientData(this);
this.packetSorter = new PacketSorter(this);
Expand Down
6 changes: 5 additions & 1 deletion src/tools/offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ setTimeout(() => {
client.on("TextPacket", handleTextPacket);
client.on("spawn", handleSpawn);
client.on("UpdateBlockPacket", handleUpdateBlockPacket);
client.on("StartGamePacket", (packet) => { console.log(`Logged in with UniqueID ${packet.entityId} and runtimeID ${packet.runtimeEntityId}`)});
client.on("StartGamePacket", (packet) => {
console.log(
`Logged in with UniqueID ${packet.entityId} and runtimeID ${packet.runtimeEntityId}`,
);
});
async function handleTextPacket(packet: TextPacket): Promise<void> {
if (!packet.parameters) return Logger.chat(packet.message);

Expand Down
2 changes: 1 addition & 1 deletion src/tools/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const client = new Client({
offline: false,
username: "SanctumTerra",
version: "1.21.30",
port: 19132
port: 19132,
});

try {
Expand Down
14 changes: 8 additions & 6 deletions src/vendor/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const colors: { [key: string]: string } = {

const specialFormatting: { [key: string]: string } = {
l: "\u001B[1m",
o: "\u001B[3m",
k: "\u001B[5m",
o: "\u001B[3m",
k: "\u001B[5m",
};

const Logger = {
Expand Down Expand Up @@ -81,14 +81,16 @@ const Logger = {

arg.replace(regex, (match, index) => {
const code = match[1].toLowerCase();
result += arg.slice(lastIndex, index) + (colors[code] || specialFormatting[code] || "");

result +=
arg.slice(lastIndex, index) +
(colors[code] || specialFormatting[code] || "");

if (colors[code]) {
currentColor = colors[code];
currentFormat = "";
} else if (specialFormatting[code]) {
currentFormat += specialFormatting[code];
} else if (code === 'r') {
} else if (code === "r") {
currentColor = "";
currentFormat = "";
}
Expand All @@ -98,7 +100,7 @@ const Logger = {
});

result += arg.slice(lastIndex);
return result + colors.r;
return result + colors.r;
});
},
};
Expand Down
14 changes: 7 additions & 7 deletions src/vendor/PacketSorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getPacketId,
Packet,
Packets,
SetScorePacket
SetScorePacket,
} from "@serenityjs/protocol";
import { deflateRawSync, inflateRawSync } from "node:zlib";
import { CraftingDataPacket } from "./packets/CraftingDataPacket";
Expand Down Expand Up @@ -215,27 +215,27 @@ export class PacketSorter {
PacketClass = MoveActorDeltaPacket;
}

if((id as number) === 162) {
if ((id as number) === 162) {
PacketClass = ItemComponentPacket;
}

if((id as number) === 39) {
if ((id as number) === 39) {
PacketClass = SetActorDataPacket;
}

if((id as number) === 13) {
if ((id as number) === 13) {
PacketClass = AddEntityPacket;
}

if((id as number) === 15) {
if ((id as number) === 15) {
PacketClass = AddItemActorPacket;
}

if((id as number) === 65) {
if ((id as number) === 65) {
PacketClass = LegacyTelemetryEventPacket;
}

if((id as number) === 172) {
if ((id as number) === 172) {
PacketClass = UpdateSubChunkBlocksPacket;
}

Expand Down
13 changes: 10 additions & 3 deletions src/vendor/packets/AddActorPacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import {
Float32,
VarLong,
VarString,
ZigZong
ZigZong,
} from "@serenityjs/binarystream";
import { DataPacket, EntityAttributes, Links, Packet, PropertySyncData, Vector3f } from "@serenityjs/protocol";
import {
DataPacket,
EntityAttributes,
Links,
Packet,
PropertySyncData,
Vector3f,
} from "@serenityjs/protocol";
import { Serialize, Proto } from "@serenityjs/raknet";
import { DataItem } from "./types/data-item";

Expand All @@ -26,4 +33,4 @@ class AddEntityPacket extends DataPacket {
@Serialize(Links) public links!: Array<Links>;
}

export { AddEntityPacket };
export { AddEntityPacket };
2 changes: 1 addition & 1 deletion src/vendor/packets/ItemComponentPacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ComponentItem } from "./types/ComponentItem";

@Proto(Packet.ItemComponent)
class ItemComponentPacket extends DataPacket {
@Serialize(ComponentItem) public items!: Array<ComponentItem>;
@Serialize(ComponentItem) public items!: Array<ComponentItem>;
}

export { ItemComponentPacket };
Loading

0 comments on commit 630c137

Please sign in to comment.