|
9 | 9 | import com.comphenix.protocol.PacketType;
|
10 | 10 | import com.comphenix.protocol.PacketType.Protocol;
|
11 | 11 | import com.comphenix.protocol.PacketType.Sender;
|
| 12 | +import com.comphenix.protocol.compat.netty.Netty; |
12 | 13 | import com.comphenix.protocol.injector.packet.MapContainer;
|
13 | 14 | import com.comphenix.protocol.reflect.StructureModifier;
|
14 | 15 | import com.comphenix.protocol.utility.MinecraftReflection;
|
15 |
| -import com.comphenix.protocol.utility.MinecraftVersion; |
16 | 16 | import com.google.common.collect.BiMap;
|
17 | 17 | import com.google.common.collect.HashBiMap;
|
18 | 18 | import com.google.common.collect.Iterables;
|
@@ -109,14 +109,13 @@ public synchronized void synchronize() {
|
109 | 109 | * Load the packet lookup tables in each protocol.
|
110 | 110 | */
|
111 | 111 | private synchronized void initialize() {
|
112 |
| - Object[] protocols = enumProtocol.getEnumConstants(); |
113 |
| - |
114 |
| - // TODO: Find a better less than 1.7 check |
115 |
| - if (MinecraftVersion.getCurrentVersion().compareTo(MinecraftVersion.BOUNTIFUL_UPDATE) < 0) { |
| 112 | + if (!Netty.isIndependent()) { // Check for 1.7 |
116 | 113 | initialize17();
|
117 | 114 | return;
|
118 | 115 | }
|
119 | 116 |
|
| 117 | + Object[] protocols = enumProtocol.getEnumConstants(); |
| 118 | + |
120 | 119 | // ID to Packet class maps
|
121 | 120 | Map<Object, Map<Integer, Class<?>>> serverMaps = Maps.newLinkedHashMap();
|
122 | 121 | Map<Object, Map<Integer, Class<?>>> clientMaps = Maps.newLinkedHashMap();
|
@@ -218,12 +217,17 @@ private synchronized void initialize17() {
|
218 | 217 | private void associatePackets(Register register, Map<Integer, Class<?>> lookup, Protocol protocol, Sender sender) {
|
219 | 218 | for (Entry<Integer, Class<?>> entry : lookup.entrySet()) {
|
220 | 219 | PacketType type = PacketType.fromCurrent(protocol, sender, entry.getKey(), PacketType.UNKNOWN_PACKET);
|
221 |
| - register.typeToClass.put(type, entry.getValue()); |
222 |
| - |
223 |
| - if (sender == Sender.SERVER) |
224 |
| - register.serverPackets.add(type); |
225 |
| - if (sender == Sender.CLIENT) |
226 |
| - register.clientPackets.add(type); |
| 220 | + |
| 221 | + try { |
| 222 | + register.typeToClass.put(type, entry.getValue()); |
| 223 | + |
| 224 | + if (sender == Sender.SERVER) |
| 225 | + register.serverPackets.add(type); |
| 226 | + if (sender == Sender.CLIENT) |
| 227 | + register.clientPackets.add(type); |
| 228 | + } catch (IllegalArgumentException ex) { |
| 229 | + // Sometimes this happens with fake packets, just ignore it |
| 230 | + } |
227 | 231 | }
|
228 | 232 | }
|
229 | 233 |
|
|
0 commit comments