fix PLAY:KeepAlive
This commit is contained in:
@@ -50,12 +50,14 @@ public enum State {
|
|||||||
0x00, TeleportConfirmPacket.class,
|
0x00, TeleportConfirmPacket.class,
|
||||||
0x04, ClientSettingsPacket.class,
|
0x04, ClientSettingsPacket.class,
|
||||||
0x09, PluginMessagePacket.class,
|
0x09, PluginMessagePacket.class,
|
||||||
|
0x0B, PingPacket.class,
|
||||||
0x0D, PlayerPositionPacket.class,
|
0x0D, PlayerPositionPacket.class,
|
||||||
0x0E, CPlayerPositionAndLookPacket.class,
|
0x0E, CPlayerPositionAndLookPacket.class,
|
||||||
0x0F, PlayerLookPacket.class
|
0x0F, PlayerLookPacket.class
|
||||||
),
|
),
|
||||||
// client bound
|
// client bound
|
||||||
Map.of(
|
Map.of(
|
||||||
|
PingPacket.class, 0x1F,
|
||||||
JoinGamePacket.class, 0x23,
|
JoinGamePacket.class, 0x23,
|
||||||
SpawnPositionPacket.class, 0x46,
|
SpawnPositionPacket.class, 0x46,
|
||||||
ChunkDataPacket.class, 0x20,
|
ChunkDataPacket.class, 0x20,
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class Main {
|
|||||||
State.STATUS.packetFlux(PingPacket.class).subscribe(packetHandler::onKeepAlive);
|
State.STATUS.packetFlux(PingPacket.class).subscribe(packetHandler::onKeepAlive);
|
||||||
State.STATUS.packetFlux(StatusServerRequestPacket.class).subscribe(packetHandler::onServerStatus);
|
State.STATUS.packetFlux(StatusServerRequestPacket.class).subscribe(packetHandler::onServerStatus);
|
||||||
State.LOGIN.packetFlux(LoginStartPacket.class).subscribe(packetHandler::onLoginStart);
|
State.LOGIN.packetFlux(LoginStartPacket.class).subscribe(packetHandler::onLoginStart);
|
||||||
|
State.PLAY.packetFlux(PingPacket.class).subscribe(packetHandler::onKeepAlivePlay);
|
||||||
|
|
||||||
server.bind(config.server().host(), config.server().port());
|
server.bind(config.server().host(), config.server().port());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public class PacketHandler {
|
|||||||
channel.getCtx().writeAndFlush(channel.getPacket()).channel().disconnect();
|
channel.getCtx().writeAndFlush(channel.getPacket()).channel().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onKeepAlivePlay(ChannelContext<PingPacket> channel) {
|
||||||
|
channel.getCtx().writeAndFlush(channel.getPacket());
|
||||||
|
}
|
||||||
|
|
||||||
public void onServerStatus(ChannelContext<StatusServerRequestPacket> channel) {
|
public void onServerStatus(ChannelContext<StatusServerRequestPacket> channel) {
|
||||||
ServerInfo serverInfo = new ServerInfo();
|
ServerInfo serverInfo = new ServerInfo();
|
||||||
serverInfo.version().name(ProtocolConstant.PROTOCOL_NAME);
|
serverInfo.version().name(ProtocolConstant.PROTOCOL_NAME);
|
||||||
@@ -106,7 +110,14 @@ public class PacketHandler {
|
|||||||
playerPositionAndLookPacket.setLook(new Look(0f, 0f));
|
playerPositionAndLookPacket.setLook(new Look(0f, 0f));
|
||||||
playerPositionAndLookPacket.setTeleportId(random.nextInt());
|
playerPositionAndLookPacket.setTeleportId(random.nextInt());
|
||||||
|
|
||||||
channel.getCtx().writeAndFlush(playerPositionAndLookPacket);
|
channel.getCtx().write(playerPositionAndLookPacket);
|
||||||
|
|
||||||
|
PingPacket pingPacket = new PingPacket();
|
||||||
|
pingPacket.setPayload(System.currentTimeMillis());
|
||||||
|
|
||||||
|
channel.getCtx().write(pingPacket);
|
||||||
|
|
||||||
|
channel.getCtx().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String faviconToBase64(Path iconPath) {
|
private static String faviconToBase64(Path iconPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user