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 d1deada338..9f1b0a990a 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 @@ -471,7 +471,7 @@ private static class ProtocolData private final int protocolVersion; private final TObjectIntMap> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID ); @SuppressWarnings("unchecked") - private final Supplier[] packetConstructors = new Supplier[ MAX_PACKET_ID ]; + private final TIntObjectMap> packetConstructors = new TIntObjectHashMap<>( MAX_PACKET_ID ); } @Data @@ -530,7 +530,7 @@ public final DefinedPacket createPacket(int id, int version) throw new BadPacketException( "Packet with id " + id + " outside of range" ); } - Supplier constructor = protocolData.packetConstructors[id]; + Supplier constructor = protocolData.packetConstructors.get( id ); return ( constructor == null ) ? null : constructor.get(); } @@ -561,7 +561,7 @@ private void registerPacket(Class packetClass, Supplier ProtocolData data = protocols.get( protocol ); data.packetMap.put( packetClass, mapping.packetID ); - data.packetConstructors[mapping.packetID] = constructor; + data.packetConstructors.put( mapping.packetID, constructor ); } }