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", "homepage": "https://github.com/tgpholly/mc-beta-server#readme",
"dependencies": { "dependencies": {
"chalk": "^4.1.2", "chalk": "^4.1.2",
"net": "^1.0.2" "net": "^1.0.2",
"bufferstuff": "^1.3.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.16.3", "@types/node": "^18.16.3",

View file

@ -1,5 +1,5 @@
import { Console } from "../console"; import { Console } from "../console";
import { IReader } from "../bufferStuff/readers/IReader"; import { IReader } from "bufferstuff";
import { MinecraftServer } from "./MinecraftServer"; import { MinecraftServer } from "./MinecraftServer";
import { Packet } from "./enums/Packet"; import { Packet } from "./enums/Packet";
import { PacketAnimation } from "./packets/Animation"; import { PacketAnimation } from "./packets/Animation";

View file

@ -1,5 +1,4 @@
import { createWriter } from "../bufferStuff/index"; import { createWriter, Endian } from "bufferstuff";
import { Endian } from "../bufferStuff/Endian";
import { FunkyArray } from "../funkyArray"; import { FunkyArray } from "../funkyArray";
import { MetadataFieldType } from "./enums/MetadataFieldType"; import { MetadataFieldType } from "./enums/MetadataFieldType";

View file

@ -1,8 +1,7 @@
import { Config } from "../config"; import { Config } from "../config";
import { Console } from "../console"; import { Console } from "../console";
import { createReader } from "../bufferStuff/index"; import { createReader, IReader, Endian } from "bufferstuff";
import { FunkyArray } from "../funkyArray"; import { FunkyArray } from "../funkyArray";
import { IReader } from "../bufferStuff/readers/IReader";
import { Server, Socket, SocketAddress } from "net"; import { Server, Socket, SocketAddress } from "net";
import { MPClient } from "./MPClient"; import { MPClient } from "./MPClient";
import { Packet } from "./enums/Packet"; import { Packet } from "./enums/Packet";
@ -18,7 +17,6 @@ import { Player } from "./entities/Player";
import { SaveCompressionType } from "./enums/SaveCompressionType"; import { SaveCompressionType } from "./enums/SaveCompressionType";
import { WorldSaveManager } from "./WorldSaveManager"; import { WorldSaveManager } from "./WorldSaveManager";
import { World } from "./World"; import { World } from "./World";
import { Endian } from "../bufferStuff/Endian";
export class MinecraftServer { export class MinecraftServer {
private static readonly PROTOCOL_VERSION = 14; private static readonly PROTOCOL_VERSION = 14;

View file

@ -1,11 +1,10 @@
import { readFileSync, readFile, writeFile, existsSync, mkdirSync, writeFileSync, readdirSync } from "fs"; 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 { Config } from "../config";
import { Chunk } from "./Chunk"; import { Chunk } from "./Chunk";
import { SaveCompressionType } from "./enums/SaveCompressionType"; import { SaveCompressionType } from "./enums/SaveCompressionType";
import { deflate, inflate } from "zlib"; import { deflate, inflate } from "zlib";
import { World } from "./World"; import { World } from "./World";
import { Endian } from "../bufferStuff/Endian";
export class WorldSaveManager { export class WorldSaveManager {
private readonly worldFolderPath; private readonly worldFolderPath;

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketAnimation implements IPacket { export class PacketAnimation implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketBlockChange implements IPacket { export class PacketBlockChange implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketChat implements IPacket { export class PacketChat implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketDisconnectKick implements IPacket { export class PacketDisconnectKick implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntity implements IPacket { export class PacketEntity implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntityAction implements IPacket { export class PacketEntityAction implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntityEquipment implements IPacket { export class PacketEntityEquipment implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntityLook implements IPacket { export class PacketEntityLook implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntityLookRelativeMove implements IPacket { export class PacketEntityLookRelativeMove implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
const EMPTY_BUFFER = Buffer.alloc(0); const EMPTY_BUFFER = Buffer.alloc(0);

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntityRelativeMove implements IPacket { export class PacketEntityRelativeMove implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketEntityTeleport implements IPacket { export class PacketEntityTeleport implements IPacket {

View file

@ -1,7 +1,5 @@
import { createReader, createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketHandshake implements IPacket { 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"; import { Packet } from "../enums/Packet";
export interface IPacket { export interface IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketKeepAlive implements IPacket { export class PacketKeepAlive implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketLoginRequest implements IPacket { export class PacketLoginRequest implements IPacket {

View file

@ -1,9 +1,7 @@
import { createWriter, IReader, Endian } from "bufferstuff";
import { Chunk } from "../Chunk"; import { Chunk } from "../Chunk";
import { createWriter } from "../../bufferStuff/index";
import { deflate } from "zlib"; import { deflate } from "zlib";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketMapChunk implements IPacket { export class PacketMapChunk implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketNamedEntitySpawn implements IPacket { export class PacketNamedEntitySpawn implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketPlayer implements IPacket { export class PacketPlayer implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketPlayerDigging implements IPacket { export class PacketPlayerDigging implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketPlayerLook implements IPacket { export class PacketPlayerLook implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketPlayerPosition implements IPacket { export class PacketPlayerPosition implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketPlayerPositionLook implements IPacket { export class PacketPlayerPositionLook implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketPreChunk implements IPacket { export class PacketPreChunk implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketRespawn implements IPacket { export class PacketRespawn implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketSpawnPosition implements IPacket { export class PacketSpawnPosition implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketTimeUpdate implements IPacket { export class PacketTimeUpdate implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketUpdateHealth implements IPacket { export class PacketUpdateHealth implements IPacket {

View file

@ -1,7 +1,5 @@
import { createWriter } from "../../bufferStuff/index"; import { createWriter, IReader, Endian } from "bufferstuff";
import { Endian } from "../../bufferStuff/Endian";
import { IPacket } from "./IPacket"; import { IPacket } from "./IPacket";
import { IReader } from "../../bufferStuff/readers/IReader";
import { Packet } from "../enums/Packet"; import { Packet } from "../enums/Packet";
export class PacketUseEntity implements IPacket { export class PacketUseEntity implements IPacket {