aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/torui/coflsky/configuration/LocalConfig.java
blob: 749d0bc8fe5ab80d051638acbda4cb206c008ec9 (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
package de.torui.coflsky.configuration;

import com.google.gson.Gson;
import com.google.gson.JsonObject;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

public class LocalConfig {
    public boolean autoStart;
    public boolean extendedtooltips;
    public LocalConfig(boolean autoStart,boolean extendedtooltips) {
        this.autoStart = autoStart;
        this.extendedtooltips = extendedtooltips;
    }
    public static void saveConfig(File file, LocalConfig Config) {
        Gson gson = new Gson();
        try {
            if (!file.isFile()) {
                file.createNewFile();
            }
            Files.write(Paths.get(file.getAbsolutePath()),
                    gson.toJson(Config).getBytes(StandardCharsets.UTF_8));
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static LocalConfig createDefaultConfig() {
        return new LocalConfig(true,true);
    }
}