diff --git a/src/network/packets/Packet.java b/src/network/packets/Packet.java index 7ef9fac95..950df84a4 100644 --- a/src/network/packets/Packet.java +++ b/src/network/packets/Packet.java @@ -34,6 +34,7 @@ import utilities.Encoder; import java.net.InetAddress; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.IntBuffer; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; @@ -244,6 +245,21 @@ public class Packet { bb.get(data); return data; } + + public static int [] getIntArray(ByteBuffer bb) { + IntBuffer ib = bb.asIntBuffer(); + int size = ib.get(); + int [] ints = new int[size]; + ib.get(ints); + return ints; + } + + public static int [] getIntArray(ByteBuffer bb, int size) { + IntBuffer ib = bb.asIntBuffer(); + int [] ints = new int[size]; + ib.get(ints); + return ints; + } /** * Decodes the ByteBuffer stream into the passed List using the given listType instance for creating elements