-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Improve error/warning system; add com_mojang folder detection
- Loading branch information
1 parent
e8a7e3f
commit b8a2a6b
Showing
6 changed files
with
160 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use clap::{ArgMatches, Command}; | ||
use std::{env, path::PathBuf, process::ExitCode}; | ||
|
||
mod location { | ||
use crate::diagnostic; | ||
use std::{env, path::PathBuf}; | ||
|
||
fn android_termux() -> Option<PathBuf> { | ||
let path = PathBuf::from(env::var_os("HOME").expect("HOME environment variable not set")) | ||
.join("storage/shared/Android/data/com.mojang.minecraftpe/files/games/com.mojang"); | ||
if path.exists() { | ||
Some(path) | ||
} else { | ||
log::error!("{}", diagnostic::Notification::ComMojangNotFoundAndroid); | ||
None | ||
} | ||
} | ||
|
||
fn windows() -> Option<PathBuf> { | ||
let path = PathBuf::from( | ||
env::var_os("LOCALAPPDATA").expect("LOCALAPPDATA environment variable not set"), | ||
) | ||
.join("Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang"); | ||
if path.exists() { | ||
Some(path) | ||
} else { | ||
log::error!("{}", diagnostic::Notification::ComMojangWindows); | ||
None | ||
} | ||
} | ||
|
||
pub fn get() -> Option<PathBuf> { | ||
if cfg!(android) { | ||
android_termux() | ||
} else if cfg!(ios) { | ||
log::error!("iOS devices are not supported for syncing yet"); | ||
None | ||
} else if cfg!(windows) { | ||
windows() | ||
} else { | ||
log::error!("Your OS is not supported for syncing"); | ||
None | ||
} | ||
} | ||
} | ||
|
||
pub fn cmd() -> Command { | ||
Command::new("sync").about("Update the associated packs in the Minecraft directories") | ||
} | ||
|
||
pub fn run(matches: &ArgMatches) -> ExitCode { | ||
let com_mojang: PathBuf = match env::var_os("COM_MOJANG") { | ||
Some(var) => PathBuf::from(var), | ||
None => match location::get() { | ||
Some(loc) => loc, | ||
None => return ExitCode::FAILURE, | ||
}, | ||
}; | ||
todo!("find packs with same id as current project and update them") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# `com.mojang` folder not found on Android | ||
|
||
Make sure you | ||
|
||
- are using [Termux][] | ||
- have used the [`termux-setup-storage` command][termux-setup-storage] | ||
- have set the file storage location of Minecraft to "External" | ||
(Minecraft > Settings > Storage > File Storage Location) | ||
|
||
If the steps above do not resolve your issues, find the `com.mojang` folder on your system and set the | ||
environment variable `COM_MOJANG` to that path. | ||
|
||
[Termux]: https://termux.dev/en/ | ||
[termux-setup-storage]: https://wiki.termux.com/wiki/Termux-setup-storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters