Skip to content

Commit 98413c9

Browse files
committed
Update packet IDs
1 parent 540a5e5 commit 98413c9

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

modules/API/src/main/java/com/comphenix/protocol/PacketType.java

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ public static class Server extends ObjectEnum<PacketType> {
176176
public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x43, 0x05, "SpawnPosition");
177177
public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x44, 0x03, "UpdateTime");
178178
public static final PacketType TITLE = new PacketType(PROTOCOL, SENDER, 0x45, 0x45, "Title");
179-
public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x47, 0x29, "NamedSoundEffect");
180-
public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x48, 0x47, "PlayerListHeaderFooter");
181-
public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x49, 0x0D, "Collect");
182-
public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x4A, 0x18, "EntityTeleport");
183-
public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x4B, 0x20, "UpdateAttributes");
184-
public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4C, 0x1D, "EntityEffect");
179+
public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x46, 0x47, "NamedSoundEffect");
180+
public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x47, 0x48, "PlayerListHeaderFooter");
181+
public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x48, 0x49, "Collect");
182+
public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x49, 0x4A, "EntityTeleport");
183+
public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x4A, 0x4B, "UpdateAttributes");
184+
public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4B, 0x4C, "EntityEffect");
185185

186186
// ---- Removed in 1.9
187187

@@ -797,24 +797,11 @@ public static PacketType fromCurrent(Protocol protocol, Sender sender, int packe
797797
Map<String, PacketType> map = lookup.getMap(protocol, sender);
798798

799799
// Check the map first
800-
String className = packetClass.getSimpleName();
801-
PacketType type = map.get(className);
800+
String clazz = packetClass.getSimpleName();
801+
PacketType type = find(map, clazz);
802802
if (type == null) {
803-
// Then check any aliases
804-
for (PacketType check : map.values()) {
805-
String[] aliases = check.getClassNames();
806-
if (aliases.length > 1) {
807-
for (String alias : aliases) {
808-
if (alias.equals(className)) {
809-
// We have a match!
810-
type = check;
811-
}
812-
}
813-
}
814-
}
815-
816803
// Guess we don't support this packet :/
817-
type = new PacketType(protocol, sender, packetId, -1, PROTOCOL_VERSION, className);
804+
type = new PacketType(protocol, sender, packetId, -1, PROTOCOL_VERSION, clazz);
818805
type.dynamic = true;
819806

820807
// Many may be scheduled, but only the first will be executed
@@ -824,6 +811,28 @@ public static PacketType fromCurrent(Protocol protocol, Sender sender, int packe
824811
return type;
825812
}
826813

814+
private static PacketType find(Map<String, PacketType> map, String clazz) {
815+
PacketType ret = map.get(clazz);
816+
if (ret != null) {
817+
return ret;
818+
}
819+
820+
// Check any aliases
821+
for (PacketType check : map.values()) {
822+
String[] aliases = check.getClassNames();
823+
if (aliases.length > 1) {
824+
for (String alias : aliases) {
825+
if (alias.equals(clazz)) {
826+
// We have a match!
827+
return check;
828+
}
829+
}
830+
}
831+
}
832+
833+
return null;
834+
}
835+
827836
/**
828837
* Lookup a packet type from a packet class.
829838
* @param packetClass - the packet class.

0 commit comments

Comments
 (0)