Skip to content

Rcon client for Java and Kotlin, available for Minecraft/Factorio

License

Notifications You must be signed in to change notification settings

MukjepScarlet/rcon4j

Repository files navigation

rcon4j

An RCON client library for Java and Kotlin (JVM/Android).

Depends on: kotlin-stdlib

Modules

  • rcon4j-core: Based on Java Socket API.
  • rcon4j-kotlin: Based on ktor-network (CIO) library and Kotlin coroutines.

Usage

  1. Include the JitPack repository to your project, example (build.gradle.kts):
    repositories {
        mavenCentral()
        maven("https://jitpack.io")
    }
  2. Import the library with a proper version:
    dependencies {
        implementation("com.github.MukjepScarlet.rcon4j:rcon4j-core:$version")
        implementation("com.github.MukjepScarlet.rcon4j:rcon4j-kotlin:$version")
    }

Overview

Default Charset: StandardCharsets.UTF_8

Default request ID: Random.nextInt(1, Int.MAX_VALUE) (Kotlin thread-safe Random)

Socket

// Packet
class RconPacket(int id, int type, byte[] payload) { /*...*/ }

class RconClient implements AutoCloseable {
   public RconClient(
           String host,
           int port,
           String password,
           Charset charset, // default
           int requestId // default
   ) throws IOException, AuthenticationException { /*...*/ }

   @NotNull
   public String command(@NotNull String payload) throws IOException { /*...*/ }
}

CIO

suspend fun ARconClient(
   host: String,
   port: Int,
   password: String,
   charset: Charset, // default
   requestId: Int, // default
   socketBuilder: SocketBuilder,
): ARconClient { /*...*/ }

suspend fun ARconClient.command(payload: String): String { /*...*/ }

About

Rcon client for Java and Kotlin, available for Minecraft/Factorio

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages