Query Minecraft servers with Rust
Go to file
2021-09-17 18:54:43 +02:00
examples Add example for tracking joining/leaving players 2021-01-14 19:26:46 +01:00
src Add a few imports 2021-09-17 18:54:43 +02:00
.gitignore Very late initial commit 2021-01-08 19:42:24 +01:00
Cargo.toml Change gen_session_id to mcstatus' implementation 2021-09-17 18:18:11 +02:00
LICENSE-APACHE Very late initial commit 2021-01-08 19:42:24 +01:00
LICENSE-MIT Very late initial commit 2021-01-08 19:42:24 +01:00
README.md Very late initial commit 2021-01-08 19:42:24 +01:00

mcquery

A tool for querying Minecraft servers

What does this crate provide?

  • An asynchronous, tokio-based library
  • Two examples (basic and full queries)

Usage

To perform a query, call Query::get_basic or Query::get_full. The returned response will either be a BasicQueryResponse or a FullQueryResponse respectively.

Examples

use mcquery::Query;
use std::time::Duration;

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let mut basic_query_buffer = [0; 128];
    let basic_query = Query::get_basic(
        "example.com:25565",
        Duration::from_secs(5),
        &mut basic_buffer
    ).await?;

    println!("{:#?}", basic_query);

    let mut full_query_buffer = [0; 1024];
    let full_query = Query::get_full(
        "example.com:25565",
        Duration::from_secs(5),
        &mut buffer
    ).await?;

    println!("{:#?}", full_query);

    Ok(())
}

Participation

Feel free to help resolve issues, create new ones, or open a pull request.

What's next?

  • Synchronous queries for those who want them
  • A Packet trait (currently async trait functions are not supported by Rust) or Request/Response structs

Development resources

Thank you to the Tokio project and the Minecraft Developer Wiki for providing a great asynchronous runtime and useful documentation! Without them, this crate wouldn't be possible.

License

This project is either licensed under the MIT or the Apache 2.0 license.