diff --git a/modules/API/src/main/java/com/comphenix/protocol/PacketType.java b/modules/API/src/main/java/com/comphenix/protocol/PacketType.java index bae5d325..555aa26f 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/PacketType.java +++ b/modules/API/src/main/java/com/comphenix/protocol/PacketType.java @@ -176,12 +176,12 @@ public class PacketType implements Serializable, Cloneable, Comparable map = lookup.getMap(protocol, sender); // Check the map first - String className = packetClass.getSimpleName(); - PacketType type = map.get(className); + String clazz = packetClass.getSimpleName(); + PacketType type = find(map, clazz); if (type == null) { - // Then check any aliases - for (PacketType check : map.values()) { - String[] aliases = check.getClassNames(); - if (aliases.length > 1) { - for (String alias : aliases) { - if (alias.equals(className)) { - // We have a match! - type = check; - } - } - } - } - // Guess we don't support this packet :/ - type = new PacketType(protocol, sender, packetId, -1, PROTOCOL_VERSION, className); + type = new PacketType(protocol, sender, packetId, -1, PROTOCOL_VERSION, clazz); type.dynamic = true; // Many may be scheduled, but only the first will be executed @@ -824,6 +811,28 @@ public class PacketType implements Serializable, Cloneable, Comparable map, String clazz) { + PacketType ret = map.get(clazz); + if (ret != null) { + return ret; + } + + // Check any aliases + for (PacketType check : map.values()) { + String[] aliases = check.getClassNames(); + if (aliases.length > 1) { + for (String alias : aliases) { + if (alias.equals(clazz)) { + // We have a match! + return check; + } + } + } + } + + return null; + } + /** * Lookup a packet type from a packet class. * @param packetClass - the packet class.