Log the protocol phase in case of trying to obtain a packet id not existing in the phase (#1107)
This commit is contained in:
@@ -550,8 +550,8 @@ public enum StateRegistry {
|
||||
|
||||
public static final int STATUS_ID = 1;
|
||||
public static final int LOGIN_ID = 2;
|
||||
protected final PacketRegistry clientbound = new PacketRegistry(CLIENTBOUND);
|
||||
protected final PacketRegistry serverbound = new PacketRegistry(SERVERBOUND);
|
||||
protected final PacketRegistry clientbound = new PacketRegistry(CLIENTBOUND, this);
|
||||
protected final PacketRegistry serverbound = new PacketRegistry(SERVERBOUND, this);
|
||||
|
||||
public StateRegistry.PacketRegistry.ProtocolRegistry getProtocolRegistry(Direction direction,
|
||||
ProtocolVersion version) {
|
||||
@@ -562,11 +562,13 @@ public enum StateRegistry {
|
||||
public static class PacketRegistry {
|
||||
|
||||
private final Direction direction;
|
||||
private final StateRegistry registry;
|
||||
private final Map<ProtocolVersion, ProtocolRegistry> versions;
|
||||
private boolean fallback = true;
|
||||
|
||||
PacketRegistry(Direction direction) {
|
||||
PacketRegistry(Direction direction, StateRegistry registry) {
|
||||
this.direction = direction;
|
||||
this.registry = registry;
|
||||
|
||||
Map<ProtocolVersion, ProtocolRegistry> mutableVersions = new EnumMap<>(ProtocolVersion.class);
|
||||
for (ProtocolVersion version : ProtocolVersion.values()) {
|
||||
@@ -693,8 +695,9 @@ public enum StateRegistry {
|
||||
final int id = this.packetClassToId.getInt(packet.getClass());
|
||||
if (id == Integer.MIN_VALUE) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Unable to find id for packet of type %s in %s protocol %s",
|
||||
packet.getClass().getName(), PacketRegistry.this.direction, this.version
|
||||
"Unable to find id for packet of type %s in %s protocol %s phase %s",
|
||||
packet.getClass().getName(), PacketRegistry.this.direction,
|
||||
this.version, PacketRegistry.this.registry
|
||||
));
|
||||
}
|
||||
return id;
|
||||
|
Reference in New Issue
Block a user