Skip to content

Commit

Permalink
Add check for old MultiMC versions (build < 900)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scotsguy committed Feb 5, 2020
1 parent 6135902 commit bc76530
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use regex::Regex;

pub type Check = fn(&str) -> Option<(&str, String)>;

pub static PARSERS: [Check; 10] = [
pub static PARSERS: [Check; 11] = [
multimc_in_program_files,
server_java,
buildsystem_forge,
Expand All @@ -16,6 +16,7 @@ pub static PARSERS: [Check; 10] = [
id_range_exceeded,
out_of_memory_error,
java_architecture,
old_multimc_version,
ram_amount,
];

Expand Down Expand Up @@ -56,12 +57,15 @@ fn buildsystem_forge(log: &str) -> Option<(&str, String)> {
// When adding new versions, change the regex too
};

Some(("‼", format!(
"You're trying to use Forge for Minecraft version {}. \
Some((
"‼",
format!(
"You're trying to use Forge for Minecraft version {}. \
This is not supported by MultiMC. For more information, please see \
[this link.](https://multimc.org/posts/forge-114.html)",
mc_version)
))
mc_version
),
))
} else {
None
}
Expand Down Expand Up @@ -129,6 +133,32 @@ fn java_architecture(log: &str) -> Option<(&str, String)> {
}
}

fn old_multimc_version(log: &str) -> Option<(&str, String)> {
lazy_static! {
static ref RE: Regex =
Regex::new(r"MultiMC version: (?P<major_ver>0\.[0-9]+\.[0-9]+-(?P<build>[0-9]+))\n")
.unwrap();
}
if let Some(capture) = RE.captures(log) {
match capture.name("build")?.as_str().parse::<u32>() {
Ok(o) => {
if o < 900 {
Some(("❗", format!("You seem to be using an old build of MultiMC ({}). \
Please update to a more recent version.", capture.name("major_ver")?.as_str())))
} else {
None
}
},
Err(_) => {
Some(("❗", format!("You seem to be using an unofficial version of MultiMC ({}). \
Please only use MultiMC downloaded from [multimc.org](https://multimc.org/#Download).", capture.name("major_ver")?.as_str())))
}
}
} else {
None
}
}

fn ram_amount(log: &str) -> Option<(&str, String)> {
lazy_static! {
static ref RE: Regex = Regex::new(r"-Xmx(?P<amount>[0-9]+)m[,\]]").unwrap();
Expand Down

0 comments on commit bc76530

Please sign in to comment.