Migrate to bufferstuff module

This commit is contained in:
Holly Stubbs 2023-06-22 12:43:28 +01:00
parent 5fd4f50b1a
commit 055627bb63
35 changed files with 35 additions and 97 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "bufferStuff"]
path = bufferStuff
url = https://github.com/tgpholly/bufferStuff.git

View file

@ -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",

View file

@ -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";

View file

@ -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";

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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);

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -1,4 +1,4 @@
import { IReader } from "../../bufferStuff/readers/IReader";
import { IReader } from "bufferstuff";
import { Packet } from "../enums/Packet";
export interface IPacket {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {