From 21a9f64a9e15d033bcd2e681399716dd65fef907 Mon Sep 17 00:00:00 2001 From: Holly Date: Mon, 26 Jun 2023 09:53:45 +0100 Subject: [PATCH] fix a bunch of codefactor issues --- console.ts | 7 +++---- server/MinecraftServer.ts | 2 +- server/World.ts | 2 +- server/WorldSaveManager.ts | 5 +---- server/entities/EntityLiving.ts | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/console.ts b/console.ts index 792a455..11aebd8 100644 --- a/console.ts +++ b/console.ts @@ -1,5 +1,5 @@ import chalk from "chalk"; -import { createWriteStream, mkdirSync, existsSync, fstat } from "fs"; +import { createWriteStream, mkdirSync, existsSync } from "fs"; console.clear(); @@ -56,9 +56,8 @@ function log(tag:LogTag, log:string, logType:LogType = LogType.INFO) : void { } } -if (existsSync("./logs")) { - -} else { +// TODO: Keep old logs, rename on startup using file header? +if (!existsSync("./logs")) { mkdirSync("./logs/"); } diff --git a/server/MinecraftServer.ts b/server/MinecraftServer.ts index 0d05fdf..5687452 100644 --- a/server/MinecraftServer.ts +++ b/server/MinecraftServer.ts @@ -2,7 +2,7 @@ import { Config } from "../config"; import { Console } from "../console"; import { createReader, IReader, Endian } from "bufferstuff"; import { FunkyArray } from "../funkyArray"; -import { Server, Socket, SocketAddress } from "net"; +import { Server, Socket } from "net"; import { MPClient } from "./MPClient"; import { Packet } from "./enums/Packet"; import { PacketKeepAlive } from "./packets/KeepAlive"; diff --git a/server/World.ts b/server/World.ts index 1655abc..a13ce5c 100644 --- a/server/World.ts +++ b/server/World.ts @@ -81,7 +81,7 @@ export class World { } public getChunkSafe(x:number, z:number) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { const coordPair = Chunk.CreateCoordPair(x, z); const existingChunk = this.chunks.get(coordPair); if (!(existingChunk instanceof Chunk)) { diff --git a/server/WorldSaveManager.ts b/server/WorldSaveManager.ts index 046d7b5..067e544 100644 --- a/server/WorldSaveManager.ts +++ b/server/WorldSaveManager.ts @@ -47,7 +47,7 @@ export class WorldSaveManager { mkdirSync(this.worldChunksFolderPath); } else { const chunkFiles = readdirSync(this.worldChunksFolderPath); - for (let file of chunkFiles) { + for (const file of chunkFiles) { if (file.endsWith(".hwc")) { const numbers = file.split(".")[0].split(","); this.chunksOnDisk.push(Chunk.CreateCoordPair(parseInt(numbers[0]), parseInt(numbers[1]))); @@ -86,9 +86,6 @@ export class WorldSaveManager { } public writeChunkToDisk(chunk:Chunk) { - return new Promise((resolve, reject) => { - resolve(false); - }); return new Promise((resolve, reject) => { const saveType = this.config.saveCompression; const chunkFileWriter = createWriter(Endian.BE, 10); diff --git a/server/entities/EntityLiving.ts b/server/entities/EntityLiving.ts index 8e27441..6f6bc50 100644 --- a/server/entities/EntityLiving.ts +++ b/server/entities/EntityLiving.ts @@ -80,6 +80,6 @@ export class EntityLiving extends Entity { } this.lastYaw = this.yaw; - this.lastPitch = this.lastPitch; + this.lastPitch = this.pitch; } } \ No newline at end of file