nl.vv32.rcon:rcon

Java implementation of the RCON protocol


Keywords
csgo, java, minecraft, rcon
License
GPL-3.0

Documentation

RCON Java CI

Minimal implementation of the RCON protocol in Java.

Example (Java 8+)

public static void main(String[] args) throws IOException {

    try(Rcon rcon = Rcon.open("localhost", 25575)) {
        if (rcon.authenticate("password")) {
            System.out.println(rcon.sendCommand("list"));
        } else {
            System.out.println("Failed to authenticate");
        }
    }
}

Add RCON to your project

Gradle

Add to build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'nl.vv32.rcon:rcon:1.2.0'
}

Maven

Add to pom.xml:

<dependencies>
    <dependency>
        <groupId>nl.vv32.rcon</groupId>
        <artifactId>rcon</artifactId>
        <version>1.2.0</version>
    </dependency>
</dependencies>

Jar

If you're not using Gradle, you can download the latest version here.

Modifying client behaviour

By default (using Rcon.open), the client uses the RCON protocol as described by the Source RCON Protocol.

By using RconBuilder a couple of parameters can be changed:

  • Read buffer capacity
  • Write buffer capacity
  • Packet payload encoding

Example:

try (Rcon rcon = Rcon.newBuilder()
        .withChannel(SocketChannel.open(
                new InetSocketAddress("localhost", 25575)))
        .withCharset(StandardCharsets.UTF_8)
        .withReadBufferCapacity(1234)
        .withWriteBufferCapacity(1234)
        .build()) {
    
    ...
}