package dev.zontreck.libzontreck.config; import dev.zontreck.libzontreck.LibZontreck; import dev.zontreck.libzontreck.config.sections.DatabaseSection; import dev.zontreck.libzontreck.util.SNbtIo; import net.minecraft.nbt.CompoundTag; import java.nio.file.Path; public class ServerConfig { public static final Path BASE = LibZontreck.BASE_CONFIG.resolve("server.snbt"); public static DatabaseSection database; public static void init() { if(BASE.toFile().exists()) { var config = SNbtIo.loadSnbt(BASE); database = DatabaseSection.deserialize(config.getCompound(DatabaseSection.TAG_NAME)); commit(); } else { database = new DatabaseSection(); commit(); } } public static void commit() { CompoundTag tag = new CompoundTag(); tag.put(DatabaseSection.TAG_NAME, database.serialize()); SNbtIo.writeSnbt(BASE, tag); } }