From a543a8d62bbcbbded4577426af5fc3b2d3080188 Mon Sep 17 00:00:00 2001 From: q13x <84165981+WorldEditAxe@users.noreply.github.com> Date: Fri, 24 May 2024 01:50:16 -0700 Subject: [PATCH] Handle failure to import jimp --- src/proxy/skins/ImageEditor.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/proxy/skins/ImageEditor.ts b/src/proxy/skins/ImageEditor.ts index 2d16551..0f18d9c 100644 --- a/src/proxy/skins/ImageEditor.ts +++ b/src/proxy/skins/ImageEditor.ts @@ -1,3 +1,4 @@ +import { Logger } from "../../logger.js"; import { Constants } from "../Constants.js"; import { Enums } from "../Enums.js"; import { MineProtocol } from "../Protocol.js"; @@ -17,7 +18,16 @@ export namespace ImageEditor { if (loadedLibraries) return; if (native) sharp = (await import("sharp")).default; else { - // Jimp = (await import("jimp")).default; + try { + Jimp = (await import("jimp")).default; + } catch (err) { + const logger = new Logger("ImageEditor.js"); + logger.fatal("**** ERROR: UNABLE TO LOAD JIMP!"); + logger.fatal("Please ensure that Jimp is installed by running 'npm install jimp' in the terminal."); + logger.fatal("If you'd like to use the faster native image editor, please set the 'useNatives' option in the config to true."); + logger.fatal(`Error: ${err.stack}`); + process.exit(1); + } Jimp.appendConstructorOption( "Custom Bitmap Constructor", (args) => args[0] && args[0].width != null && args[0].height != null && args[0].data != null,