Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #261 from dogboy21/patch-2
Browse files Browse the repository at this point in the history
Readd changes from #157 (Fixing ArrayIndexOutOfBoundsException with Thermos)
  • Loading branch information
John authored Jul 4, 2019
2 parents 6824464 + 30adece commit 368028c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private static class ProtocolData

private final int protocolVersion;
private final TObjectIntMap<Class<? extends DefinedPacket>> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID );
private final Constructor<? extends DefinedPacket>[] packetConstructors = new Constructor[ MAX_PACKET_ID ];
private final TIntObjectMap<Constructor<? extends DefinedPacket>> packetConstructors = new TIntObjectHashMap<>( MAX_PACKET_ID );
}

@Data
Expand Down Expand Up @@ -404,7 +404,7 @@ public final DefinedPacket createPacket(int id, int version)
throw new BadPacketException( "Packet with id " + id + " outside of range " );
}

Constructor<? extends DefinedPacket> constructor = protocolData.packetConstructors[id];
Constructor<? extends DefinedPacket> constructor = protocolData.packetConstructors.get( id );
try
{
return ( constructor == null ) ? null : constructor.newInstance();
Expand Down Expand Up @@ -445,7 +445,7 @@ private void registerPacket(Class<? extends DefinedPacket> packetClass, Protocol

ProtocolData data = protocols.get( protocol );
data.packetMap.put( packetClass, mapping.packetID );
data.packetConstructors[mapping.packetID] = constructor;
data.packetConstructors.put( mapping.packetID, constructor );
}
} catch ( NoSuchMethodException ex )
{
Expand Down

0 comments on commit 368028c

Please sign in to comment.