From 98413c917e3bdbe2b8e7f28fa7577d3fdd082690 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Thu, 22 Dec 2016 12:24:18 -0500 Subject: [PATCH] Update packet IDs --- .../com/comphenix/protocol/PacketType.java | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) 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.