Implement StringTag, run autofix

This commit is contained in:
zontreck 2024-05-04 23:02:03 -07:00
parent 3956dc0ea9
commit 6c83fbc371
6 changed files with 50 additions and 32 deletions

View file

@ -12,6 +12,7 @@ import 'Stream.dart';
import 'impl/ByteTag.dart';
import 'impl/ListTag.dart';
import 'impl/LongArrayTag.dart';
import 'impl/StringTag.dart';
enum TagType {
End(0),
@ -59,7 +60,7 @@ abstract class Tag {
static Tag readNamedTag(ByteLayer data) {
var type = data.readByte();
if (type == 0) {
return new EndTag();
return EndTag();
} else {
Tag tag = makeTagOfType(TagType.get(type));
tag._key = data.readString();
@ -78,63 +79,72 @@ abstract class Tag {
}
bool equals(dynamic object) {
if (object == null || !(object is Tag)) return false;
if (object == null || object is! Tag) return false;
Tag tag = object;
if (tag.getType() != getType()) return false;
if (getKey() == null && tag.getKey() != null ||
tag.getKey() == null && getKey() != null) return false;
if (getKey() != null && !(getKey() == tag.getKey())) return false;
if (!(getKey() == tag.getKey())) return false;
return true;
}
static Tag makeTagOfType(TagType type) {
switch (type) {
case TagType.Byte:
{
return new ByteTag();
return ByteTag();
}
case TagType.ByteArray:
{
return new ByteArrayTag();
return ByteArrayTag();
}
case TagType.Compound:
{
return new CompoundTag();
return CompoundTag();
}
case TagType.Double:
{
return new DoubleTag();
return DoubleTag();
}
case TagType.End:
return new EndTag();
{
return EndTag();
}
case TagType.Short:
return new ShortTag();
{
return ShortTag();
}
case TagType.Int:
return new IntTag();
{
return IntTag();
}
case TagType.Long:
return new LongTag();
{
return LongTag();
}
case TagType.Float:
return new FloatTag();
{
return FloatTag();
}
case TagType.IntArray:
{
return new IntArrayTag();
return IntArrayTag();
}
case TagType.LongArray:
{
return new LongArrayTag();
return LongArrayTag();
}
case TagType.List:
{
return new ListTag();
return ListTag();
}
case TagType.String:
{
return StringTag();
}
}
}
}
}