#minecraft #minecraft-launcher #essential #oauth #package #minecraft-client

bin+lib myworld-essentials

一个为所有我的世界客户端启动器提供基本功能的包

4 个版本

0.2.11 2024 年 4 月 22 日
0.2.10 2024 年 4 月 20 日
0.2.8 2024 年 2 月 29 日
0.2.6 2024 年 1 月 31 日

#143身份验证

Download history 12/week @ 2024-04-27 1/week @ 2024-05-04 6/week @ 2024-05-18 2/week @ 2024-05-25 12/week @ 2024-07-06 92/week @ 2024-07-27

每月 92 次下载

自定义许可

45KB
778

我的世界-Essentials

提供我的世界客户端启动器基本功能的官方 Rust/cargo 包。

功能

  • 基本功能:为我的世界客户端启动器提供核心功能。
  • 简化:简化构建我的世界客户端启动器的过程。
  • 快速:在身份验证和启动方面提供卓越的性能。
  • 安全:通过禁止不安全代码来确保安全。
  • 适合初学者:提供全面的 文档 和示例/模板,可在 GitHub 上找到。

包版本

如果您想使用除 rust/cargo 之外的包,您可能想查看

安装

myworld-essentials 添加到您的项目中

cargo add minecraft-essentials

OR

将以下内容添加到您的 Cargo.toml

[dependencies]
minecraft-essentials = "0.2.9"

用法

身份验证

OAuth 自定义身份验证 | OAuth2.0

此示例演示了如何使用由 myworld-essentials 提供的 OAuth 身份验证方法,oauth 功能。

use minecraft_essentials::*;

async fn Oauth(client_id: &str, client_secret: &str, port: Option<u16>, bedrockrel: bool) {
// Initialize the OAuth authentication object
let auth = Oauth::new(client_id, port);

// Print the URL needed for authentication
println!("URL: {}", auth.url());

// Launch the authentication process
 let auth_info = auth.launch(bedrockrel, client_secret).await;

// Print the authentication information
println!("{:?}", auth_info)
}

fn main() {
    Oauth("CLientID", "ClientSecret", None, false);
}

设备代码自定义身份验证 | DeviceCode

[!WARNING] 这仍在进行中 所以它可能会改变.

此示例演示了如何使用由 myworld-essentials 提供的设备代码身份验证方法,devicecode 功能。

use minecraft_essentials::*;


async fn deviceCode(client_id: &str) {
  // Create a new device code instance 
  let code = DeviceCode::new(client_id).expect("Expected Code");

  // Print the device code information 
  println!("Stuff Here: {}", code.preinfo());

  // Launch the authentication process 
  let code_info = code.launch().await?;
}

fn main() {
    // Initialize Device Code authentication with your client ID 
    deviceCode("111231209837123098712");
}

实际的我的世界身份验证

[!CAUTION] 这目前在 0.2.12-14 的 路线图 中,目前不可用。

启动

自定义启动

use minecraft_essentials::Launch;
use std::path::Path;

let args = vec!["--uuid:LauncherUUID".to_string(), "--token:Beartoken".to_string()];
let jre_path = Path::new("/path/to/jre").to_path_buf();
let java_exe = "/your/java/path";

// Init the instance of launch
let launch = Launch::new(args, java_exe.to_string(), Some(jre_path.clone()), Some(false)).expect("Expected Launch");

// Grab the info to verify that your doing everything currect.
let launch_info = launch.info();
println!("Launching with: {:?}", launch_info);

let _ = launch.launch_jre();

贡献

有兴趣为此项目做出贡献?请查看 贡献

许可

此库采用 BSD 3.0 许可

致谢

  • trippleawap 提供了用于 Minecraft 实现的 Minecraft 认证示例。

依赖项

约2-15MB
约201K SLoC