Automate the stress testing of a Minecraft server network using bots

Support non-compressed packets

PureGero c3b0f3a5 f696b2c1

Changed files
+12 -10
src
main
java
com
github
puregero
minecraftstresstest
+12 -10
src/main/java/com/github/puregero/minecraftstresstest/Bot.java
··· 45 45 46 46 sendLoginPackets(in, out); 47 47 48 - if (!compressed) { 49 - System.out.println("Not compressed!!!"); 50 - } 51 - 52 48 FriendlyDataOutputStream settingsPacket = new FriendlyDataOutputStream(); 53 49 settingsPacket.write(0x05); 54 50 settingsPacket.writeString("en_GB"); ··· 60 56 settingsPacket.writeBoolean(false); 61 57 settingsPacket.writeBoolean(true); 62 58 63 - out.writeVarInt(settingsPacket.size() + 1); 64 - out.writeVarInt(0); 65 - out.write(settingsPacket.toByteArray()); 59 + writePacket(out, settingsPacket.toByteArray()); 66 60 67 61 CompletableFuture.delayedExecutor(1000,TimeUnit.MILLISECONDS).execute(() -> tick(socket)); 68 62 ··· 84 78 System.out.println(username + " has disconnected from " + address + ":" + port); 85 79 } 86 80 81 + public void writePacket(FriendlyDataOutputStream out, byte[] bytes) throws IOException { 82 + if (compressed) { 83 + out.writeVarInt(bytes.length + 1); 84 + out.writeVarInt(0); 85 + } else { 86 + out.writeVarInt(bytes.length); 87 + } 88 + out.write(bytes); 89 + } 90 + 87 91 private void tick(Socket socket) { 88 92 try { 89 93 if (socket.isClosed()) return; ··· 120 124 movePacket.writeBoolean(true); 121 125 122 126 FriendlyDataOutputStream out = new FriendlyDataOutputStream(new BufferedOutputStream(socket.getOutputStream())); 123 - out.writeVarInt(movePacket.size() + 1); 124 - out.writeVarInt(0); 125 - out.write(movePacket.toByteArray()); 127 + writePacket(out, movePacket.toByteArray()); 126 128 out.flush(); 127 129 } catch (IOException e) { 128 130 e.printStackTrace();