Small optimization to PacketProtocol.getOutgoingId(Class<? extends Packet>)

This commit is contained in:
ipbeegle 2020-05-20 23:37:46 -04:00
parent 27cdf88b36
commit 74ee4fa02b

View file

@ -137,11 +137,12 @@ public abstract class PacketProtocol {
* @throws IllegalArgumentException If the packet is not registered. * @throws IllegalArgumentException If the packet is not registered.
*/ */
public final int getOutgoingId(Class<? extends Packet> packetClass) { public final int getOutgoingId(Class<? extends Packet> packetClass) {
if(!this.outgoing.containsKey(packetClass) || this.outgoing.get(packetClass) == null) { Integer packetId = this.outgoing.get(packetClass);
if(packetId == null) {
throw new IllegalArgumentException("Unregistered outgoing packet class: " + packetClass.getName()); throw new IllegalArgumentException("Unregistered outgoing packet class: " + packetClass.getName());
} }
return this.outgoing.get(packetClass); return packetId;
} }
/** /**