2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei.config;
|
|
|
|
|
|
2023-09-25 00:35:24 +02:00
|
|
|
import java.io.File;
|
|
|
|
|
|
2023-09-25 00:34:42 +02:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
|
2023-09-25 00:35:24 +02:00
|
|
|
import codechicken.lib.config.ConfigTagParent;
|
|
|
|
|
import codechicken.nei.NEIServerUtils;
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public class ConfigSet {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
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 {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!nbtFile.getParentFile().exists()) nbtFile.getParentFile().mkdirs();
|
|
|
|
|
if (!nbtFile.exists()) nbtFile.createNewFile();
|
|
|
|
|
if (nbtFile.length() > 0) 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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|