Skip to content

Commit ec781dc

Browse files
authored
chore: add warning when using Java 25 on macOS 10.x (#1303)
* chore: add warning when using Java 25 on macOS 10.x * fix(java): only offer the java 21 downgrade when the game allows it
1 parent a0affb7 commit ec781dc

20 files changed

Lines changed: 192 additions & 43 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
# Warn before launching with Java 22 or newer on macOS 10.x

‎packages/oneclient_app/lang/en_us.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,11 @@
19061906
"oneclient.install.optional_available.title": "Optional mods available",
19071907
"oneclient.install.required_by": "%s (required by %s)",
19081908
"oneclient.install.view_changes": "View changes",
1909+
"oneclient.java.legacy_macos.body": "Java %s and newer need macOS 11 or newer for their graphics libraries, so the game will likely crash on startup. This version of the game needs one of those, so no older Java can stand in.",
1910+
"oneclient.java.legacy_macos.body_downgrade": "Java %s and newer need macOS 11 or newer for their graphics libraries, so the game will likely crash on startup. Java %s works on older macOS. Use it for this launch? To stop seeing this, pick it in this cluster's Java settings.",
1911+
"oneclient.java.legacy_macos.downgrade": "Use Java %s",
1912+
"oneclient.java.legacy_macos.keep": "Launch anyway",
1913+
"oneclient.java.legacy_macos.title": "Java may crash on this macOS version",
19091914
"oneclient.layout.back_to": "Back to %s",
19101915
"oneclient.layout.cluster.share": "Share",
19111916
"oneclient.layout.cluster.stop_game": "Stop game",

‎packages/oneclient_app/src/notifications.rs‎

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use oneclient_core::UnpublishedFile;
88
use oneclient_core::clusters::{FlaggedModpack, FlaggedPackMod};
99
use oneclient_db::models::{ClusterId, OptionalModStatus};
1010
use oneclient_events::{
11-
Answer, Choice, Event, GroupedProgressEvent, Level, Notification, ProgressEvent, TaskCategory,
12-
TaskPhase,
11+
Answer, Choice, Event, GroupedProgressEvent, Level, Notification, ProgressEvent, PromptRequest,
12+
TaskCategory, TaskPhase,
1313
};
1414
use tokio::sync::oneshot;
1515
use uuid::Uuid;
@@ -291,6 +291,45 @@ pub struct PendingPrompt {
291291
pub reply_tx: Option<oneshot::Sender<Option<Answer>>>,
292292
}
293293

294+
/// The Java crate has no i18n, so its legacy macOS warning is recognised by
295+
/// choice id and rewritten here
296+
fn localize_legacy_macos_prompt(request: &mut PromptRequest) {
297+
use oneclient_java::{
298+
LEGACY_MACOS_CHOICE_DOWNGRADE, LEGACY_MACOS_CHOICE_KEEP, LEGACY_MACOS_MAX_MAJOR,
299+
};
300+
301+
if !request
302+
.choices
303+
.iter()
304+
.any(|c| c.id == LEGACY_MACOS_CHOICE_KEEP)
305+
{
306+
return;
307+
}
308+
let newest = LEGACY_MACOS_MAX_MAJOR;
309+
let can_downgrade = request
310+
.choices
311+
.iter()
312+
.any(|c| c.id == LEGACY_MACOS_CHOICE_DOWNGRADE);
313+
314+
request.title = t("oneclient.java.legacy_macos.title").to_string();
315+
request.body = if can_downgrade {
316+
tf(
317+
"oneclient.java.legacy_macos.body_downgrade",
318+
&[&(newest + 1), &newest],
319+
)
320+
} else {
321+
tf("oneclient.java.legacy_macos.body", &[&(newest + 1)])
322+
};
323+
for choice in &mut request.choices {
324+
if choice.id == LEGACY_MACOS_CHOICE_DOWNGRADE {
325+
choice.label = tf("oneclient.java.legacy_macos.downgrade", &[&newest]);
326+
} else if choice.id == LEGACY_MACOS_CHOICE_KEEP {
327+
choice.label = t("oneclient.java.legacy_macos.keep").to_string();
328+
}
329+
}
330+
request.dismiss = Some(t("oneclient.common.cancel").to_string());
331+
}
332+
294333
#[derive(Clone, Debug)]
295334
pub struct PendingPromptView {
296335
pub title: String,
@@ -749,7 +788,8 @@ impl NotificationState {
749788
}
750789
// Handled directly by the runtime loop they never become inbox entries
751790
Event::Signal(_) | Event::Game(_) => {}
752-
Event::Notification(Notification::Prompt(request)) => {
791+
Event::Notification(Notification::Prompt(mut request)) => {
792+
localize_legacy_macos_prompt(&mut request);
753793
let pending_prompt = Some(PendingPrompt {
754794
title: request.title,
755795
question: request.body,

‎packages/oneclient_core/examples/import_launcher.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4747
);
4848

4949
let choices = oneclient_core::ImportChoices::default();
50-
let report = match oneclient_core::import_external_instance(
51-
&state, instance, &choices, None,
52-
)
53-
.await
54-
{
50+
let report =
51+
match oneclient_core::import_external_instance(&state, instance, &choices, None)
52+
.await
53+
{
5554
Ok(report) => report,
5655
Err(err) => {
5756
println!(" import failed: {err}");

‎packages/oneclient_core/src/bisect/mod.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,10 @@ pub async fn start_bisect(
515515
)
516516
.await
517517
.unwrap_or_else(|_| {
518-
tracing::warn!(cluster_id, "reading the listed mod dependencies took too long");
518+
tracing::warn!(
519+
cluster_id,
520+
"reading the listed mod dependencies took too long"
521+
);
519522
Vec::new()
520523
});
521524
if !listed.is_empty()

‎packages/oneclient_core/src/clusters/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ pub use modpack::{
2121
create_modpack_instance, install_modpack_instance, prepare_modpack, repair_modpack_cluster,
2222
update_modpack_cluster,
2323
};
24+
pub(crate) use modpack_import::flag_pack_mods;
2425
pub use modpack_import::{
2526
ExistingPack, FlaggedPackMod, ImportedModpack, LoaderPlan, PreparedImport,
2627
has_imported_modpacks, import_modpack_into_cluster, list_imported_modpacks,
2728
modpack_file_sources, prepare_modpack_import, release_imported_modpacks,
2829
remove_imported_modpack,
2930
};
30-
pub(crate) use modpack_import::flag_pack_mods;
3131
pub(crate) use prepare::cluster_version_info;
3232
pub use prepare::{
3333
estimate_cluster_download, prepare_cluster, prepare_cluster_locked, required_java_major,

‎packages/oneclient_core/src/clusters/modpack.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use oneclient_cluster::naming::{is_allowed_name_char, validate_modpack_instance_
66
use oneclient_cluster::{Cluster, ClusterKind, ClusterUpdate, CreateClusterOptions, DirTarget};
77
use oneclient_common::domain::{GameLoader, ProviderId};
88
use oneclient_common::patch::Patch;
9-
use oneclient_content::{ContentCtx, ContentError};
109
use oneclient_content::modpacks::{self, ModpackInstallReport, ModpackManifest, ModpackRelease};
1110
use oneclient_content::packages::store::artifact_absolute_path;
1211
use oneclient_content::packages::{
1312
PackageStore, ProjectDetail, ResolvedAlternative, fetch_modpack_explanation, load_bad_modpacks,
1413
};
14+
use oneclient_content::{ContentCtx, ContentError};
1515
use oneclient_db::dao::artifact::get_artifact_by_hash;
1616
use oneclient_db::dao::cluster_bundle as bundle_dao;
1717
use oneclient_db::models::OverrideType;

‎packages/oneclient_core/src/clusters/modpack_import.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ impl PreparedImport {
101101

102102
#[must_use]
103103
pub fn target_bundle_name(&self, existing: ExistingPack) -> &str {
104-
if existing == ExistingPack::KeepBoth && self.previous.is_some() && self.existing().is_some()
104+
if existing == ExistingPack::KeepBoth
105+
&& self.previous.is_some()
106+
&& self.existing().is_some()
105107
{
106108
&self.separate_bundle_name
107109
} else {
@@ -280,7 +282,10 @@ pub async fn import_modpack_into_cluster(
280282
match remove_pack(state, &cluster, bundle_name, &content).await {
281283
Ok(failed) if failed.is_empty() => {}
282284
Ok(failed) => {
283-
tracing::warn!(failed = failed.len(), "could not undo every file of a failed import");
285+
tracing::warn!(
286+
failed = failed.len(),
287+
"could not undo every file of a failed import"
288+
);
284289
}
285290
Err(undo) => {
286291
tracing::warn!(error = %undo, "could not undo a failed import");

‎packages/oneclient_core/src/clusters/reset.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ pub async fn reset_cluster(
128128
.create_and_assign_profile(&global, cluster_id, &cluster.folder_name)
129129
.await?;
130130

131-
let loader_version = match (&modpack, cluster.kind == ClusterKind::OneClient && !cluster.user_created) {
131+
let loader_version = match (
132+
&modpack,
133+
cluster.kind == ClusterKind::OneClient && !cluster.user_created,
134+
) {
132135
(Some(manifest), _) => Some(manifest.loader_version.clone()),
133136
(None, true) => Some(None),
134137
(None, false) => None,

‎packages/oneclient_core/src/clusters/share.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ async fn import_playtime(
490490
) -> Result<(), sqlx::Error> {
491491
let mut tx = db.begin().await?;
492492
if playtime.played_secs > 0 {
493-
let secs = i64::try_from(playtime.played_secs.min(MAX_IMPORTED_PLAYED_SECS))
494-
.unwrap_or(i64::MAX);
493+
let secs =
494+
i64::try_from(playtime.played_secs.min(MAX_IMPORTED_PLAYED_SECS)).unwrap_or(i64::MAX);
495495
cluster_dao::add_playtime(&mut *tx, cluster_id, secs).await?;
496496
}
497497
let last_played = playtime

0 commit comments

Comments
 (0)