From 172f89940a304e146472c305f3c26070e3b7a129 Mon Sep 17 00:00:00 2001 From: Myles Date: Tue, 3 May 2016 21:09:48 +0100 Subject: [PATCH] Implement passthroughAll to make it easier for adding things to the end of a packet. --- .../us/myles/ViaVersion/api/PacketWrapper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java b/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java index 7f8b4f643..5a605d7d6 100644 --- a/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java +++ b/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java @@ -163,6 +163,21 @@ public class PacketWrapper { return value; } + /** + * Take all the inputs and write them to the output. + * + * @throws Exception If it failed to read or write + */ + public void passthroughAll() throws Exception { + // Copy previous objects + packetValues.addAll(readableObjects); + readableObjects.clear(); + // If the buffer has readable bytes, copy them. + if(inputBuffer.readableBytes() > 0){ + read(Type.REMAINING_BYTES); + } + } + /** * Write the current output to a buffer. *