修复来自服务端的KeepAlive心跳包未正确回应的问题

This commit is contained in:
SerendipityR 2022-08-23 00:07:04 +08:00 committed by GitHub
parent f0b86a5ddd
commit d2d5fccd91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -10,10 +10,12 @@ import cn.serendipityr.EndMinecraftPlusV2.VersionControl.VersionSupport578;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
import com.github.steveice10.packetlib.Client;
@ -398,6 +400,12 @@ public class BotAttack extends IAttack {
} else {
clickVerifiesHandle(chatPacket.getMessage(), session, username);
}
} else if (recvPacket instanceof ServerKeepAlivePacket) {
ClientKeepAlivePacket keepAlivePacket = new ClientKeepAlivePacket(((ServerKeepAlivePacket) recvPacket).getPingId());
session.send(keepAlivePacket);
if (!alivePlayers.contains(username)) {
alivePlayers.add(username);
}
}
}

View File

@ -6,16 +6,20 @@ import cn.serendipityr.EndMinecraftPlusV2.VersionControl.NewVersion.ACProtocol.A
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.NewVersion.ACProtocol.AntiCheat3;
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.NewVersion.ForgeProtocol.MCForge;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundKeepAlivePacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket;
import com.github.steveice10.packetlib.ProxyInfo;
import com.github.steveice10.packetlib.Session;
@ -429,6 +433,9 @@ public class NewBotAttack extends IAttack {
alivePlayers.add(username);
}
}
} else if (recvPacket instanceof ServerKeepAlivePacket) {
ClientKeepAlivePacket keepAlivePacket = new ClientKeepAlivePacket(((ServerKeepAlivePacket) recvPacket).getPingId());
session.send(keepAlivePacket);
}
}
@ -468,6 +475,12 @@ public class NewBotAttack extends IAttack {
VersionSupport758.sendClientSettingPacket(session, "zh_CN");
VersionSupport758.sendClientPlayerChangeHeldItemPacket(session, 1);
} else if (recvPacket instanceof ClientboundKeepAlivePacket) {
ServerboundKeepAlivePacket keepAlivePacket = new ServerboundKeepAlivePacket(((ClientboundKeepAlivePacket) recvPacket).getPingId());
session.send(keepAlivePacket);
if (!alivePlayers.contains(username)) {
alivePlayers.add(username);
}
} else if (recvPacket instanceof ClientboundPlayerPositionPacket) {
try {
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;

View File

@ -9,10 +9,12 @@ import io.netty.util.internal.ConcurrentSet;
import org.spacehq.mc.protocol.MinecraftProtocol;
import org.spacehq.mc.protocol.data.message.Message;
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
import org.spacehq.packetlib.Client;
@ -355,6 +357,12 @@ public class BotAttack extends IAttack {
} else if (recvPacket instanceof ServerChatPacket) {
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
clickVerifiesHandle(chatPacket.getMessage(), session, username);
} else if (recvPacket instanceof ServerKeepAlivePacket) {
ClientKeepAlivePacket keepAlivePacket = new ClientKeepAlivePacket(((ServerKeepAlivePacket) recvPacket).getPingId());
session.send(keepAlivePacket);
if (!alivePlayers.contains(username)) {
alivePlayers.add(username);
}
}
}