mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 11:15:47 +01:00
Require a buffer to be passed along.
This commit is contained in:
parent
684600a423
commit
6bb9a14cd1
@ -6,10 +6,10 @@ import java.io.IOException;
|
||||
public class BulkChunk extends Instruction {
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
short count = in.readShort();
|
||||
int size = in.readInt();
|
||||
in.readBoolean();
|
||||
skip(in, size + count * 12);
|
||||
skip(in, buffer, size + count * 12);
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ class ByteHeader extends Instruction {
|
||||
}
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
byte size = in.readByte();
|
||||
for (byte b = 0; b < size; b++) {
|
||||
child.read(in);
|
||||
child.read(in, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class DataInputPacketReader {
|
||||
}
|
||||
}
|
||||
|
||||
public static void readPacket(DataInput in) throws IOException {
|
||||
public static void readPacket(DataInput in, byte[] buffer) throws IOException {
|
||||
int packetId = in.readUnsignedByte();
|
||||
Instruction[] packetDef = instructions[packetId];
|
||||
|
||||
@ -56,7 +56,7 @@ public class DataInputPacketReader {
|
||||
}
|
||||
|
||||
for (Instruction instruction : packetDef) {
|
||||
instruction.read(in);
|
||||
instruction.read(in, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,10 @@ abstract class Instruction {
|
||||
static final Instruction USHORT_BYTE = new UnsignedShortByte();
|
||||
// Illegal forward references below this line
|
||||
static final Instruction BYTE_INT = new ByteHeader(INT);
|
||||
// Buffer used to read all skips, make sure it is sufficiently large (1mb packet at the moment)
|
||||
static final byte[] buf = new byte[1 << 20];
|
||||
|
||||
abstract void read(DataInput in) throws IOException;
|
||||
abstract void read(DataInput in, byte[] buffer) throws IOException;
|
||||
|
||||
final void skip(DataInput in, int len) throws IOException {
|
||||
in.readFully(buf, 0, len);
|
||||
final void skip(DataInput in, byte[] buffer, int len) throws IOException {
|
||||
in.readFully(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ class IntHeader extends Instruction {
|
||||
}
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
int size = in.readInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
child.read(in);
|
||||
child.read(in, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ import java.io.IOException;
|
||||
class Item extends Instruction {
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
short type = in.readShort();
|
||||
if (type >= 0) {
|
||||
skip(in, 3);
|
||||
SHORT_BYTE.read(in);
|
||||
skip(in, buffer, 3);
|
||||
SHORT_BYTE.read(in, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class Jump extends Instruction {
|
||||
}
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
skip(in, len);
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
skip(in, buffer, len);
|
||||
}
|
||||
}
|
||||
|
@ -6,31 +6,31 @@ import java.io.IOException;
|
||||
class MetaData extends Instruction {
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
int x = in.readUnsignedByte();
|
||||
while (x != 127) {
|
||||
int type = x >> 5;
|
||||
switch (type) {
|
||||
case 0:
|
||||
BYTE.read(in);
|
||||
BYTE.read(in, buffer);
|
||||
break;
|
||||
case 1:
|
||||
SHORT.read(in);
|
||||
SHORT.read(in, buffer);
|
||||
break;
|
||||
case 2:
|
||||
INT.read(in);
|
||||
INT.read(in, buffer);
|
||||
break;
|
||||
case 3:
|
||||
FLOAT.read(in);
|
||||
FLOAT.read(in, buffer);
|
||||
break;
|
||||
case 4:
|
||||
STRING.read(in);
|
||||
STRING.read(in, buffer);
|
||||
break;
|
||||
case 5:
|
||||
ITEM.read(in);
|
||||
ITEM.read(in, buffer);
|
||||
break;
|
||||
case 6:
|
||||
skip(in, 12); // int, int, int
|
||||
skip(in, buffer, 12); // int, int, int
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown metadata type " + type);
|
||||
|
@ -6,10 +6,10 @@ import java.io.IOException;
|
||||
public class OptionalMotion extends Instruction {
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
int data = in.readInt();
|
||||
if (data > 0) {
|
||||
skip(in, 6);
|
||||
skip(in, buffer, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ class ShortHeader extends Instruction {
|
||||
}
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
short size = in.readShort();
|
||||
for (short s = 0; s < size; s++) {
|
||||
child.read(in);
|
||||
child.read(in, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import java.io.IOException;
|
||||
public class UnsignedShortByte extends Instruction {
|
||||
|
||||
@Override
|
||||
void read(DataInput in) throws IOException {
|
||||
void read(DataInput in, byte[] buffer) throws IOException {
|
||||
int size = in.readUnsignedShort();
|
||||
skip(in, size);
|
||||
skip(in, buffer, size);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user