read config compression type as SaveCompressionType
This commit is contained in:
parent
b1a4933990
commit
0653da20b2
4 changed files with 10 additions and 4 deletions
|
@ -1,8 +1,10 @@
|
||||||
|
import { SaveCompressionType } from "./server/enums/SaveCompressionType";
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
port: number,
|
port: number,
|
||||||
onlineMode: boolean,
|
onlineMode: boolean,
|
||||||
maxPlayers: number,
|
maxPlayers: number,
|
||||||
seed: number|string,
|
seed: number|string,
|
||||||
worldName: string,
|
worldName: string,
|
||||||
saveCompression: "NONE"
|
saveCompression: SaveCompressionType
|
||||||
}
|
}
|
5
index.ts
5
index.ts
|
@ -1,6 +1,9 @@
|
||||||
import { Config } from "./config";
|
import { Config } from "./config";
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import { MinecraftServer } from "./server/MinecraftServer";
|
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);
|
new MinecraftServer(config);
|
|
@ -16,6 +16,7 @@ import { PacketPlayerPositionLook } from "./packets/PlayerPositionLook";
|
||||||
import { PacketChat } from "./packets/Chat";
|
import { PacketChat } from "./packets/Chat";
|
||||||
import { PacketNamedEntitySpawn } from "./packets/NamedEntitySpawn";
|
import { PacketNamedEntitySpawn } from "./packets/NamedEntitySpawn";
|
||||||
import { WorldSaveManager } from "./WorldSaveManager";
|
import { WorldSaveManager } from "./WorldSaveManager";
|
||||||
|
import { SaveCompressionType } from "./enums/SaveCompressionType";
|
||||||
|
|
||||||
export class MinecraftServer {
|
export class MinecraftServer {
|
||||||
private static readonly PROTOCOL_VERSION = 14;
|
private static readonly PROTOCOL_VERSION = 14;
|
||||||
|
@ -50,7 +51,7 @@ export class MinecraftServer {
|
||||||
public constructor(config:Config) {
|
public constructor(config:Config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
if (this.config.saveCompression === "NONE") {
|
if (this.config.saveCompression === SaveCompressionType.NONE) {
|
||||||
Console.printWarn("=============- WARNING -=============");
|
Console.printWarn("=============- WARNING -=============");
|
||||||
Console.printWarn(" Chunk compression is disabled. This");
|
Console.printWarn(" Chunk compression is disabled. This");
|
||||||
Console.printWarn(" will lead to large file sizes!");
|
Console.printWarn(" will lead to large file sizes!");
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class WorldSaveManager {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});*/
|
});*/
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
const saveType = SaveCompressionType[this.config.saveCompression];
|
const saveType = this.config.saveCompression;
|
||||||
const chunkFileWriter = new Writer(10);
|
const chunkFileWriter = new Writer(10);
|
||||||
chunkFileWriter.writeUByte(0xFC); // Chunk File Magic
|
chunkFileWriter.writeUByte(0xFC); // Chunk File Magic
|
||||||
chunkFileWriter.writeUByte(0); // File Version
|
chunkFileWriter.writeUByte(0); // File Version
|
||||||
|
|
Loading…
Reference in a new issue