read config compression type as SaveCompressionType
This commit is contained in:
parent
b1a4933990
commit
0653da20b2
|
@ -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
|
||||
}
|
5
index.ts
5
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);
|
|
@ -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!");
|
||||
|
|
|
@ -90,7 +90,7 @@ export class WorldSaveManager {
|
|||
resolve(true);
|
||||
});*/
|
||||
return new Promise<boolean>((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
|
||||
|
|
Loading…
Reference in New Issue