From 72a30fe6066c7ec79604c553a791946361189165 Mon Sep 17 00:00:00 2001 From: Obique PSWG Date: Sun, 4 Oct 2015 10:34:23 -0500 Subject: [PATCH] Created getIntArray method in Packet --- src/network/packets/Packet.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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