Crate tetsu[][src]

Interface to Minecraft’s server protocol.

Examples

use std::env;
use std::thread;
use std::time;

use tetsu::errors;
use tetsu::server;
use tetsu::user;

let user = user::User::authenticate(
    env::var("MOJANG_USER").unwrap(),
    env::var("MOJANG_USER_PWD").unwrap(),
);

let mut server = server::Server::new("127.0.0.1", None, None).unwrap();

server.connect_player(user).unwrap();

loop {
    match server.read_event() {
        Ok(e) => println!("{:?}", e),
        Err(e) => match e {
            errors::ConnectionError::LockError(_) => {
                thread::sleep(time::Duration::from_millis(50));
                continue;
            }
            errors::ConnectionError::Error(e) => panic!("Error while reading event: {:?}", e),
        },
    }
}

Modules

errors

All possible errors.

event

The client/server communicates by sendingand receiving events. These act as a sort of common interface to Minecraft’s various packet implementations.

server

High level server connection.

user

Mojang user information.

Macros

protocol_impl

Autoimplement packets for a protocol version.