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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
#![warn(missing_docs)]
#![warn(
missing_debug_implementations,
clippy::print_stderr,
clippy::print_stdout
)]
//! # cobble-core
//!
//! [](https://crates.io/crates/cobble-core)
//! [](https://docs.rs/cobble-core)
//! [](https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html)
//! [](https://deps.rs/repo/gitlab/stefan99353/cobble-core)
//! [](https://opensource.org/licenses/MIT)
//!
//! A Rust library for managing, installing and launching Minecraft instances.
//!
//! ## Usage
//!
//! ### Authentication
//!
//! ```rust
//! # use cobble_core::profile::Profile;
//! # use std::sync::{atomic::AtomicBool, Arc};
//! #
//! # fn function() -> Result<(), Box<dyn std::error::Error>> {
//! #
//! let client_id = "<MS Graph Client ID>".to_string();
//! let client_secret = "<MS Graph Client Secret>".to_string();
//!
//! let cancel = Arc::new(AtomicBool::new(false));
//! let (url, result) = Profile::authenticate(client_id, client_secret, cancel)?;
//!
//! println!("{}", url);
//!
//! let profile: Profile = result.recv()??;
//! println!("Minecraft Playername: {}", profile.player_name);
//! #
//! # Ok(())
//! # }
//! ```
//!
//! ### Installing
//!
//! ```rust
//! # use cobble_core::instance::{Instance, InstanceBuilder};
//! # use std::sync::atomic::AtomicBool;
//! # use std::sync::Arc;
//! #
//! # fn function() -> Result<(), Box<dyn std::error::Error>> {
//! #
//! let instance: Instance = InstanceBuilder::default()
//! .name("Test Instance".to_string())
//! .version("1.18.2".to_string())
//! .instance_path("./instance".to_string())
//! .libraries_path("./libraries".to_string())
//! .assets_path("./assets".to_string())
//! .build()?;
//!
//! let (tx, _rx) = Instance::update_channel();
//! let cancel = Arc::new(AtomicBool::new(false));
//!
//! instance.full_install(tx, cancel)?;
//! #
//! # Ok(())
//! # }
//! ```
//!
//! ### Launching
//!
//! ```rust
//! # use cobble_core::instance::{Instance, InstanceBuilder};
//! # use cobble_core::minecraft::launch_options::LaunchOptionsBuilder;
//! #
//! # fn function() -> Result<(), Box<dyn std::error::Error>> {
//! #
//! let instance: Instance = InstanceBuilder::default()
//! .name("Test Instance".to_string())
//! .version("1.18.2".to_string())
//! .instance_path("./instance".to_string())
//! .libraries_path("./libraries".to_string())
//! .assets_path("./assets".to_string())
//! .build()?;
//!
//! instance.launch(&LaunchOptionsBuilder::default().build()).unwrap();
//! #
//! # Ok(())
//! # }
//! ```
//!
//! ## Cargo Features
//!
//! | Feature | Description |
//! |-----------|-----------------------------------------------|
//! | `gobject` | Provides glib objects for the primary structs |
//!
//! ## Future Development
//!
//! - [ ] Minecraft
//! - [ ] Installation
//! - [x] Current Versions
//! - [ ] Old Versions (needs testing)
//! - [ ] Launching
//! - [x] Current Versions
//! - [ ] Old Versions (needs testing)
//! - [ ] Saves
//! - [ ] Servers
//! - [ ] Resourcepacks
//! - [ ] Logs
//! - [ ] Support other platforms than linux (process forking)
//! - [ ] Instances
//! - [x] Installation
//! - [x] Launching
//! - [ ] Installed status
//! - [ ] Removing
//! - [ ] Export / Import
//! - [ ] Fabric
//! - [ ] Installation
//! - [ ] Updating
//! - [ ] Mods
//! - [ ] Mod Manager
#[macro_use]
extern crate log;
/// Contains URLs for authentication and minecraft resources.
pub mod consts;
/// Error for interaction with this crate.
pub mod error;
/// Glib Objects for GTK development.
#[cfg(feature = "gobject")]
pub mod gobject;
/// Instance related structs and functions.
pub mod instance;
/// Minecraft related structs and functions.
pub mod minecraft;
/// Profile and authentication.
pub mod profile;
pub(crate) mod utils;
pub use error::CobbleResult;
pub use instance::{Instance, InstanceBuilder};
pub use minecraft::launch_options::{LaunchOptions, LaunchOptionsBuilder};
pub use profile::Profile;