1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/// The main library module for the Minecraft management system.
///
/// This library provides functionalities for managing Minecraft installations,
/// including authentication, downloading necessary files, and launching the game.
///
/// # Modules
/// - `auth`: Handles authentication with Microsoft and Xbox Live.
/// - `error`: Defines error types used throughout the library.
/// - `http`: Provides HTTP utilities for making requests.
/// - `json`: Contains utilities for handling JSON data.
/// - `minecraft`: Manages Minecraft-specific functionalities, including installation and launching.
/// - `util`: Contains various utility functions and types.
///
/// # Examples
///
/// You can find examples of how to use this library in the `examples` directory.
/// For instance, the `with_emitter` example demonstrates how to track download progress
/// and launch Minecraft. Below is the code for the `with_emitter` example:
///
/// ```rust
/// use std::env;
///
/// use lyceris::minecraft::{
/// config::ConfigBuilder,
/// emitter::{Emitter, Event},
/// install::install,
/// launch::launch,
/// };
///
/// /// Example of using the Emitter to track download progress and launch Minecraft.
/// ///
/// /// This example demonstrates how to set up an Emitter to listen for download
/// /// progress events and launch the Minecraft game with a specified configuration.
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let emitter = Emitter::default();
///
/// emitter
/// .on(
/// Event::SingleDownloadProgress,
/// |(path, current, total): (String, u64, u64)| {
/// println!("Downloading {} - {}/{}", path, current, total);
/// },
/// )
/// .await;
///
/// emitter
/// .on(
/// Event::MultipleDownloadProgress,
/// |(current, total): (u64, u64)| {
/// println!("Downloading {}/{}", current, total);
/// },
/// )
/// .await;
///
/// emitter
/// .on(Event::Console, |line: String| {
/// println!("Line: {}", line);
/// })
/// .await;
///
/// let current_dir = env::current_dir()?;
/// let config = ConfigBuilder::new(
/// current_dir.join("game"),
/// "1.21.4".into(),
/// lyceris::auth::AuthMethod::Offline {
/// username: "Lyceris".into(),
/// uuid: None,
/// },
/// )
/// .build();
///
/// install(&config, Some(&emitter)).await?;
/// launch(&config, Some(&emitter)).await?.wait().await?;
///
/// Ok(())
/// }
/// ```
// Re-export commonly used items for easier access
pub use AuthMethod;
pub use Error;
pub use ;
pub use ;
pub use Config;
pub use ;
pub use ;
/// A type alias for results returned by library functions.
pub type Result<T> = Result;