From a8a33a3a2b487def4af795791f49bc16e92d6817 Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Sun, 24 Nov 2019 09:04:37 -0300 Subject: [PATCH] add exception for wrong protocol --- .../main/java/us/myles/ViaVersion/api/PacketWrapper.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java index 29f583064..950bbfac8 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java +++ b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java @@ -18,10 +18,7 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.util.PipelineUtil; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; +import java.util.*; public class PacketWrapper { public static final int PASSTHROUGH_ID = 1000; @@ -326,13 +323,14 @@ public class PacketWrapper { // Other way if outgoing Collections.reverse(protocols); } - int index = 0; + int index = -1; for (int i = 0; i < protocols.size(); i++) { if (protocols.get(i).getClass().equals(packetProtocol)) { index = skipCurrentPipeline ? (i + 1) : (i); break; } } + if (index == -1) throw new NoSuchElementException(packetProtocol.getCanonicalName()); // Reset reader before we start resetReader();