@@ -176,12 +176,12 @@ public static class Server extends ObjectEnum<PacketType> {
176
176
public static final PacketType SPAWN_POSITION = new PacketType (PROTOCOL , SENDER , 0x43 , 0x05 , "SpawnPosition" );
177
177
public static final PacketType UPDATE_TIME = new PacketType (PROTOCOL , SENDER , 0x44 , 0x03 , "UpdateTime" );
178
178
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" );
185
185
186
186
// ---- Removed in 1.9
187
187
@@ -797,24 +797,11 @@ public static PacketType fromCurrent(Protocol protocol, Sender sender, int packe
797
797
Map <String , PacketType > map = lookup .getMap (protocol , sender );
798
798
799
799
// 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 );
802
802
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
-
816
803
// 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 );
818
805
type .dynamic = true ;
819
806
820
807
// 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
824
811
return type ;
825
812
}
826
813
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
+
827
836
/**
828
837
* Lookup a packet type from a packet class.
829
838
* @param packetClass - the packet class.
0 commit comments