mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-08 11:50:36 +01:00
Add readByteArray
shortcut
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
502db8ec5c
commit
de71900cb9
@ -28,7 +28,7 @@ public record EncryptionResponsePacket(byte[] sharedSecret, byte[] verifyToken)
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
public EncryptionResponsePacket(BinaryReader reader) {
|
||||
this(reader.readBytes(reader.readVarInt()), reader.readBytes(reader.readVarInt()));
|
||||
this(reader.readByteArray(), reader.readByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,8 +11,8 @@ public record EncryptionRequestPacket(@NotNull String serverId,
|
||||
byte @NotNull [] verifyToken) implements ServerPacket {
|
||||
public EncryptionRequestPacket(BinaryReader reader) {
|
||||
this(reader.readSizedString(),
|
||||
reader.readBytes(reader.readVarInt()),
|
||||
reader.readBytes(reader.readVarInt()));
|
||||
reader.readByteArray(),
|
||||
reader.readByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public record MapDataPacket(int mapId, byte scale, boolean locked,
|
||||
byte rows = reader.readByte();
|
||||
byte x = reader.readByte();
|
||||
byte z = reader.readByte();
|
||||
byte[] data = reader.readBytes(reader.readVarInt());
|
||||
byte[] data = reader.readByteArray();
|
||||
return new MapDataPacket(mapId, scale, locked,
|
||||
trackingPosition, icons, new ColorContent(columns, rows, x, z,
|
||||
data));
|
||||
@ -86,7 +86,7 @@ public record MapDataPacket(int mapId, byte scale, boolean locked,
|
||||
byte @NotNull [] data) implements Writeable {
|
||||
public ColorContent(BinaryReader reader) {
|
||||
this(reader.readByte(), reader.readByte(), reader.readByte(), reader.readByte(),
|
||||
reader.readBytes(reader.readVarInt()));
|
||||
reader.readByteArray());
|
||||
}
|
||||
|
||||
public void write(BinaryWriter writer) {
|
||||
|
@ -24,8 +24,7 @@ public record ChunkData(@NotNull NBTCompound heightmaps, byte @NotNull [] data,
|
||||
}
|
||||
|
||||
public ChunkData(BinaryReader reader) {
|
||||
this((NBTCompound) reader.readTag(),
|
||||
reader.readBytes(reader.readVarInt()),
|
||||
this((NBTCompound) reader.readTag(), reader.readByteArray(),
|
||||
readBlockEntities(reader));
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,10 @@ public class BinaryReader extends InputStream {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public byte[] readByteArray() {
|
||||
return readBytes(readVarInt());
|
||||
}
|
||||
|
||||
public String[] readSizedStringArray(int maxLength) {
|
||||
final int size = readVarInt();
|
||||
String[] strings = new String[size];
|
||||
|
Loading…
Reference in New Issue
Block a user