forked from Sol-Client/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
44 lines (35 loc) · 884 Bytes
/
config.js
File metadata and controls
44 lines (35 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const fs = require("fs");
const Utils = require("./utils");
class Config {
static data = {
maxMemory: 2048,
optifine: Utils.getOsName() != "osx",
minecraftFolder: "<use default>",
autoUpdate: true
};
static file;
static init(base) {
Config.file = base + "/config.json";
}
static load() {
if(fs.existsSync(Config.file)) {
Config.data = JSON.parse(fs.readFileSync(Config.file, "UTF-8"));
if(!Config.data.minecraftFolder) {
Config.data.minecraftFolder = "<use default>";
}
if(Config.data.autoUpdate == undefined) {
Config.data.autoUpdate = true;
}
}
}
static save() {
fs.writeFileSync(Config.file, JSON.stringify(Config.data));
}
static getGameDirectory(defaultDirectory) {
if(Config.data.minecraftFolder != "<use default>") {
return Config.data.minecraftFolder;
}
return defaultDirectory;
}
}
module.exports = Config;