Add some helper functions, adjust visibility on variables

This commit is contained in:
zontreck 2024-05-04 23:21:40 -07:00
parent 6c83fbc371
commit 43aa3bc6d0
13 changed files with 141 additions and 65 deletions

View file

@ -147,4 +147,84 @@ abstract class Tag {
}
}
}
int asByte() {
if (this is ByteTag) {
return (this as ByteTag).value;
} else {
return 0;
}
}
List<int> asByteArray() {
if (this is ByteArrayTag) {
return (this as ByteArrayTag).value;
} else {
return [];
}
}
double asDouble() {
if (this is DoubleTag) {
return (this as DoubleTag).value;
} else {
return 0.0;
}
}
double asFloat() {
if (this is FloatTag) {
return (this as FloatTag).value;
} else {
return 0.0;
}
}
List<int> asIntArray() {
if (this is IntArrayTag) {
return (this as IntArrayTag).value;
} else {
return [];
}
}
int asInt() {
if (this is IntTag) {
return (this as IntTag).value;
} else {
return 0;
}
}
List<int> asLongArray() {
if (this is LongArrayTag) {
return (this as LongArrayTag).value;
} else {
return [];
}
}
int asLong() {
if (this is LongTag) {
return (this as LongTag).value;
} else {
return 0;
}
}
int asShort() {
if (this is ShortTag) {
return (this as ShortTag).value;
} else {
return 0;
}
}
String asString() {
if (this is StringTag) {
return (this as StringTag).value;
} else {
return "";
}
}
}