Skip to content

TinyTsuki/rcon

 
 

Repository files navigation

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 'xin.vanilla.rcon:rcon:1.2.1'
}

Maven

Add to pom.xml:

<dependencies>
    <dependency>
        <groupId>xin.vanilla.rcon</groupId>
        <artifactId>rcon</artifactId>
        <version>1.2.1</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()) {
    
    ...
}

About

Minimal RCON client in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%