use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.
the class DisconnectPacket method decode.
@Override
public void decode() {
try {
PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
//PID
reader.readByte();
this.message = reader.readString();
this.setLength(reader.totallyRead());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.
the class DropItemPacket method decode.
@Override
public void decode() {
try {
setChannel(NetworkChannel.CHANNEL_ENTITY_SPAWNING);
PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
//PID
reader.readByte();
this.type = reader.readByte();
this.slot = PEInventorySlot.readSlot(reader);
this.setLength(reader.totallyRead());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.
the class LoginPacket method decode.
@Override
public void decode() {
try {
PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
//PID
reader.readByte();
this.username = reader.readString();
this.protocol1 = reader.readInt();
this.protocol2 = reader.readInt();
this.clientID = reader.readLong();
this.clientUuid = reader.readUUID();
this.serverAddress = reader.readString();
this.clientSecret = reader.readString();
this.slim = (reader.readByte() & 0xF) > 0;
this.skinTransparent = (reader.readByte() & 0xF) > 0;
int len = reader.readShort();
this.skin = reader.read(len);
this.setLength(reader.totallyRead());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.
the class BatchPacket method decode.
@Override
public void decode() {
try {
packets = new ArrayList<>();
PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
//PID
reader.readByte();
int size = reader.readInt();
byte[] payload = reader.read(size);
Inflater inf = new Inflater();
inf.setInput(payload);
byte[] decompressedPayload = new byte[1024 * 1024 * 64];
int decompressedSize = 0;
try {
decompressedSize = inf.inflate(decompressedPayload);
} catch (DataFormatException ex) {
this.setLength(reader.totallyRead());
return;
}
inf.end();
PEBinaryReader dataReader = new PEBinaryReader(new ByteArrayInputStream(decompressedPayload));
int offset = 0;
while (offset < decompressedSize) {
int pkLen = dataReader.readInt();
offset += 4;
byte[] pkData = dataReader.read(pkLen);
offset += pkLen;
PEPacket pk = Protocol.decode(pkData);
if (pk == null || pk.getLength() == 0) {
packets.clear();
return;
}
packets.add(pk);
}
this.setLength(reader.totallyRead());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.
the class ChatPacket method decode.
@Override
public void decode() {
try {
PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
//PID
reader.readByte();
this.type = TextType.fromNum(reader.readByte());
switch(this.type) {
case POPUP:
case CHAT:
this.source = reader.readString();
case RAW:
case TIP:
case SYSTEM:
this.message = reader.readString();
break;
case TRANSLATION:
this.message = reader.readString();
int cnt = reader.readByte();
this.params = new String[cnt];
for (int i = 0; i < cnt; i++) {
this.params[i] = reader.readString();
}
break;
}
this.setLength(reader.totallyRead());
} catch (IOException e) {
}
}
Aggregations