From d5b3508c7c26667236bde5fcccce4007125efbdf Mon Sep 17 00:00:00 2001 From: Dogboy21 Date: Wed, 15 Sep 2021 20:20:02 +0200 Subject: [PATCH 1/2] Fixed connection to 1.7 Thermos servers Readd changes from #157 and #261 Changed packet constructors type from Array to Map to allow negative packet ids (can occur in CoFH mods for example) --- .../src/main/java/net/md_5/bungee/protocol/Protocol.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 d1deada338..07dcfebd98 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); } } From b0dcde449ca59535c341b3c93b6ec3f5e39606c0 Mon Sep 17 00:00:00 2001 From: Dogboy21 Date: Wed, 15 Sep 2021 20:25:39 +0200 Subject: [PATCH 2/2] Fixed checkstyle error in CI build --- protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java | 4 ++-- 1 file changed, 2 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 07dcfebd98..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 @@ -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.get(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.put(mapping.packetID, constructor); + data.packetConstructors.put( mapping.packetID, constructor ); } }