blob: a0e25fc69e0d217947d3ab609e2dbb0cda312c01 (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
|
package cc.polyfrost.oneconfig.internal.config;
import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.utils.JsonUtils;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
public class OneConfigConfig extends Config {
public static String currentProfile = "Default Profile";
public static boolean autoUpdate = true;
/**
* 0 = Releases
* 1 = Pre-Releases
*/
public static int updateChannel = 0;
public static ArrayList<String> favoriteMods = new ArrayList<>();
public static ArrayList<OneColor> favoriteColors = new ArrayList<>();
public static ArrayList<OneColor> recentColors = new ArrayList<>();
public static boolean allShowShortCut = false;
public static boolean australia = false;
public OneConfigConfig() {
super(null, "OneConfig.json");
}
@Override
public void init(Mod mod) {
if (new File("OneConfig/" + configFile).exists()) load();
else save();
}
@Override
public void save() {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(Paths.get("OneConfig/" + configFile)), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(this));
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void load() {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get("OneConfig/" + configFile)), StandardCharsets.UTF_8))) {
deserializePart(JsonUtils.PARSER.parse(reader).getAsJsonObject(), this);
} catch (IOException e) {
e.printStackTrace();
}
}
}
|