Completely rework SNBT Parser
(NOTE: ChatGPT Was used for regex only)
This commit is contained in:
parent
7c87ef444f
commit
84192c69db
11 changed files with 150 additions and 107 deletions
|
@ -5,7 +5,7 @@ import 'Tag.dart';
|
|||
import 'impl/CompoundTag.dart';
|
||||
|
||||
class SnbtIo {
|
||||
static void writeToFile(String file, CompoundTag tag) {
|
||||
static Future<void> writeToFile(String file, CompoundTag tag) async {
|
||||
File handle = File(file);
|
||||
|
||||
if (handle.existsSync())
|
||||
|
@ -13,7 +13,7 @@ class SnbtIo {
|
|||
|
||||
StringBuilder builder = StringBuilder();
|
||||
Tag.writeStringifiedNamedTag(tag, builder, 0);
|
||||
handle.writeAsString(builder.toString());
|
||||
await handle.writeAsString(builder.toString());
|
||||
}
|
||||
|
||||
static Future<Tag> readFromFile(String file) async {
|
||||
|
@ -21,7 +21,15 @@ class SnbtIo {
|
|||
String data = await fi.readAsString();
|
||||
StringReader reader = StringReader(data);
|
||||
|
||||
return Tag.readStringifiedNamedTag(reader);
|
||||
Tag tag = CompoundTag();
|
||||
try {
|
||||
tag = Tag.readStringifiedNamedTag(reader);
|
||||
} catch (E, stack) {
|
||||
print("FATAL ERROR OCCURED AT LOCATION:\n${reader.getSnapshot()}");
|
||||
print(E);
|
||||
print(stack);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
static String writeToString(CompoundTag tag) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue