fix a bunch of codefactor issues

This commit is contained in:
Holly Stubbs 2023-06-26 09:53:45 +01:00
parent 44f8568cdb
commit 21a9f64a9e
5 changed files with 7 additions and 11 deletions

View file

@ -1,5 +1,5 @@
import chalk from "chalk"; import chalk from "chalk";
import { createWriteStream, mkdirSync, existsSync, fstat } from "fs"; import { createWriteStream, mkdirSync, existsSync } from "fs";
console.clear(); console.clear();
@ -56,9 +56,8 @@ function log(tag:LogTag, log:string, logType:LogType = LogType.INFO) : void {
} }
} }
if (existsSync("./logs")) { // TODO: Keep old logs, rename on startup using file header?
if (!existsSync("./logs")) {
} else {
mkdirSync("./logs/"); mkdirSync("./logs/");
} }

View file

@ -2,7 +2,7 @@ import { Config } from "../config";
import { Console } from "../console"; import { Console } from "../console";
import { createReader, IReader, Endian } from "bufferstuff"; import { createReader, IReader, Endian } from "bufferstuff";
import { FunkyArray } from "../funkyArray"; import { FunkyArray } from "../funkyArray";
import { Server, Socket, SocketAddress } from "net"; import { Server, Socket } from "net";
import { MPClient } from "./MPClient"; import { MPClient } from "./MPClient";
import { Packet } from "./enums/Packet"; import { Packet } from "./enums/Packet";
import { PacketKeepAlive } from "./packets/KeepAlive"; import { PacketKeepAlive } from "./packets/KeepAlive";

View file

@ -81,7 +81,7 @@ export class World {
} }
public getChunkSafe(x:number, z:number) { public getChunkSafe(x:number, z:number) {
return new Promise<Chunk>((resolve, reject) => { return new Promise<Chunk>((resolve) => {
const coordPair = Chunk.CreateCoordPair(x, z); const coordPair = Chunk.CreateCoordPair(x, z);
const existingChunk = this.chunks.get(coordPair); const existingChunk = this.chunks.get(coordPair);
if (!(existingChunk instanceof Chunk)) { if (!(existingChunk instanceof Chunk)) {

View file

@ -47,7 +47,7 @@ export class WorldSaveManager {
mkdirSync(this.worldChunksFolderPath); mkdirSync(this.worldChunksFolderPath);
} else { } else {
const chunkFiles = readdirSync(this.worldChunksFolderPath); const chunkFiles = readdirSync(this.worldChunksFolderPath);
for (let file of chunkFiles) { for (const file of chunkFiles) {
if (file.endsWith(".hwc")) { if (file.endsWith(".hwc")) {
const numbers = file.split(".")[0].split(","); const numbers = file.split(".")[0].split(",");
this.chunksOnDisk.push(Chunk.CreateCoordPair(parseInt(numbers[0]), parseInt(numbers[1]))); this.chunksOnDisk.push(Chunk.CreateCoordPair(parseInt(numbers[0]), parseInt(numbers[1])));
@ -86,9 +86,6 @@ export class WorldSaveManager {
} }
public writeChunkToDisk(chunk:Chunk) { public writeChunkToDisk(chunk:Chunk) {
return new Promise<boolean>((resolve, reject) => {
resolve(false);
});
return new Promise<boolean>((resolve, reject) => { return new Promise<boolean>((resolve, reject) => {
const saveType = this.config.saveCompression; const saveType = this.config.saveCompression;
const chunkFileWriter = createWriter(Endian.BE, 10); const chunkFileWriter = createWriter(Endian.BE, 10);

View file

@ -80,6 +80,6 @@ export class EntityLiving extends Entity {
} }
this.lastYaw = this.yaw; this.lastYaw = this.yaw;
this.lastPitch = this.lastPitch; this.lastPitch = this.pitch;
} }
} }