Skip to content

Commit

Permalink
docs: reformat function comment
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Jun 12, 2024
1 parent 95feb75 commit bec8bcf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src-tauri/src/minecraft/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ impl MinecraftAccount {
}

/// Authenticate using an offline account
/// Requests the UUID of the username from Mojang's API. If the username is invalid, the UUID will be `-`.
/// Generates UUID from following format: OfflinePlayer:<username>
/// Java/Kotlin equivalent: UUID.nameUUIDFromBytes("OfflinePlayer:$name".toByteArray())
///
// Explanation: [nameUUIDFromBytes] uses MD5 to generate a UUID from the input bytes.
// The input bytes are the UTF-8 bytes of the string "OfflinePlayer:$name".
// The UUID generated is a version 3 UUID, which is based on the MD5 hash of the input bytes.
///
/// Returns a `MinecraftAccount::OfflineAccount` if successful
pub async fn auth_offline(username: String) -> Self {
// Generate UUID from following string: OfflinePlayer:<username>
// Java/Kotlin equivalent: UUID.nameUUIDFromBytes("OfflinePlayer:$name".toByteArray())
// Explanation: [nameUUIDFromBytes] uses MD5 to generate a UUID from the input bytes.
// The input bytes are the UTF-8 bytes of the string "OfflinePlayer:$name".
// The UUID generated is a version 3 UUID, which is based on the MD5 hash of the input bytes.

// Generate UUID from "OfflinePlayer:$name"
let name_str = format!("OfflinePlayer:{}", username);
let bytes = name_str.as_bytes();
Expand Down

0 comments on commit bec8bcf

Please sign in to comment.