Crates.io | minecraft-client-rs |
lib.rs | minecraft-client-rs |
version | 0.1.3 |
source | src |
created_at | 2021-03-20 06:00:53.070233 |
updated_at | 2022-08-02 12:56:04.721022 |
description | A client for the Minecraft RCON protocol. |
homepage | |
repository | |
max_upload_size | |
id | 371281 |
size | 56,597 |
A client for the Minecraft RCON protocol.
// Create a new client and connect to the server.
let mut client = Client::new("127.0.0.1:25575".to_string()).unwrap();
// Send some commands.
match client.authenticate("password".to_string()) {
Ok(_) => { },
Err(e) => { /* handle authentication error */ },
}
match client.send_command("seed".to_string()) {
Ok(resp) => { println!("{}", resp.body); }, // "Seed: [1871644822592853811]"
Err(e) => { /* handle error */ },
}
// Disconnect cleanly when finished.
client.close().unwrap();
If you are looking for a tool rather than a library, try the shell command:
# Single command mode
$ cargo run -F cli -- -h 127.0.0.1:25575 -p minecraft seed
Seed: [5454567064266725003]
# Interactive mode
$ cargo run -F cli -- -h 127.0.0.1:25575 -p minecraft -i
Starting RCON shell. Use 'exit', 'quit', or Ctrl-C to exit.
> list
There are 0 of a max of 20 players online:
> seed
Seed: [5454567064266725003]
Response bodies over 4KB will be truncated.
$ docker pull itzg/minecraft-server
$ docker run --name=minecraft-server -p 25575:25575 -d -e EULA=TRUE itzg/minecraft-server
To run unit tests:
$ cargo test --lib
To run integration tests after starting the test server in Docker:
$ cargo test