From 95cbe26c5aecae4a687f86228d0f8b96e608c27c Mon Sep 17 00:00:00 2001 From: Seeroy <37861929+Seeroy@users.noreply.github.com> Date: Sun, 19 Feb 2023 17:44:36 +0300 Subject: [PATCH] 2.0.2-fix - Fixed server.properties editor - Fixed mods list --- app.js | 2 +- my_modules/servers.js | 2 +- routers/plugins.js | 2 +- www/pages/server_settings.js | 10 +++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 3288e3a..b29b737 100644 --- a/app.js +++ b/app.js @@ -147,7 +147,7 @@ global.currentFileWritingsText = []; global.ftpserver; // Kubek version -global.kubek_version = "v2.0.2"; +global.kubek_version = "v2.0.2-fix"; app.use(fileUpload()); app.use(cookieParser()); diff --git a/my_modules/servers.js b/my_modules/servers.js index d871778..e694b46 100644 --- a/my_modules/servers.js +++ b/my_modules/servers.js @@ -60,7 +60,7 @@ exports.getServerProperties = (name) => { } exports.saveServerProperties = (name, doc) => { - fs.writeFileSync("./servers/" + name + "/server.properties", Buffer.from(doc, 'base64').toString('ascii')); + fs.writeFileSync("./servers/" + name + "/server.properties", doc); return true; } diff --git a/routers/plugins.js b/routers/plugins.js index b0110ff..3ccb497 100644 --- a/routers/plugins.js +++ b/routers/plugins.js @@ -37,7 +37,7 @@ router.get('/installed', function (req, res) { router.get('/installedMods', function (req, res) { res.set("content-type", "application/json"); - if (fs.existsSync("./servers/" + req.query.server + "/plugins")) { + if (fs.existsSync("./servers/" + req.query.server + "/mods")) { res.send(plugins.getInstalledMods(req.query.server)); } else { res.send(JSON.stringify([])); diff --git a/www/pages/server_settings.js b/www/pages/server_settings.js index 2300d1f..b4d65c5 100644 --- a/www/pages/server_settings.js +++ b/www/pages/server_settings.js @@ -109,6 +109,9 @@ function refreshServerProperties() { fulls = data; keys.forEach(function (key, i) { znach = fulls[key]; + if(typeof znach == "object"){ + znach = JSON.stringify(znach).replace("null", "").trim();; + } if (typeof znach == "boolean") { if (znach == true) { checkd = " checked"; @@ -136,11 +139,11 @@ function refreshServerProperties() { } function saveProps() { - var sp; + var sp = ""; $(".ttgrid .cbox").each(function () { chk = $(this).find("input").is(':checked') ? true : false; key = $(this).find("label").html(); - if (typeof (sp) !== "undefined") { + if (sp !== "") { sp = sp + "\n" + key + "=" + chk; } else { sp = key + "=" + chk; @@ -151,7 +154,8 @@ function saveProps() { key = $(this).find("span").html(); sp = sp + "\n" + key + "=" + value; }); - $.get("/server/saveServerPropertiesFile?doc=" + sp + "&server=" + window.localStorage.selectedServer); + sp = sp.trim(); + $.get("/server/saveServerPropertiesFile?doc=" + encodeURIComponent(sp) + "&server=" + window.localStorage.selectedServer); Toastify({ text: "{{settings-saved}}", duration: 3000,