Fix some inconsistencies
This commit is contained in:
parent
cfd97a687c
commit
4957fe633e
4 changed files with 25 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
class Constants {
|
class Constants {
|
||||||
static const VERSION = "1.4.012225+0413";
|
static const VERSION = "1.4.020325+1215";
|
||||||
static const NBT_REVISION = "1.3.012225+0304";
|
static const NBT_REVISION = "1.4.020325+1215";
|
||||||
static const ARGS_REVISION = "1.4.012225+0413";
|
static const ARGS_REVISION = "1.4.012225+0413";
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,23 +17,23 @@ class NbtIo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function will read the file and check if it is infact gzipped
|
// This function will read the file and check if it is infact gzipped
|
||||||
static Future<CompoundTag> read(String file) async {
|
static Future<Tag> read(String file) async {
|
||||||
await _read(file);
|
await _read(file);
|
||||||
if (_io.readByte() == TagType.Compound.byte) {
|
if (_io.readByte() == TagType.Compound.byte) {
|
||||||
_io.resetPosition();
|
_io.resetPosition();
|
||||||
return Tag.readNamedTag(_io) as CompoundTag;
|
return Tag.readNamedTag(_io);
|
||||||
} else {
|
} else {
|
||||||
// Is likely gzip compressed
|
// Is likely gzip compressed
|
||||||
return readCompressed(file);
|
return readCompressed(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<CompoundTag> readCompressed(String file) async {
|
static Future<Tag> readCompressed(String file) async {
|
||||||
_io = ByteLayer();
|
_io = ByteLayer();
|
||||||
await _io.readFromFile(file);
|
await _io.readFromFile(file);
|
||||||
await _io.decompress();
|
await _io.decompress();
|
||||||
_io.resetPosition();
|
_io.resetPosition();
|
||||||
return Tag.readNamedTag(_io) as CompoundTag;
|
return Tag.readNamedTag(_io);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> write(String file, CompoundTag tag) async {
|
static Future<void> write(String file, CompoundTag tag) async {
|
||||||
|
@ -60,7 +60,7 @@ class NbtIo {
|
||||||
return base64Encoder.encode(_io.bytes);
|
return base64Encoder.encode(_io.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<CompoundTag> readBase64String(String encoded) async {
|
static Future<Tag> readBase64String(String encoded) async {
|
||||||
_io = ByteLayer();
|
_io = ByteLayer();
|
||||||
List<int> bytes = base64Encoder.decode(encoded);
|
List<int> bytes = base64Encoder.decode(encoded);
|
||||||
for (int byte in bytes) {
|
for (int byte in bytes) {
|
||||||
|
@ -68,7 +68,7 @@ class NbtIo {
|
||||||
}
|
}
|
||||||
_io.decompress();
|
_io.decompress();
|
||||||
_io.resetPosition();
|
_io.resetPosition();
|
||||||
return Tag.readNamedTag(_io) as CompoundTag;
|
return Tag.readNamedTag(_io);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes the NBT Data to stream in compressed mode
|
/// Writes the NBT Data to stream in compressed mode
|
||||||
|
@ -80,7 +80,7 @@ class NbtIo {
|
||||||
return _io.bytes;
|
return _io.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<CompoundTag> readFromStreamCompressed(Uint8List list) async {
|
static Future<Tag> readFromStreamCompressed(Uint8List list) async {
|
||||||
_io = ByteLayer();
|
_io = ByteLayer();
|
||||||
try {
|
try {
|
||||||
_io.writeBytes(list);
|
_io.writeBytes(list);
|
||||||
|
@ -90,7 +90,7 @@ class NbtIo {
|
||||||
} catch (E) {
|
} catch (E) {
|
||||||
print(E);
|
print(E);
|
||||||
} finally {
|
} finally {
|
||||||
return Tag.readNamedTag(_io) as CompoundTag;
|
return Tag.readNamedTag(_io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class NbtIo {
|
||||||
return _io.bytes;
|
return _io.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<CompoundTag> readFromStream(Uint8List list) async {
|
static Future<Tag> readFromStream(Uint8List list) async {
|
||||||
_io = ByteLayer();
|
_io = ByteLayer();
|
||||||
try {
|
try {
|
||||||
_io.writeBytes(list);
|
_io.writeBytes(list);
|
||||||
|
@ -109,7 +109,15 @@ class NbtIo {
|
||||||
} catch (E) {
|
} catch (E) {
|
||||||
print(E);
|
print(E);
|
||||||
} finally {
|
} finally {
|
||||||
return Tag.readNamedTag(_io) as CompoundTag;
|
if (_io.readByte() == TagType.Compound.byte) {
|
||||||
|
_io.resetPosition();
|
||||||
|
return Tag.readNamedTag(_io);
|
||||||
|
} else {
|
||||||
|
_io.resetPosition();
|
||||||
|
_io.decompress();
|
||||||
|
_io.resetPosition();
|
||||||
|
return Tag.readNamedTag(_io);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,8 @@ class PacketServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag tag =
|
CompoundTag tag =
|
||||||
await NbtIo.readFromStream(Uint8List.fromList(remainingBytes));
|
await NbtIo.readFromStream(Uint8List.fromList(remainingBytes))
|
||||||
|
as CompoundTag;
|
||||||
StringBuilder builder = StringBuilder();
|
StringBuilder builder = StringBuilder();
|
||||||
Tag.writeStringifiedNamedTag(tag, builder, 0);
|
Tag.writeStringifiedNamedTag(tag, builder, 0);
|
||||||
|
|
||||||
|
@ -327,7 +328,8 @@ class PacketClient {
|
||||||
pktBytes = await xtea.decipher(pktBytes);
|
pktBytes = await xtea.decipher(pktBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTag = await NbtIo.readFromStream(Uint8List.fromList(pktBytes));
|
NBTTag = await NbtIo.readFromStream(Uint8List.fromList(pktBytes))
|
||||||
|
as CompoundTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseWait.complete();
|
responseWait.complete();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: libac_dart
|
name: libac_dart
|
||||||
description: "Aria's Creations code library"
|
description: "Aria's Creations code library"
|
||||||
version: 1.4.012225+0413
|
version: 1.4.020325+1215
|
||||||
homepage: "https://zontreck.com"
|
homepage: "https://zontreck.com"
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue