diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java index c389d61d4..1ec75ba67 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java @@ -54,9 +54,15 @@ public class ProtocolPipeline extends Protocol { */ public void add(Protocol protocol) { if (protocolList != null) { - // Make BaseProtocol be in the last position, so the login packets can be modified by other protocols - protocolList.add(protocolList.size() - 1, protocol); + protocolList.add(protocol); protocol.init(userConnection); + // Move base Protocols to the end, so the login packets can be modified by other protocols + List toMove = new ArrayList<>(); + for (Protocol p : protocolList) + if (ProtocolRegistry.isBaseProtocol(p)) + toMove.add(p); + protocolList.removeAll(toMove); + protocolList.addAll(toMove); } else { throw new NullPointerException("Tried to add protocol to early"); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index 5a00d36d0..3ba69210a 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -230,4 +230,12 @@ public class ProtocolRegistry { return rangeProtocol.getValue(); throw new IllegalStateException("No Base Protocol for " + serverVersion); } + + public static boolean isBaseProtocol(Protocol protocol) { + for (Pair, Protocol> p : baseProtocols) + if (p.getValue() == protocol) + return true; + return false; + } + } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_13.java index c286d724d..68acc9750 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_13.java @@ -131,8 +131,8 @@ public class BaseProtocol1_13 extends Protocol { Via.getManager().addPortedClient(wrapper.user()); if (info.getPipeline().pipes().size() == 2 - && info.getPipeline().pipes().get(0).getClass() == BaseProtocol1_13.class - && info.getPipeline().pipes().get(1).getClass() == BaseProtocol.class) // Only base protocol + && info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_13.class + && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol wrapper.user().setActive(false); if (Via.getManager().isDebug()) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_7.java b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_7.java index 647e006bf..468972d5c 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_7.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol1_7.java @@ -131,8 +131,8 @@ public class BaseProtocol1_7 extends Protocol { Via.getManager().addPortedClient(wrapper.user()); if (info.getPipeline().pipes().size() == 2 - && info.getPipeline().pipes().get(0).getClass() == BaseProtocol1_7.class - && info.getPipeline().pipes().get(1).getClass() == BaseProtocol.class) // Only base protocol + && info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_7.class + && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol wrapper.user().setActive(false); if (Via.getManager().isDebug()) {