Backport 1.20 changes and improvements
This commit is contained in:
parent
e4b59167f6
commit
15bca9670b
87 changed files with 10114 additions and 587 deletions
|
@ -0,0 +1,39 @@
|
|||
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);
|
||||
}
|
||||
}
|
Reference in a new issue