lighty-launcher 0.8.6

A modern minecraft launcher library supporting multiple mod loaders fabric quilt, forge, neoforge, vanilla, and more
Documentation
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# LightyLauncher


[![Crates.io](https://img.shields.io/crates/v/lighty-launcher.svg)](https://crates.io/crates/lighty-launcher)
[![Documentation](https://docs.rs/lighty-launcher/badge.svg)](https://docs.rs/lighty-launcher)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Rust Version](https://img.shields.io/badge/rust-1.75%2B-orange.svg)](https://www.rust-lang.org)

> **ACTIVE DEVELOPMENT** - API may change between versions. Use with caution in production.

A modern, modular Minecraft launcher library for Rust with full async support, real-time event system, and automatic Java management.

![LightyUpdater Banner](img/banner.png)

## Features


- **Modular Architecture**: Organized into logical namespaces (`auth`, `event`, `java`, `launch`, `loaders`, `version`, `core`)
- **Multi-Loader Support**: Vanilla, Fabric, Quilt, NeoForge, Forge, OptiFine, LightyUpdater
- **Event System**: Real-time progress tracking for all operations (downloads, installations, authentication)
- **Authentication**: Offline, Microsoft OAuth 2.0, Azuriom CMS + trait-based extensibility for custom providers
- **Automatic Java Management**: Download and manage JRE distributions (Temurin, GraalVM, Zulu, Liberica)
- **Async/Await**: Built on Tokio for maximum performance
- **Smart Caching**: Dual cache (raw + query) with configurable TTL
- **Type-Safe**: Strongly typed API with comprehensive error handling
- **Cross-Platform**: Windows, Linux, and macOS support
- **Performance Optimized**: Parallel downloads, async I/O, minimal dependencies

## Installation


Add to your `Cargo.toml`:

```toml
[dependencies]
lighty-launcher = { version = "0.6", features = ["vanilla", "events"] }
tokio = { version = "1", features = ["full"] }
directories = "6.0"
once_cell = "1.21"
tracing-subscriber = "0.3"
anyhow = "1.0"
```

## Quick Start


### Basic Example - Vanilla Minecraft


```rust
use lighty_launcher::{
    auth::{OfflineAuth, Authenticator},
    java::JavaDistribution,
    launch::Launch,
    loaders::Loader,
    version::VersionBuilder,
};
use directories::ProjectDirs;
use once_cell::sync::Lazy;

static LAUNCHER_DIR: Lazy<ProjectDirs> = Lazy::new(|| {
    ProjectDirs::from("com", "MyLauncher", "")
        .expect("Failed to create project directories")
});

#[tokio::main]

async fn main() -> anyhow::Result<()> {
    tracing_subscriber::fmt::init();

    // Authenticate
    let mut auth = OfflineAuth::new("PlayerName");
    let profile = auth.authenticate().await?;

    // Create version instance
    let mut version = VersionBuilder::new(
        "vanilla-1.21.1",
        Loader::Vanilla,
        "",
        "1.21.1",
        &LAUNCHER_DIR
    );

    // Launch the game
    version.launch(&profile, JavaDistribution::Temurin)
        .run()
        .await?;

    Ok(())
}
```

### Using the Prelude


For convenience, import commonly used types:

```rust
use lighty_launcher::prelude::*;
use directories::ProjectDirs;

#[tokio::main]

async fn main() -> anyhow::Result<()> {
    let launcher_dir = ProjectDirs::from("com", "MyLauncher", "").unwrap();

    let mut auth = OfflineAuth::new("Player");
    let profile = auth.authenticate().await?;

    let mut version = VersionBuilder::new(
        "my-instance",
        Loader::Vanilla,
        "",
        "1.21.1",
        &launcher_dir
    );

    version.launch(&profile, JavaDistribution::Temurin)
        .run()
        .await?;

    Ok(())
}
```

## Modules


LightyLauncher is organized into logical modules, each with its own namespace:

### `lighty_launcher::auth` - Authentication


Multiple authentication methods with a unified, extensible interface:

```rust
use lighty_launcher::auth::{OfflineAuth, MicrosoftAuth, AzuriomAuth, Authenticator};

// Offline (no network required)
let mut auth = OfflineAuth::new("Player");
let profile = auth.authenticate().await?;

// Microsoft OAuth 2.0
let mut auth = MicrosoftAuth::new();
let profile = auth.authenticate().await?;

// Azuriom CMS
let mut auth = AzuriomAuth::new("https://example.com");
let profile = auth.authenticate().await?;
```

**Custom Authentication:**

Implement the `Authenticator` trait to create your own provider:

```rust
use lighty_launcher::auth::{Authenticator, UserProfile, UserRole, AuthResult};

pub struct MyCustomAuth {
    api_url: String,
}

impl Authenticator for MyCustomAuth {
    async fn authenticate(
        &mut self,
        #[cfg(feature = "events")] event_bus: Option<&EventBus>,
    ) -> AuthResult<UserProfile> {
        // Your custom logic here
        Ok(UserProfile {
            username: "Player".to_string(),
            uuid: "uuid-here".to_string(),
            access_token: Some("token".to_string()),
            role: UserRole::User,
        })
    }
}
```

**Key Types:**
- `OfflineAuth` - Offline authentication (UUID v5 generation)
- `MicrosoftAuth` - Microsoft/Xbox Live OAuth 2.0
- `AzuriomAuth` - Azuriom CMS integration
- `Authenticator` - Trait for creating custom authentication providers
- `UserProfile` - User data (username, UUID, access token)
- `generate_offline_uuid()` - Helper to create deterministic UUIDs

### `lighty_launcher::event` - Event System


Real-time progress tracking for all launcher operations:

```rust
use lighty_launcher::event::{EventBus, Event, LaunchEvent, AuthEvent, JavaEvent};

// Create event bus
let event_bus = EventBus::new(1000);
let mut receiver = event_bus.subscribe();

// Listen to events
tokio::spawn(async move {
    while let Ok(event) = receiver.next().await {
        match event {
            Event::Launch(LaunchEvent::InstallProgress { bytes }) => {
                println!("Downloaded {} bytes", bytes);
            }
            Event::Java(JavaEvent::JavaDownloadStarted { distribution, version, total_bytes }) => {
                println!("Downloading {} {} ({} MB)", distribution, version, total_bytes / 1_000_000);
            }
            _ => {}
        }
    }
});

// Use with authentication
let profile = auth.authenticate(Some(&event_bus)).await?;

// Use with launch
version.launch(&profile, JavaDistribution::Temurin)
    .with_event_bus(&event_bus)
    .run()
    .await?;
```

**Event Types:**
- `AuthEvent` - Authentication progress
- `JavaEvent` - JRE download/extraction
- `LaunchEvent` - Installation/launch progress
- `LoaderEvent` - Loader metadata fetching
- `CoreEvent` - Archive extraction

See [crates/event/README.md](crates/event/README.md) for complete documentation.

### `lighty_launcher::java` - Java Management


Automatic Java runtime download and installation:

```rust
use lighty_launcher::java::{JavaDistribution, JavaRuntime};

// Distributions are automatically managed
JavaDistribution::Temurin   // Recommended, supports all Java versions
JavaDistribution::GraalVM    // High performance, Java 17+ only
JavaDistribution::Zulu       // Enterprise support available
JavaDistribution::Liberica   // Lightweight alternative
```

**Supported Distributions:**

| Distribution | Java Versions | Type | Size (Java 21) | Best For |
|--------------|---------------|------|----------------|----------|
| Temurin | 8, 11, 17, 21+ | JRE | ~42 MB | General use, best compatibility |
| GraalVM | 17+ only | JDK | ~303 MB | Maximum performance |
| Zulu | 8, 11, 17, 21+ | JRE | ~82 MB | Enterprise support |
| Liberica | 8, 11, 17, 21+ | JRE | ~50 MB | Lightweight |

### `lighty_launcher::launch` - Game Launching


Complete launch orchestration with customization options:

```rust
use lighty_launcher::launch::{Launch, LaunchBuilder, DownloaderConfig, init_downloader_config};
use lighty_launcher::launch::keys::*;

// Configure downloader (optional)
init_downloader_config(DownloaderConfig {
    max_concurrent_downloads: 100,
    max_retries: 5,
    initial_delay_ms: 50,
});

// Launch with custom JVM options and arguments
version.launch(&profile, JavaDistribution::Temurin)
    .with_jvm_options()
        .set("Xmx", "4G")
        .set("Xms", "2G")
        .done()
    .with_arguments()
        .set(KEY_LAUNCHER_NAME, "MyCustomLauncher")
        .set("width", "1920")
        .set("height", "1080")
        .done()
    .run()
    .await?;
```

**Key Features:**
- JVM options customization (memory, GC, system properties)
- Game arguments customization (resolution, launcher name)
- Automatic file verification
- Parallel downloads with retry logic
- Asset, library, and native management

### `lighty_launcher::loaders` - Mod Loaders


Support for multiple Minecraft mod loaders:

```rust
use lighty_launcher::loaders::{Loader, VersionInfo};

// Available loaders
Loader::Vanilla       // Vanilla Minecraft
Loader::Fabric        // Fabric mod loader
Loader::Quilt         // Quilt mod loader
Loader::NeoForge      // NeoForge (modern Forge fork)
Loader::Forge         // Forge
Loader::LightyUpdater // Custom updater system
Loader::Optifine      // OptiFine (experimental)
```

**Loader Status:**

| Loader | Status | Example Version | Minecraft Version |
|--------|--------|-----------------|-------------------|
| Vanilla | ✅ Stable | - | 1.21.1 |
| Fabric | ✅ Stable | 0.17.2 | 1.21.8 |
| Quilt | ✅ Stable | 0.17.10 | 1.18.2 |
| NeoForge | ⚠️ Testing | 20.2.93 | 1.20.2 |
| Forge | ⚠️ Testing | - | - |
| LightyUpdater | ✅ Stable | - | Custom |
| OptiFine | 🧪 Experimental | - | - |

### `lighty_launcher::version` - Version Builders


Build game instances with different loaders:

```rust
use lighty_launcher::version::{VersionBuilder, LightyVersionBuilder};

// Standard Minecraft with loader
let mut version = VersionBuilder::new(
    "fabric-instance",
    Loader::Fabric,
    "0.17.2",       // Loader version
    "1.21.8",       // Minecraft version
    &launcher_dir
);

// LightyUpdater custom version
let mut version = LightyVersionBuilder::new(
    "custom-instance",
    "https://my-server.com/api",
    &launcher_dir
);
```

### `lighty_launcher::core` - Core Utilities


Low-level utilities for system operations:

```rust
use lighty_launcher::core::{hash, extract, download, system};

// SHA1 verification
core::verify_file_sha1(&path, expected_hash).await?;

// Archive extraction
core::extract::zip_extract(reader, output_dir, None).await?;

// System detection
let (os, arch) = core::system::get_os_arch();
```

## Examples


### Fabric with Events


```rust
use lighty_launcher::{
    auth::{OfflineAuth, Authenticator},
    event::{EventBus, Event, LaunchEvent},
    java::JavaDistribution,
    launch::Launch,
    loaders::Loader,
    version::VersionBuilder,
};

#[tokio::main]

async fn main() -> anyhow::Result<()> {
    let launcher_dir = ProjectDirs::from("com", "MyLauncher", "").unwrap();

    // Create event bus
    let event_bus = EventBus::new(1000);
    let mut receiver = event_bus.subscribe();

    // Spawn event listener
    tokio::spawn(async move {
        while let Ok(event) = receiver.next().await {
            match event {
                Event::Launch(LaunchEvent::InstallProgress { bytes }) => {
                    println!("Downloaded {} bytes", bytes);
                }
                Event::Launch(LaunchEvent::InstallCompleted { version, .. }) => {
                    println!("{} installation completed!", version);
                }
                _ => {}
            }
        }
    });

    // Authenticate with events
    let mut auth = OfflineAuth::new("Player");
    let profile = auth.authenticate(Some(&event_bus)).await?;

    // Launch with events
    let mut version = VersionBuilder::new(
        "fabric-1.21.8",
        Loader::Fabric,
        "0.17.2",
        "1.21.8",
        &launcher_dir
    );

    version.launch(&profile, JavaDistribution::Temurin)
        .with_event_bus(&event_bus)
        .run()
        .await?;

    Ok(())
}
```

### Microsoft Authentication


```rust
use lighty_launcher::auth::{MicrosoftAuth, Authenticator};

let mut auth = MicrosoftAuth::new();

// Interactive OAuth flow
let profile = auth.authenticate().await?;

println!("Logged in as: {}", profile.username);
println!("UUID: {}", profile.uuid);
```

### Custom Downloader Configuration


```rust
use lighty_launcher::launch::{init_downloader_config, DownloaderConfig};

// Configure before launching
init_downloader_config(DownloaderConfig {
    max_concurrent_downloads: 150,  // More parallel downloads
    max_retries: 10,                 // More retry attempts
    initial_delay_ms: 100,           // Longer initial delay
});

// Launches will use this configuration
version.launch(&profile, JavaDistribution::Temurin).run().await?;
```

## Cargo Features


Control which functionality is compiled:

```toml
# Minimal - Vanilla only

lighty-launcher = { version = "0.6", features = ["vanilla"] }

# With events

lighty-launcher = { version = "0.6", features = ["vanilla", "events"] }

# Multiple loaders

lighty-launcher = { version = "0.6", features = ["vanilla", "fabric", "quilt", "events"] }

# All loaders

lighty-launcher = { version = "0.6", features = ["all-loaders", "events"] }

# With Tauri integration

lighty-launcher = { version = "0.6", features = ["all-loaders", "events", "tauri-commands"] }
```

**Available Features:**
- `vanilla` - Vanilla Minecraft support (required base)
- `fabric` - Fabric loader
- `quilt` - Quilt loader
- `neoforge` - NeoForge loader
- `forge` - Forge loader
- `forge_legacy` - Legacy Forge (1.7.10 - 1.12.2)
- `lighty_updater` - Custom updater system
- `all-loaders` - All mod loaders
- `events` - Event system
- `tauri-commands` - Tauri desktop integration

## Running Examples


```bash
# Vanilla

cargo run --example vanilla --features vanilla,events

# Vanilla with events (detailed progress)

cargo run --example vanilla_with_events --features vanilla,events

# Fabric

cargo run --example fabric --features fabric

# Quilt

cargo run --example quilt --features quilt

# LightyUpdater

cargo run --example lighty_updater --features lighty_updater
```

## Architecture


```
lighty-launcher/
├── src/
│   └── lib.rs                    # Module organization and re-exports
│
├── crates/
│   ├── auth/                     # Authentication
│   │   ├── offline.rs            # Offline auth
│   │   ├── microsoft.rs          # Microsoft OAuth
│   │   ├── azuriom.rs            # Azuriom CMS
│   │   └── custom.rs             # Custom endpoints
│   │
│   ├── event/                    # Event system
│   │   ├── lib.rs                # EventBus, EventReceiver
│   │   ├── errors.rs             # Custom errors
│   │   └── module/               # Event definitions
│   │       ├── auth.rs           # AuthEvent
│   │       ├── java.rs           # JavaEvent
│   │       ├── launch.rs         # LaunchEvent
│   │       ├── loader.rs         # LoaderEvent
│   │       └── core.rs           # CoreEvent
│   │
│   ├── java/                     # Java runtime management
│   │   ├── distribution.rs       # Distribution providers
│   │   ├── jre_downloader.rs     # Download & install
│   │   └── runtime.rs            # Version detection
│   │
│   ├── launch/                   # Game launching
│   │   ├── arguments/            # Argument building
│   │   │   └── arguments.rs      # Arguments trait
│   │   ├── installer/            # Installation logic
│   │   │   ├── installer.rs      # Installer trait
│   │   │   ├── config.rs         # Downloader config
│   │   │   ├── assets.rs         # Asset management
│   │   │   ├── libraries.rs      # Library management
│   │   │   ├── natives.rs        # Native libraries
│   │   │   └── client.rs         # Client JAR
│   │   └── launch/               # Launch orchestration
│   │       ├── runner.rs         # Launch logic
│   │       ├── builder.rs        # LaunchBuilder
│   │       └── config.rs         # LaunchConfig
│   │
│   ├── loaders/                  # Mod loaders
│   │   ├── vanilla/              # Vanilla Minecraft
│   │   ├── fabric/               # Fabric
│   │   ├── quilt/                # Quilt
│   │   ├── neoforge/             # NeoForge
│   │   ├── forge/                # Forge
│   │   ├── lighty_updater/       # Custom updater
│   │   └── utils/                # Caching & utilities
│   │
│   ├── version/                  # Version builders
│   │   ├── version_builder.rs    # Standard builder
│   │   └── lighty_builder.rs     # LightyUpdater builder
│   │
│   └── core/                     # Core utilities
│       ├── system.rs             # OS/Arch detection
│       ├── hosts.rs              # HTTP client
│       ├── download.rs           # Download utilities
│       ├── extract.rs            # Archive extraction
│       └── hash.rs               # SHA1 verification
│
└── examples/                     # Usage examples
    ├── vanilla.rs
    ├── vanilla_with_events.rs
    ├── fabric.rs
    ├── quilt.rs
    ├── neoforge.rs
    └── lighty_updater.rs
```

## Performance


- **Async I/O**: All filesystem and network operations are async
- **Parallel Downloads**: Configurable concurrency (default: 50 concurrent)
- **Smart Caching**: Dual cache system with TTL
- **Event System**: Zero-cost when disabled via feature flags
- **Minimal Dependencies**: Only essential crates
- **Optimized Profiles**:
  - `dev`: Fast compilation with opt-level=2 for dependencies
  - `release`: LTO thin, optimized for performance
  - `release-small`: Size-optimized binary

## Platform Support


| Platform | Status | Architectures |
|----------|--------|---------------|
| Windows | ✅ Tested | x64, ARM64 |
| Linux | ✅ Tested | x64, ARM64 |
| macOS | ✅ Tested | x64 (Intel), ARM64 (Apple Silicon) |

## Requirements


- **Rust 1.75+**
- **Tokio** async runtime
- **Internet connection** for downloads

## Crate Ecosystem


LightyLauncher is composed of multiple focused crates:

- [`lighty-auth`]crates/auth - Authentication providers
- [`lighty-event`]crates/event - Event system
- [`lighty-java`]crates/java - Java runtime management
- [`lighty-launch`]crates/launch - Game launching
- [`lighty-loaders`]crates/loaders - Mod loader implementations
- [`lighty-version`]crates/version - Version builders
- [`lighty-core`]crates/core - Core utilities

Each crate can be used independently or together through the main `lighty-launcher` crate.

## License


This project is licensed under the **MIT License** - See [LICENSE](LICENSE) for details.

**Clean Room Implementation**: All components were implemented from scratch using only publicly documented APIs. No GPL-licensed code was used or referenced.

## Disclaimer


- **Minecraft** is a trademark of Mojang Studios
- This project is **not affiliated** with Mojang Studios or Microsoft
- For educational and personal use
- Please respect the [Minecraft EULA]https://www.minecraft.net/en-us/eula

## Links


- **Documentation**: [docs.rs/lighty-launcher]https://docs.rs/lighty-launcher
- **Crates.io**: [crates.io/crates/lighty-launcher]https://crates.io/crates/lighty-launcher
- **Repository**: [GitHub]https://github.com/Lighty-Launcher/LightyLauncherLib
- **Issues**: [GitHub Issues]https://github.com/Lighty-Launcher/LightyLauncherLib/issues

---

**Made by Hamadi**

*Built with Rust: Tokio, Reqwest, Serde, Thiserror, and more.*