diff --git a/lib/nbt/Tag.dart b/lib/nbt/Tag.dart index 26fd57c..d0b3748 100644 --- a/lib/nbt/Tag.dart +++ b/lib/nbt/Tag.dart @@ -227,7 +227,7 @@ abstract class Tag { if (getKey() == "") { return false; } else { - String letters = "abcdefghijklmnopqrstuvwxyz"; + String letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (int i = 0; i < getKey().length; i++) { String digit = getKey().substring(i, i + 1); if (letters.indexOf(digit) == -1) { @@ -238,6 +238,21 @@ abstract class Tag { } } + bool shouldQuote(String value) { + if (value == "") { + return false; + } else { + String letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + for (int i = 0; i < value.length; i++) { + String digit = value.substring(i, i + 1); + if (letters.indexOf(digit) == -1) { + return true; + } + } + return false; + } + } + void writeStringifiedValue(StringBuilder builder, int indent, bool isList); void readStringifiedValue(StringReader reader); diff --git a/lib/nbt/impl/StringTag.dart b/lib/nbt/impl/StringTag.dart index 2978e2c..6876fe7 100644 --- a/lib/nbt/impl/StringTag.dart +++ b/lib/nbt/impl/StringTag.dart @@ -36,7 +36,10 @@ class StringTag extends Tag { @override void writeStringifiedValue(StringBuilder builder, int indent, bool isList) { - builder.append("${isList ? "".padLeft(indent, '\t') : ""}\"${value}\""); + if (shouldQuote(value)) + builder.append("${isList ? "".padLeft(indent, '\t') : ""}\"${value}\""); + else + builder.append("${isList ? "".padLeft(indent, '\t') : ""}${value}"); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 7488d5f..8339ee0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libac_dart description: "Aria's Creations code library" -version: 1.0.35 +version: 1.0.36 homepage: "https://zontreck.com"