blob: 2f051f05c2cf5dbe793269888fb3bcae22a104be (
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
|
package shcm.shsupercm.fabric.citresewn.config;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import org.apache.commons.io.IOUtils;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import java.io.*;
public class CITResewnConfig {
public boolean enabled = true;
public boolean mute_errors = false;
public boolean mute_warns = false;
public int cache_ms = 50;
public boolean broken_paths = false;
private static final File FILE = new File("config/citresewn.json");
public static final CITResewnConfig INSTANCE = read();
public static CITResewnConfig read() {
if (!FILE.exists())
return new CITResewnConfig().write();
Reader reader = null;
try {
return new Gson().fromJson(reader = new FileReader(FILE), CITResewnConfig.class);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(reader);
}
}
public CITResewnConfig write() {
Gson gson = new Gson();
JsonWriter writer = null;
try {
writer = gson.newJsonWriter(new FileWriter(FILE));
writer.setIndent(" ");
gson.toJson(gson.toJsonTree(this, CITResewnConfig.class), writer);
} catch (Exception e) {
CITResewn.LOG.error("Couldn't save config");
e.printStackTrace();
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(writer);
}
return this;
}
}
|