Skip to content

Commit

Permalink
Fix: ByteBuffer allocating
Browse files Browse the repository at this point in the history
  • Loading branch information
leshleekor committed Jan 24, 2024
1 parent c7dcbeb commit ae869fc
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ private ByteBuffer readData(int bytes) {

private ByteBuffer createRconByteBuffer(int requestCount, int requestType, String command) {
// In accordance with the RCON format: Length + Request ID + Type + Payload + Two nil bytes
ByteBuffer byteBuffer = ByteBuffer.allocate((3 * Integer.BYTES) + command.length() + (2 * Byte.BYTES));
ByteBuffer byteBuffer = ByteBuffer.allocate((3 * Integer.BYTES) + command.getBytes().length + (2 * Byte.BYTES));
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);

byteBuffer.putInt((2 * Integer.BYTES) + command.length() + (2 * Byte.BYTES));
byteBuffer.putInt((2 * Integer.BYTES) + command.getBytes().length + (2 * Byte.BYTES));
byteBuffer.putInt(requestCount);
byteBuffer.putInt(requestType);
byteBuffer.put(command.getBytes());
Expand Down

0 comments on commit ae869fc

Please sign in to comment.