From caeabb5b62694ef761d5a0524b80cef2fa1d7abd Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 Mar 2019 09:08:27 +1100 Subject: [PATCH] #2610: Fix out of date message for unsupported versions --- .../java/net/md_5/bungee/protocol/Protocol.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index 56d8a0de3..98be98e83 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -1,6 +1,7 @@ package net.md_5.bungee.protocol; import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TIntObjectHashMap; @@ -359,9 +360,19 @@ public enum Protocol } } + private ProtocolData getProtocolData(int version) + { + ProtocolData protocol = protocols.get( version ); + if ( protocol == null && ( protocolPhase != Protocol.GAME ) ) + { + protocol = Iterables.getFirst( protocols.valueCollection(), null ); + } + return protocol; + } + public final DefinedPacket createPacket(int id, int version) { - ProtocolData protocolData = protocols.get( version ); + ProtocolData protocolData = getProtocolData( version ); if ( protocolData == null ) { throw new BadPacketException( "Unsupported protocol version " + version ); @@ -423,7 +434,7 @@ public enum Protocol final int getId(Class packet, int version) { - ProtocolData protocolData = protocols.get( version ); + ProtocolData protocolData = getProtocolData( version ); if ( protocolData == null ) { throw new BadPacketException( "Unsupported protocol version" );