Skip to content

Commit

Permalink
Merge pull request #23 from leshleekor/develop
Browse files Browse the repository at this point in the history
Fix: ByteBuffer allocating
  • Loading branch information
MrGraversen authored Feb 14, 2024
2 parents c7dcbeb + ae869fc commit 651eee4
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 651eee4

Please sign in to comment.