|
10 | 10 | import org.apache.logging.log4j.LogManager; |
11 | 11 | import org.apache.logging.log4j.Logger; |
12 | 12 |
|
13 | | -final class PlayerHandler extends SimpleChannelInboundHandler<ByteBuf> { |
| 13 | +final class PlayerHandler extends SimpleChannelInboundHandler<DatagramPacket> { |
14 | 14 |
|
15 | 15 | private static final Logger logger = LogManager.getLogger(PlayerHandler.class); |
16 | 16 |
|
17 | 17 | @Override |
18 | | - protected void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) { |
| 18 | + protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) { |
19 | 19 |
|
20 | | - if (ByteBufUtil.equals(Packets.A2S_PLAYER_CHALLENGE_RESPONSE, byteBuf.slice(0, 5))) { |
| 20 | + if (ByteBufUtil.equals(Packets.A2S_PLAYER_CHALLENGE_RESPONSE, datagramPacket.content().slice(0, 5))) { |
21 | 21 | ByteBuf responseBuf = ctx.alloc().buffer() |
22 | 22 | .writeBytes(Packets.A2S_PLAYER_REQUEST_HEADER.retainedDuplicate()) |
23 | | - .writeBytes(byteBuf.slice(5, 4)); |
| 23 | + .writeBytes(datagramPacket.content().slice(5, 4)); |
24 | 24 |
|
25 | 25 | ctx.channel().writeAndFlush(responseBuf); |
26 | | - } else if (ByteBufUtil.equals(Packets.A2S_PLAYER_RESPONSE_HEADER, byteBuf.slice(0, 5))) { |
| 26 | + } else if (ByteBufUtil.equals(Packets.A2S_PLAYER_RESPONSE_HEADER, datagramPacket.content().slice(0, 5))) { |
27 | 27 | // Set new Packet Data |
28 | 28 | CacheHub.A2S_PLAYER.clear(); |
29 | | - CacheHub.A2S_PLAYER.writeBytes(byteBuf); |
| 29 | + CacheHub.A2S_PLAYER.writeBytes(datagramPacket.content()); |
30 | 30 |
|
31 | 31 | logger.atDebug().log("New A2SPlayer Update Cached Successfully"); |
32 | 32 | } else { |
33 | | - logger.atError().log("Received unsupported A2S Player Response from Game Server: {}", ByteBufUtil.hexDump(byteBuf)); |
| 33 | + logger.atError().log("Received unsupported A2S Player Response from Game Server: {}", ByteBufUtil.hexDump(datagramPacket.content())); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | } |
0 commit comments