aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java/moe/ymc/acron/Acron.java
blob: d6f6214f89fe844e0654135873aa1f6e3a733092 (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
package moe.ymc.acron;

import moe.ymc.acron.config.Config;
import moe.ymc.acron.config.json.ConfigDeserializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.nio.file.Path;

public class Acron implements ModInitializer {
    private static final Logger LOGGER = LogManager.getLogger();

    @Override
    public void onInitialize() {
        LOGGER.debug("onInitialize");
        try {
            final Path config = FabricLoader
                    .getInstance().getConfigDir()
                    .resolve("acron.json");
            if (!config.toFile().exists()) {
                throw new IllegalStateException("Cannot find config/acron.json.");
            }
            final Config cfg = ConfigDeserializer.deserialize(config.toFile(), true);
            Config.setGlobalConfig(cfg);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}