Automate the stress testing of a Minecraft server network using bots

Merge branch 'nik012003-main'

PureGero a4d691b6 11041380

Changed files
+12 -11
src
main
java
com
github
puregero
minecraftstresstest
+12 -11
src/main/java/com/github/puregero/minecraftstresstest/Bot.java
··· 11 11 import java.util.concurrent.TimeUnit; 12 12 13 13 public class Bot extends ChannelInboundHandlerAdapter { 14 - private static final int PROTOCOL_VERSION = Integer.parseInt(System.getProperty("bot.protocol.version", "758")); // 758 is 1.18.2 14 + private static final int PROTOCOL_VERSION = Integer.parseInt(System.getProperty("bot.protocol.version", "759")); // 759 is 1.19 https://wiki.vg/Protocol_version_numbers 15 15 private static final double RADIUS = Double.parseDouble(System.getProperty("bot.radius", "1000")); 16 16 private static final double CENTER_X = Double.parseDouble(System.getProperty("bot.x", "0")); 17 17 private static final double CENTER_Z = Double.parseDouble(System.getProperty("bot.z", "0")); ··· 56 56 FriendlyByteBuf loginStartPacket = new FriendlyByteBuf(ctx.alloc().buffer()); 57 57 loginStartPacket.writeVarInt(0x00); 58 58 loginStartPacket.writeUtf(username); 59 + loginStartPacket.writeBoolean(false); 59 60 ctx.writeAndFlush(loginStartPacket); 60 61 } 61 62 ··· 107 108 108 109 CompletableFuture.delayedExecutor(1000,TimeUnit.MILLISECONDS).execute(() -> { 109 110 FriendlyByteBuf settingsPacket = new FriendlyByteBuf(ctx.alloc().buffer()); 110 - settingsPacket.writeVarInt(0x05); 111 + settingsPacket.writeVarInt(0x07); 111 112 settingsPacket.writeUtf("en_GB"); 112 113 settingsPacket.writeByte(2); 113 114 settingsPacket.writeVarInt(0); ··· 163 164 } 164 165 165 166 FriendlyByteBuf movePacket = new FriendlyByteBuf(ctx.alloc().buffer()); 166 - movePacket.writeVarInt(0x12); 167 + movePacket.writeVarInt(0x14); 167 168 movePacket.writeDouble(x); 168 169 movePacket.writeDouble(y); 169 170 movePacket.writeDouble(z); ··· 175 176 176 177 private void channelReadPlay(ChannelHandlerContext ctx, FriendlyByteBuf byteBuf) { 177 178 int packetId = byteBuf.readVarInt(); 178 - // System.out.println("id " + packetId + " (" + (dataLength == 0 ? length : dataLength) + ")"); 179 + // System.out.println("id 0x" + Integer.toHexString(packetId) + " (" + (dataLength == 0 ? length : dataLength) + ")"); 179 180 180 - if (packetId == 0x1A) { 181 + if (packetId == 0x17) { 181 182 System.out.println(username + " (" + uuid + ") was kicked due to " + byteBuf.readUtf()); 182 183 ctx.close(); 183 - } else if (packetId == 0x21) { 184 + } else if (packetId == 0x1E) { 184 185 long id = byteBuf.readLong(); 185 186 186 187 FriendlyByteBuf keepAlivePacket = new FriendlyByteBuf(ctx.alloc().buffer()); 187 - keepAlivePacket.writeVarInt(0x0F); 188 + keepAlivePacket.writeVarInt(0x11); 188 189 keepAlivePacket.writeLong(id); 189 190 ctx.writeAndFlush(keepAlivePacket); 190 - } else if (packetId == 0x30) { 191 + } else if (packetId == 0x2D) { 191 192 int id = byteBuf.readInt(); 192 193 193 194 FriendlyByteBuf keepAlivePacket = new FriendlyByteBuf(ctx.alloc().buffer()); 194 - keepAlivePacket.writeVarInt(0x1D); 195 + keepAlivePacket.writeVarInt(0x1F); 195 196 keepAlivePacket.writeInt(id); 196 197 ctx.writeAndFlush(keepAlivePacket); 197 - } else if (packetId == 0x38) { 198 + } else if (packetId == 0x36) { 198 199 double dx = byteBuf.readDouble(); 199 200 double dy = byteBuf.readDouble(); 200 201 double dz = byteBuf.readDouble(); ··· 227 228 teleportConfirmPacket.writeVarInt(0x00); 228 229 teleportConfirmPacket.writeVarInt(id); 229 230 ctx.writeAndFlush(teleportConfirmPacket); 230 - } else if (packetId == 0x3C) { 231 + } else if (packetId == 0x3A) { 231 232 String url = byteBuf.readUtf(); 232 233 String hash = byteBuf.readUtf(); 233 234 boolean forced = byteBuf.readBoolean();