Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -10,34 +10,32 @@ import ru.betterend.BetterEnd;
|
|||
public class WorldDataUtil {
|
||||
private static CompoundTag root;
|
||||
private static File saveFile;
|
||||
|
||||
|
||||
public static void load(File file) {
|
||||
saveFile = file;
|
||||
if (file.exists()) {
|
||||
try {
|
||||
root = NbtIo.readCompressed(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
BetterEnd.LOGGER.error("World data loading failed", e);
|
||||
} catch (IOException e) {
|
||||
BetterEnd.LOGGER.error("Level data loading failed", e);
|
||||
root = new CompoundTag();
|
||||
}
|
||||
return;
|
||||
}
|
||||
root = new CompoundTag();
|
||||
}
|
||||
|
||||
|
||||
public static CompoundTag getRootTag() {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
public static CompoundTag getCompoundTag(String path) {
|
||||
String[] parts = path.split("\\.");
|
||||
CompoundTag tag = root;
|
||||
for (String part: parts) {
|
||||
for (String part : parts) {
|
||||
if (tag.contains(part)) {
|
||||
tag = tag.getCompound(part);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
CompoundTag t = new CompoundTag();
|
||||
tag.put(part, t);
|
||||
tag = t;
|
||||
|
@ -45,13 +43,12 @@ public class WorldDataUtil {
|
|||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
public static void saveFile() {
|
||||
try {
|
||||
NbtIo.writeCompressed(root, saveFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
BetterEnd.LOGGER.error("World data saving failed", e);
|
||||
} catch (IOException e) {
|
||||
BetterEnd.LOGGER.error("Level data saving failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue