diff --git a/sample.env b/sample.env index 85d7f73..b1ab885 100644 --- a/sample.env +++ b/sample.env @@ -20,3 +20,11 @@ WS_CONNECTION_STRING=ws://localhost:3000 #Map ENABLE_WORLDMAP=false WORLDMAP_URL=http://localhost/map + +#Skins +SKINS_TARGET_DIRECTORY=/opt/skins +SKINS_URL=https://launcher.foxarmy.org/skins/%username%.png + +#Capes +CAPES_TARGET_DIRECTORY=/opt/cloaks +CAPES_URL=https://launcher.foxarmy.org/cloaks/%username%.png \ No newline at end of file diff --git a/src/config.js b/src/config.js index ea0af41..609160e 100644 --- a/src/config.js +++ b/src/config.js @@ -21,7 +21,13 @@ const config = { ws_connection_string: process.env.WS_CONNECTION_STRING, enable_worldmap: getBoolean(process.env.ENABLE_WORLDMAP), - worldmap_url: process.env.WORLDMAP_URL + worldmap_url: process.env.WORLDMAP_URL, + + skins_target_directory: process.env.SKINS_TARGET_DIRECTORY, + skins_url: process.env.SKINS_URL, + + capes_target_directory: process.env.CAPES_TARGET_DIRECTORY, + capes_url: process.env.CAPES_URL } export default config; \ No newline at end of file diff --git a/src/controllers/user.js b/src/controllers/user.js index 8c32f2b..9153a0d 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -76,12 +76,11 @@ class UserController { const token = req.cookies["jwt"]; const decoded = jwt.decode(token); const tempPath = req.file.path; - const targetPath = `/opt/skins/${decoded.username}.png`; + const targetPath = config.skins_target_directory + `/${decoded.username}.png`; if (path.extname(req.file.originalname).toLowerCase() !== ".png") { return res.status(400).send("Only .png files are allowed!"); } - const image = await Jimp.read(tempPath); if (image.bitmap.width != 64 || image.bitmap.height != 64) { @@ -98,13 +97,12 @@ class UserController { const token = req.cookies["jwt"]; const decoded = jwt.decode(token); const tempPath = req.file.path; - const targetPath = `/opt/cloaks/${decoded.username}.png`; + const targetPath = config.capes_target_directory + `/${decoded.username}.png`; if (path.extname(req.file.originalname).toLowerCase() !== ".png") { return res.status(400).send("Only .png files are allowed!"); } - const image = await Jimp.read(tempPath); if ((image.bitmap.width != 64 || image.bitmap.height != 32) && (image.bitmap.width != 128 || image.bitmap.height != 64)) { return res.status(400).send('This does not look like a minecraft cape.');