diff --git a/config.ts b/config.ts index c1fcff2..04237f9 100644 --- a/config.ts +++ b/config.ts @@ -1,8 +1,10 @@ +import { SaveCompressionType } from "./server/enums/SaveCompressionType"; + export interface Config { port: number, onlineMode: boolean, maxPlayers: number, seed: number|string, worldName: string, - saveCompression: "NONE" + saveCompression: SaveCompressionType } \ No newline at end of file diff --git a/index.ts b/index.ts index 594bd06..2989526 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,9 @@ import { Config } from "./config"; import { readFileSync } from "fs"; import { MinecraftServer } from "./server/MinecraftServer"; -const config:Config = JSON.parse(readFileSync("./config.json").toString()) as Config; +import { SaveCompressionType } from "./server/enums/SaveCompressionType"; +const tempConfig = JSON.parse(readFileSync("./config.json").toString()); +tempConfig.saveCompression = SaveCompressionType[tempConfig.saveCompression]; +const config:Config = tempConfig as Config; new MinecraftServer(config); \ No newline at end of file diff --git a/server/MinecraftServer.ts b/server/MinecraftServer.ts index 37ee378..5fb5b0e 100644 --- a/server/MinecraftServer.ts +++ b/server/MinecraftServer.ts @@ -16,6 +16,7 @@ import { PacketPlayerPositionLook } from "./packets/PlayerPositionLook"; import { PacketChat } from "./packets/Chat"; import { PacketNamedEntitySpawn } from "./packets/NamedEntitySpawn"; import { WorldSaveManager } from "./WorldSaveManager"; +import { SaveCompressionType } from "./enums/SaveCompressionType"; export class MinecraftServer { private static readonly PROTOCOL_VERSION = 14; @@ -50,7 +51,7 @@ export class MinecraftServer { public constructor(config:Config) { this.config = config; - if (this.config.saveCompression === "NONE") { + if (this.config.saveCompression === SaveCompressionType.NONE) { Console.printWarn("=============- WARNING -============="); Console.printWarn(" Chunk compression is disabled. This"); Console.printWarn(" will lead to large file sizes!"); diff --git a/server/WorldSaveManager.ts b/server/WorldSaveManager.ts index afe6dc2..38a5ca4 100644 --- a/server/WorldSaveManager.ts +++ b/server/WorldSaveManager.ts @@ -90,7 +90,7 @@ export class WorldSaveManager { resolve(true); });*/ return new Promise((resolve, reject) => { - const saveType = SaveCompressionType[this.config.saveCompression]; + const saveType = this.config.saveCompression; const chunkFileWriter = new Writer(10); chunkFileWriter.writeUByte(0xFC); // Chunk File Magic chunkFileWriter.writeUByte(0); // File Version