2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei.config;
|
|
|
|
|
|
|
|
|
|
import codechicken.lib.config.ConfigTagParent;
|
2014-10-01 20:01:10 +10:00
|
|
|
import codechicken.nei.NEIServerUtils;
|
2014-04-29 10:54:20 +10:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
public class ConfigSet
|
|
|
|
|
{
|
2019-12-30 20:19:16 -08:00
|
|
|
private final File nbtFile;
|
2014-04-29 10:54:20 +10:00
|
|
|
public NBTTagCompound nbt;
|
2019-12-30 20:19:16 -08:00
|
|
|
public final ConfigTagParent config;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
public ConfigSet(File nbtFile, ConfigTagParent config) {
|
|
|
|
|
this.nbtFile = nbtFile;
|
|
|
|
|
this.config = config;
|
|
|
|
|
loadNBT();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void loadNBT() {
|
|
|
|
|
nbt = new NBTTagCompound();
|
|
|
|
|
try {
|
|
|
|
|
if (!nbtFile.getParentFile().exists())
|
|
|
|
|
nbtFile.getParentFile().mkdirs();
|
|
|
|
|
if (!nbtFile.exists())
|
|
|
|
|
nbtFile.createNewFile();
|
|
|
|
|
if (nbtFile.length() > 0)
|
2014-10-01 20:01:10 +10:00
|
|
|
nbt = NEIServerUtils.readNBT(nbtFile);
|
2014-04-29 10:54:20 +10:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveNBT() {
|
|
|
|
|
try {
|
2014-10-01 20:01:10 +10:00
|
|
|
NEIServerUtils.writeNBT(nbt, nbtFile);
|
2014-04-29 10:54:20 +10:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|