From 07827a2a1caaa1a86a044e3071bcec6c90be1ac0 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 12 Jun 2022 06:45:54 +0100 Subject: [PATCH] Add protocol version to packet not found message Also avoids a double get, but, this is probably trivial 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 7e0c4f7a..8bf14d56 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 @@ -2,6 +2,8 @@ package net.md_5.bungee.protocol; import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; + +import gnu.trove.impl.Constants; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TIntObjectHashMap; @@ -741,9 +743,12 @@ public enum Protocol { throw new BadPacketException( "Unsupported protocol version" ); } - Preconditions.checkArgument( protocolData.packetMap.containsKey( packet ), "Cannot get ID for packet %s in phase %s with direction %s", packet, protocolPhase, direction ); + // Waterfall start + final int packetId = protocolData.packetMap.get(packet); + Preconditions.checkArgument( packetId >= 0, "Cannot get ID for packet %s in phase %s with direction %s for protocol version %s", packet, protocolPhase, direction, version ); // Waterfall - add version - return protocolData.packetMap.get( packet ); + return packetId; + // Waterfall end } } } -- 2.37.3.windows.1