Apply dart autofixes

This commit is contained in:
zontreck 2024-05-08 14:44:37 -07:00
parent 2f3991b97c
commit c10ffc58b8
5 changed files with 22 additions and 14 deletions

View file

@ -111,9 +111,10 @@ class NbtUtils {
} }
static UUID readUUID(CompoundTag tag, String name) { static UUID readUUID(CompoundTag tag, String name) {
if (!tag.contains(name)) if (!tag.contains(name)) {
return UUID.ZERO; return UUID.ZERO;
else } else {
return _uuidFromIntArray(tag.get(name)!.asIntArray()); return _uuidFromIntArray(tag.get(name)!.asIntArray());
}
} }
} }

1
lib/nbt/SnbtIo.dart Normal file
View file

@ -0,0 +1 @@
class SnbtIo {}

View file

@ -351,8 +351,9 @@ class ByteLayer {
seek(position); seek(position);
int current = readUnsignedByte(); int current = readUnsignedByte();
return (current & mask) == mask; return (current & mask) == mask;
} else } else {
return false; return false;
}
} }
int getBit(int position) { int getBit(int position) {

View file

@ -27,8 +27,9 @@ class UUID {
static bool validate(String uuid) { static bool validate(String uuid) {
if (uuid.length == ((16 * 2) + 4)) { if (uuid.length == ((16 * 2) + 4)) {
return true; // Likely is true. This is just a surface level check return true; // Likely is true. This is just a surface level check
} else } else {
return false; return false;
}
} }
/// Parses the given [uuid] string and returns a UUID object. /// Parses the given [uuid] string and returns a UUID object.
@ -48,13 +49,13 @@ class UUID {
int i = 0; int i = 0;
ByteLayer layer = ByteLayer(); ByteLayer layer = ByteLayer();
for (i = 0; i < msbString.length; i += 2) { for (i = 0; i < msbString.length; i += 2) {
String hex = "${msbString.substring(i, i + 2)}"; String hex = msbString.substring(i, i + 2);
int byte = int.parse(hex, radix: 16); int byte = int.parse(hex, radix: 16);
layer.writeByte(byte); layer.writeByte(byte);
} }
for (i = 0; i < lsbString.length; i += 2) { for (i = 0; i < lsbString.length; i += 2) {
String hex = "${lsbString.substring(i, i + 2)}"; String hex = lsbString.substring(i, i + 2);
int byte = int.parse(hex, radix: 16); int byte = int.parse(hex, radix: 16);
layer.writeByte(byte); layer.writeByte(byte);
} }
@ -64,8 +65,9 @@ class UUID {
lsb = layer.readLong(); lsb = layer.readLong();
return UUID(msb, lsb); return UUID(msb, lsb);
} else } else {
return UUID.ZERO; return UUID.ZERO;
}
} }
@override @override
@ -90,16 +92,18 @@ class UUID {
if (version != 4) { if (version != 4) {
return UUID.generate(4); return UUID.generate(4);
} }
} else } else {
params = parameters!; params = parameters;
}
switch (version) { switch (version) {
case 0: case 0:
return UUID(0, 0); return UUID(0, 0);
case 3: case 3:
{ {
if (params.length != 2) if (params.length != 2) {
throw Exception( throw Exception(
"UUID v3 requires two parameters, [namespace,name]"); "UUID v3 requires two parameters, [namespace,name]");
}
String namespace = params[0] as String; String namespace = params[0] as String;
String name = params[1] as String; String name = params[1] as String;
@ -145,18 +149,19 @@ class UUID {
case 5: case 5:
{ {
ByteLayer layer = ByteLayer(); ByteLayer layer = ByteLayer();
if (params.length != 2) if (params.length != 2) {
throw Exception( throw Exception(
"UUID v5 requires two parameters, [namespace,name]"); "UUID v5 requires two parameters, [namespace,name]");
}
String namespace = params[0] as String; String namespace = params[0] as String;
String name = params[1] as String; String name = params[1] as String;
if (!namespace.isEmpty) { if (namespace.isNotEmpty) {
final namespaceBytes = utf8.encode(namespace); final namespaceBytes = utf8.encode(namespace);
layer.writeBytes(namespaceBytes); layer.writeBytes(namespaceBytes);
} }
if (!name.isEmpty) { if (name.isNotEmpty) {
final nameBytes = utf8.encode(name); final nameBytes = utf8.encode(name);
layer.writeBytes(nameBytes); layer.writeBytes(nameBytes);
} }

View file

@ -20,7 +20,7 @@ void main() {
} }
for (UUID sID in ID) { for (UUID sID in ID) {
print("ID : ${sID}}"); print("ID : $sID}");
} }
}); });