Archived
0

check send packet

This commit is contained in:
2021-05-03 17:07:51 +03:00
parent 627cee9af3
commit de27654e67

View File

@@ -10,15 +10,17 @@ import mc.protocol.State;
import mc.protocol.io.NetByteBuf; import mc.protocol.io.NetByteBuf;
import mc.protocol.packets.ServerSidePacket; import mc.protocol.packets.ServerSidePacket;
import java.util.Objects;
@Slf4j @Slf4j
public class ProtocolEncoder extends MessageToByteEncoder<ServerSidePacket> { public class ProtocolEncoder extends MessageToByteEncoder<ServerSidePacket> {
@Override @Override
protected void encode(ChannelHandlerContext ctx, ServerSidePacket packet, ByteBuf out) { protected void encode(ChannelHandlerContext ctx, ServerSidePacket packet, ByteBuf out) {
State state = ctx.channel().attr(NetworkAttributes.STATE).get(); State state = ctx.channel().attr(NetworkAttributes.STATE).get();
int packetId = Objects.requireNonNull(state.getServerSidePacketId(packet.getClass())); Integer packetId = state.getServerSidePacketId(packet.getClass());
if (packetId == null) {
log.error("Unknown send packet: State {} ; Class {}", state, packet.getClass());
return;
}
log.debug("OUT: {}:{}", state, packet); log.debug("OUT: {}:{}", state, packet);