From 055627bb63bd2a28c02281fae27d1cff813eb3a9 Mon Sep 17 00:00:00 2001 From: Holly Date: Thu, 22 Jun 2023 12:43:28 +0100 Subject: [PATCH] Migrate to bufferstuff module --- .gitmodules | 3 --- package.json | 3 ++- server/MPClient.ts | 2 +- server/MetadataWriter.ts | 3 +-- server/MinecraftServer.ts | 4 +--- server/WorldSaveManager.ts | 3 +-- server/packets/Animation.ts | 4 +--- server/packets/BlockChange.ts | 4 +--- server/packets/Chat.ts | 4 +--- server/packets/DisconnectKick.ts | 4 +--- server/packets/Entity.ts | 4 +--- server/packets/EntityAction.ts | 4 +--- server/packets/EntityEquipment.ts | 4 +--- server/packets/EntityLook.ts | 4 +--- server/packets/EntityLookRelativeMove.ts | 4 +--- server/packets/EntityMetadata.ts | 4 +--- server/packets/EntityRelativeMove.ts | 4 +--- server/packets/EntityTeleport.ts | 4 +--- server/packets/Handshake.ts | 4 +--- server/packets/IPacket.ts | 2 +- server/packets/KeepAlive.ts | 4 +--- server/packets/LoginRequest.ts | 4 +--- server/packets/MapChunk.ts | 4 +--- server/packets/NamedEntitySpawn.ts | 4 +--- server/packets/Player.ts | 4 +--- server/packets/PlayerDigging.ts | 4 +--- server/packets/PlayerLook.ts | 4 +--- server/packets/PlayerPosition.ts | 4 +--- server/packets/PlayerPositionLook.ts | 4 +--- server/packets/PreChunk.ts | 4 +--- server/packets/Respawn.ts | 4 +--- server/packets/SpawnPosition.ts | 4 +--- server/packets/TimeUpdate.ts | 4 +--- server/packets/UpdateHealth.ts | 4 +--- server/packets/UseEntity.ts | 4 +--- 35 files changed, 35 insertions(+), 97 deletions(-) diff --git a/.gitmodules b/.gitmodules index e8f945f..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "bufferStuff"] - path = bufferStuff - url = https://github.com/tgpholly/bufferStuff.git diff --git a/package.json b/package.json index b94bfd6..d958bc0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "homepage": "https://github.com/tgpholly/mc-beta-server#readme", "dependencies": { "chalk": "^4.1.2", - "net": "^1.0.2" + "net": "^1.0.2", + "bufferstuff": "^1.3.0" }, "devDependencies": { "@types/node": "^18.16.3", diff --git a/server/MPClient.ts b/server/MPClient.ts index 870a87b..0518b9d 100644 --- a/server/MPClient.ts +++ b/server/MPClient.ts @@ -1,5 +1,5 @@ import { Console } from "../console"; -import { IReader } from "../bufferStuff/readers/IReader"; +import { IReader } from "bufferstuff"; import { MinecraftServer } from "./MinecraftServer"; import { Packet } from "./enums/Packet"; import { PacketAnimation } from "./packets/Animation"; diff --git a/server/MetadataWriter.ts b/server/MetadataWriter.ts index 79b0d5b..15e79c6 100644 --- a/server/MetadataWriter.ts +++ b/server/MetadataWriter.ts @@ -1,5 +1,4 @@ -import { createWriter } from "../bufferStuff/index"; -import { Endian } from "../bufferStuff/Endian"; +import { createWriter, Endian } from "bufferstuff"; import { FunkyArray } from "../funkyArray"; import { MetadataFieldType } from "./enums/MetadataFieldType"; diff --git a/server/MinecraftServer.ts b/server/MinecraftServer.ts index f908edf..0d05fdf 100644 --- a/server/MinecraftServer.ts +++ b/server/MinecraftServer.ts @@ -1,8 +1,7 @@ import { Config } from "../config"; import { Console } from "../console"; -import { createReader } from "../bufferStuff/index"; +import { createReader, IReader, Endian } from "bufferstuff"; import { FunkyArray } from "../funkyArray"; -import { IReader } from "../bufferStuff/readers/IReader"; import { Server, Socket, SocketAddress } from "net"; import { MPClient } from "./MPClient"; import { Packet } from "./enums/Packet"; @@ -18,7 +17,6 @@ import { Player } from "./entities/Player"; import { SaveCompressionType } from "./enums/SaveCompressionType"; import { WorldSaveManager } from "./WorldSaveManager"; import { World } from "./World"; -import { Endian } from "../bufferStuff/Endian"; export class MinecraftServer { private static readonly PROTOCOL_VERSION = 14; diff --git a/server/WorldSaveManager.ts b/server/WorldSaveManager.ts index 2f47ce0..046d7b5 100644 --- a/server/WorldSaveManager.ts +++ b/server/WorldSaveManager.ts @@ -1,11 +1,10 @@ import { readFileSync, readFile, writeFile, existsSync, mkdirSync, writeFileSync, readdirSync } from "fs"; -import { createWriter, createReader } from "../bufferStuff/index"; +import { createWriter, createReader, Endian } from "bufferstuff"; import { Config } from "../config"; import { Chunk } from "./Chunk"; import { SaveCompressionType } from "./enums/SaveCompressionType"; import { deflate, inflate } from "zlib"; import { World } from "./World"; -import { Endian } from "../bufferStuff/Endian"; export class WorldSaveManager { private readonly worldFolderPath; diff --git a/server/packets/Animation.ts b/server/packets/Animation.ts index c3d2bca..b6bad6d 100644 --- a/server/packets/Animation.ts +++ b/server/packets/Animation.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketAnimation implements IPacket { diff --git a/server/packets/BlockChange.ts b/server/packets/BlockChange.ts index aaced44..f24618a 100644 --- a/server/packets/BlockChange.ts +++ b/server/packets/BlockChange.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketBlockChange implements IPacket { diff --git a/server/packets/Chat.ts b/server/packets/Chat.ts index 01010ec..94334d6 100644 --- a/server/packets/Chat.ts +++ b/server/packets/Chat.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketChat implements IPacket { diff --git a/server/packets/DisconnectKick.ts b/server/packets/DisconnectKick.ts index 6645886..fdf6de6 100644 --- a/server/packets/DisconnectKick.ts +++ b/server/packets/DisconnectKick.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketDisconnectKick implements IPacket { diff --git a/server/packets/Entity.ts b/server/packets/Entity.ts index 41cdd3b..31d99e9 100644 --- a/server/packets/Entity.ts +++ b/server/packets/Entity.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntity implements IPacket { diff --git a/server/packets/EntityAction.ts b/server/packets/EntityAction.ts index 88c5919..4bf1e8a 100644 --- a/server/packets/EntityAction.ts +++ b/server/packets/EntityAction.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntityAction implements IPacket { diff --git a/server/packets/EntityEquipment.ts b/server/packets/EntityEquipment.ts index 8a5df21..2cdcec8 100644 --- a/server/packets/EntityEquipment.ts +++ b/server/packets/EntityEquipment.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntityEquipment implements IPacket { diff --git a/server/packets/EntityLook.ts b/server/packets/EntityLook.ts index 4277236..5147b52 100644 --- a/server/packets/EntityLook.ts +++ b/server/packets/EntityLook.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntityLook implements IPacket { diff --git a/server/packets/EntityLookRelativeMove.ts b/server/packets/EntityLookRelativeMove.ts index 6a9565f..21c4857 100644 --- a/server/packets/EntityLookRelativeMove.ts +++ b/server/packets/EntityLookRelativeMove.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntityLookRelativeMove implements IPacket { diff --git a/server/packets/EntityMetadata.ts b/server/packets/EntityMetadata.ts index ed9f56f..8bf3e06 100644 --- a/server/packets/EntityMetadata.ts +++ b/server/packets/EntityMetadata.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; const EMPTY_BUFFER = Buffer.alloc(0); diff --git a/server/packets/EntityRelativeMove.ts b/server/packets/EntityRelativeMove.ts index 5612370..6669416 100644 --- a/server/packets/EntityRelativeMove.ts +++ b/server/packets/EntityRelativeMove.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntityRelativeMove implements IPacket { diff --git a/server/packets/EntityTeleport.ts b/server/packets/EntityTeleport.ts index 36a13f1..bcd3bfc 100644 --- a/server/packets/EntityTeleport.ts +++ b/server/packets/EntityTeleport.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketEntityTeleport implements IPacket { diff --git a/server/packets/Handshake.ts b/server/packets/Handshake.ts index 798a2dd..34e0fbd 100644 --- a/server/packets/Handshake.ts +++ b/server/packets/Handshake.ts @@ -1,7 +1,5 @@ -import { createReader, createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketHandshake implements IPacket { diff --git a/server/packets/IPacket.ts b/server/packets/IPacket.ts index 98a4588..9d29751 100644 --- a/server/packets/IPacket.ts +++ b/server/packets/IPacket.ts @@ -1,4 +1,4 @@ -import { IReader } from "../../bufferStuff/readers/IReader"; +import { IReader } from "bufferstuff"; import { Packet } from "../enums/Packet"; export interface IPacket { diff --git a/server/packets/KeepAlive.ts b/server/packets/KeepAlive.ts index d562a01..897b7b4 100644 --- a/server/packets/KeepAlive.ts +++ b/server/packets/KeepAlive.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketKeepAlive implements IPacket { diff --git a/server/packets/LoginRequest.ts b/server/packets/LoginRequest.ts index e60f99c..2abb764 100644 --- a/server/packets/LoginRequest.ts +++ b/server/packets/LoginRequest.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketLoginRequest implements IPacket { diff --git a/server/packets/MapChunk.ts b/server/packets/MapChunk.ts index 0fac4a9..c54c361 100644 --- a/server/packets/MapChunk.ts +++ b/server/packets/MapChunk.ts @@ -1,9 +1,7 @@ +import { createWriter, IReader, Endian } from "bufferstuff"; import { Chunk } from "../Chunk"; -import { createWriter } from "../../bufferStuff/index"; import { deflate } from "zlib"; -import { Endian } from "../../bufferStuff/Endian"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketMapChunk implements IPacket { diff --git a/server/packets/NamedEntitySpawn.ts b/server/packets/NamedEntitySpawn.ts index 0fc5339..4363f1a 100644 --- a/server/packets/NamedEntitySpawn.ts +++ b/server/packets/NamedEntitySpawn.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketNamedEntitySpawn implements IPacket { diff --git a/server/packets/Player.ts b/server/packets/Player.ts index 3576736..422cd27 100644 --- a/server/packets/Player.ts +++ b/server/packets/Player.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketPlayer implements IPacket { diff --git a/server/packets/PlayerDigging.ts b/server/packets/PlayerDigging.ts index 28de656..558ec1f 100644 --- a/server/packets/PlayerDigging.ts +++ b/server/packets/PlayerDigging.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketPlayerDigging implements IPacket { diff --git a/server/packets/PlayerLook.ts b/server/packets/PlayerLook.ts index 6deb716..d0b3954 100644 --- a/server/packets/PlayerLook.ts +++ b/server/packets/PlayerLook.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketPlayerLook implements IPacket { diff --git a/server/packets/PlayerPosition.ts b/server/packets/PlayerPosition.ts index 4164d70..8d6d992 100644 --- a/server/packets/PlayerPosition.ts +++ b/server/packets/PlayerPosition.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketPlayerPosition implements IPacket { diff --git a/server/packets/PlayerPositionLook.ts b/server/packets/PlayerPositionLook.ts index 3341cb2..8357892 100644 --- a/server/packets/PlayerPositionLook.ts +++ b/server/packets/PlayerPositionLook.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketPlayerPositionLook implements IPacket { diff --git a/server/packets/PreChunk.ts b/server/packets/PreChunk.ts index 6ac7462..61d0899 100644 --- a/server/packets/PreChunk.ts +++ b/server/packets/PreChunk.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketPreChunk implements IPacket { diff --git a/server/packets/Respawn.ts b/server/packets/Respawn.ts index d69a19e..b2fbea9 100644 --- a/server/packets/Respawn.ts +++ b/server/packets/Respawn.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketRespawn implements IPacket { diff --git a/server/packets/SpawnPosition.ts b/server/packets/SpawnPosition.ts index feed560..7d099a6 100644 --- a/server/packets/SpawnPosition.ts +++ b/server/packets/SpawnPosition.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketSpawnPosition implements IPacket { diff --git a/server/packets/TimeUpdate.ts b/server/packets/TimeUpdate.ts index ebab851..c48dbfb 100644 --- a/server/packets/TimeUpdate.ts +++ b/server/packets/TimeUpdate.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketTimeUpdate implements IPacket { diff --git a/server/packets/UpdateHealth.ts b/server/packets/UpdateHealth.ts index 34bb926..221ae6e 100644 --- a/server/packets/UpdateHealth.ts +++ b/server/packets/UpdateHealth.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketUpdateHealth implements IPacket { diff --git a/server/packets/UseEntity.ts b/server/packets/UseEntity.ts index 8f2a15d..e56419c 100644 --- a/server/packets/UseEntity.ts +++ b/server/packets/UseEntity.ts @@ -1,7 +1,5 @@ -import { createWriter } from "../../bufferStuff/index"; -import { Endian } from "../../bufferStuff/Endian"; +import { createWriter, IReader, Endian } from "bufferstuff"; import { IPacket } from "./IPacket"; -import { IReader } from "../../bufferStuff/readers/IReader"; import { Packet } from "../enums/Packet"; export class PacketUseEntity implements IPacket {