aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-12-06 23:23:18 -0600
committermat <git@matdoes.dev>2023-12-06 23:23:18 -0600
commit98f2c54c26f2559b4743fa4d5174c4d461bab9b5 (patch)
tree606577e9643995575256d64d12f0371dbb4c89f3 /azalea-client/src
parent3f341aa11452b4dfe0b61af23efe9742a4d3f277 (diff)
downloadazalea-drasl-98f2c54c26f2559b4743fa4d5174c4d461bab9b5.tar.xz
use minecraft_folder_path
Diffstat (limited to 'azalea-client/src')
-rwxr-xr-xazalea-client/src/account.rs5
-rwxr-xr-xazalea-client/src/get_mc_dir.rs61
-rw-r--r--azalea-client/src/lib.rs1
3 files changed, 2 insertions, 65 deletions
diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs
index e43d57e7..741a07d4 100755
--- a/azalea-client/src/account.rs
+++ b/azalea-client/src/account.rs
@@ -2,7 +2,6 @@
use std::sync::Arc;
-use crate::get_mc_dir;
use azalea_auth::certs::{Certificates, FetchCertificatesError};
use azalea_auth::AccessTokenResponse;
use bevy_ecs::component::Component;
@@ -91,10 +90,10 @@ impl Account {
/// a key for the cache, but it's recommended to use the real email to
/// avoid confusion.
pub async fn microsoft(email: &str) -> Result<Self, azalea_auth::AuthError> {
- let minecraft_dir = get_mc_dir::minecraft_dir().unwrap_or_else(|| {
+ let minecraft_dir = minecraft_folder_path::minecraft_dir().unwrap_or_else(|| {
panic!(
"No {} environment variable found",
- get_mc_dir::home_env_var()
+ minecraft_folder_path::home_env_var()
)
});
let auth_result = azalea_auth::auth(
diff --git a/azalea-client/src/get_mc_dir.rs b/azalea-client/src/get_mc_dir.rs
deleted file mode 100755
index df2a81aa..00000000
--- a/azalea-client/src/get_mc_dir.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-//! Find out where the user's .minecraft directory is.
-//!
-//! Used for the auth cache.
-
-use std::path::PathBuf;
-
-/// Return the location of the user's .minecraft directory.
-///
-/// Windows: `%appdata%\.minecraft`\
-/// Mac: `$HOME/Library/Application Support/minecraft`\
-/// Linux: `$HOME/.minecraft`
-///
-/// If the environment variable is not set, this will return `None`.
-pub fn minecraft_dir() -> Option<PathBuf> {
- let env_var = home_env_var();
- let home = std::env::var(env_var).ok()?;
- let path = PathBuf::from(home).join(minecraft_dir_relative());
- Some(path)
-}
-
-/// Return the name of the environment variable that's used for the home folder
-/// on the user's operating system.
-pub fn home_env_var() -> &'static str {
- #[cfg(target_os = "windows")]
- {
- "APPDATA"
- }
- #[cfg(target_os = "macos")]
- {
- "HOME"
- }
- #[cfg(target_os = "linux")]
- {
- "HOME"
- }
- #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
- {
- "HOME"
- }
-}
-
-/// Return the path relative to the home folder where we expect to find the
-/// .minecraft directory.
-pub fn minecraft_dir_relative() -> &'static str {
- #[cfg(target_os = "windows")]
- {
- ".minecraft"
- }
- #[cfg(target_os = "macos")]
- {
- "Library/Application Support/minecraft"
- }
- #[cfg(target_os = "linux")]
- {
- ".minecraft"
- }
- #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
- {
- ".minecraft"
- }
-}
diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs
index 068b3ccd..1eaf4605 100644
--- a/azalea-client/src/lib.rs
+++ b/azalea-client/src/lib.rs
@@ -16,7 +16,6 @@ mod client;
pub mod disconnect;
mod entity_query;
mod events;
-mod get_mc_dir;
pub mod interact;
pub mod inventory;
mod local_player;