Skip to content

Commit cedc33b

Browse files
committed
chore: Fix weird java prefix + add force reinstall button
1 parent 74a0e27 commit cedc33b

File tree

7 files changed

+65
-14
lines changed

7 files changed

+65
-14
lines changed

apps/desktop/src/api/commands/cluster.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,19 @@ pub async fn get_worlds(uuid: Uuid) -> Result<Vec<String>, String> {
199199

200200
#[specta::specta]
201201
#[tauri::command]
202-
pub async fn get_optimal_java_version(cluster_id: Uuid) -> Result<JavaVersion, String> {
203-
let cluster_path = cluster::get_by_uuid(cluster_id).await?.ok_or("Cluster not found")?.cluster_path();
202+
pub async fn get_optimal_java_version(uuid: Uuid) -> Result<JavaVersion, String> {
203+
let cluster_path = cluster::get_by_uuid(uuid).await?.ok_or("Cluster not found")?.cluster_path();
204204
Ok(cluster::get_optimal_java_version(&cluster_path).await?.ok_or("No Java version found")?)
205+
}
206+
207+
#[specta::specta]
208+
#[tauri::command]
209+
pub async fn repair_cluster(uuid: Uuid) -> Result<(), String> {
210+
let cluster = cluster::get_by_uuid(uuid)
211+
.await?
212+
.ok_or("cluster not found")?;
213+
214+
cluster::repair_cluster(&cluster.cluster_path()).await?;
215+
216+
Ok(())
205217
}

apps/desktop/src/api/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use interpulse::api::minecraft::Version;
22
use onelauncher::data::Settings;
3-
use onelauncher::game::metadata;
43
use onelauncher::settings;
54
use tauri::{AppHandle, Manager};
65

@@ -44,6 +43,7 @@ macro_rules! collect_commands {
4443
get_screenshots,
4544
get_worlds,
4645
get_optimal_java_version,
46+
repair_cluster,
4747
// Processor
4848
get_running_clusters,
4949
get_processes_by_path,

apps/frontend/src/ui/pages/cluster/ClusterOverview.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Cluster } from '@onelauncher/client/bindings';
22
import { useNavigate } from '@solidjs/router';
33
import * as dialog from '@tauri-apps/plugin-dialog';
44
import { open } from '@tauri-apps/plugin-shell';
5-
import { Edit02Icon, FolderIcon, ImagePlusIcon, LinkExternal01Icon, PlayIcon, Save01Icon, Share07Icon, Trash01Icon } from '@untitled-theme/icons-solid';
5+
import { Edit02Icon, FolderIcon, ImagePlusIcon, LinkExternal01Icon, PlayIcon, Save01Icon, Share07Icon, Tool02Icon, Trash01Icon } from '@untitled-theme/icons-solid';
66
import { bridge } from '~imports';
77
import TextField from '~ui/components/base/TextField';
88
import Modal, { createModal, type ModalProps } from '~ui/components/overlay/Modal';
@@ -63,6 +63,10 @@ function ClusterOverview() {
6363
navigate('/');
6464
}
6565

66+
async function repairCluster() {
67+
await bridge.commands.repairCluster(cluster()!.uuid);
68+
}
69+
6670
function madeChanges() {
6771
const name = untrack(() => newName());
6872
const cover = untrack(() => newCover());
@@ -195,6 +199,19 @@ function ClusterOverview() {
195199
icon={<Trash01Icon />}
196200
title="Delete Cluster"
197201
/>
202+
<SettingsRow
203+
children={(
204+
<Button
205+
buttonStyle="secondary"
206+
children="Repair"
207+
iconLeft={<Tool02Icon />}
208+
onClick={repairCluster}
209+
/>
210+
)}
211+
description="Verifies whether all assets, libraries and natives were properly installed."
212+
icon={<Tool02Icon />}
213+
title="Verify Cluster"
214+
/>
198215
</ScrollableContainer>
199216
</Sidebar.Page>
200217
);
@@ -260,7 +277,7 @@ function Banner(props: BannerProps) {
260277
if (selected === null)
261278
return;
262279

263-
props.setNewCover(selected.path);
280+
props.setNewCover(selected);
264281
}
265282

266283
function updateName(name: string) {
@@ -338,7 +355,8 @@ function Banner(props: BannerProps) {
338355
<Button
339356
buttonStyle="iconSecondary"
340357
children={<Share07Icon />}
341-
disabled={props.editMode()}
358+
// disabled={props.editMode()}
359+
disabled={true}
342360
/>
343361

344362
<Button

apps/frontend/src/ui/pages/settings/game/SettingsMinecraft.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ function ClusterJavaVersionModal(props: ModalProps & {
470470
}) {
471471
const [_, modalProps] = splitProps(props, ['javaVersion', 'javaVersions']);
472472

473-
const javaVersions = createMemo(() => Object.entries(props.javaVersions).sort((a, b) => Number.parseFloat(b[1].version) - Number.parseFloat(a[1].version)));
473+
const javaVersions = createMemo(() => Object.entries(props.javaVersions.get()).sort((a, b) => Number.parseFloat(b[1].version) - Number.parseFloat(a[1].version)));
474474
const [selected, setSelected] = createSignal<number>(0);
475475

476476
onMount(async () => {
@@ -490,7 +490,7 @@ function ClusterJavaVersionModal(props: ModalProps & {
490490
props.javaVersion.set(pkg);
491491
props.javaVersions.set({
492492
...props.javaVersions?.get(),
493-
[`JAVA_${version}`]: pkg,
493+
[version]: pkg,
494494
});
495495
};
496496

@@ -522,6 +522,7 @@ function ClusterJavaVersionModal(props: ModalProps & {
522522
<Dropdown.Row>
523523
<span class="capitalize">
524524
Java
525+
{' '}
525526
{major}
526527
</span>
527528
</Dropdown.Row>
@@ -542,7 +543,7 @@ function GlobalJavaVersionModal(props: ModalProps & {
542543
const setPackage = (pkg: JavaVersion, version: string) => {
543544
props.javaVersions?.set({
544545
...props.javaVersions?.get(),
545-
[`JAVA_${version}`]: pkg,
546+
[version]: pkg,
546547
});
547548
};
548549

@@ -561,6 +562,7 @@ function GlobalJavaVersionModal(props: ModalProps & {
561562
<>
562563
<span class="capitalize">
563564
Java
565+
{' '}
564566
{major}
565567
</span>
566568
<TextField

packages/client/src/bindings.ts

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/api/cluster/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::proxy::send::send_cluster;
99
use crate::prelude::{ClusterPath, JavaVersion, PackagePath};
1010
use crate::proxy::ClusterPayloadType;
1111
pub use crate::store::{Cluster, JavaOptions, State};
12-
use crate::store::{MinecraftCredentials, ProcessorChild};
12+
use crate::store::{ClusterStage, MinecraftCredentials, ProcessorChild};
1313

1414
use onelauncher_utils::io::{self, IOError};
1515

@@ -420,6 +420,15 @@ pub async fn update_playtime(path: &ClusterPath) -> crate::Result<()> {
420420
Ok(())
421421
}
422422

423+
/// This forces the cluster to be verified (and possibly reinstalled).
424+
pub async fn repair_cluster(path: &ClusterPath) -> crate::Result<()> {
425+
let cluster = get(path)
426+
.await?
427+
.ok_or_else(|| anyhow::anyhow!("failed to repair cluster at path {}", path))?;
428+
429+
crate::game::install_minecraft(&cluster, None, true).await
430+
}
431+
423432
/// Sanitize a user-inputted [`Cluster`] name.
424433
#[must_use]
425434
pub fn sanitize_cluster_name(input: &str) -> String {

packages/core/src/game/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub async fn install_minecraft(
124124
let mut settings = state.settings.write().await;
125125
settings
126126
.java_versions
127-
.insert(format!("JAVA_{key}"), java_version.clone());
127+
.insert(key.to_string(), java_version.clone());
128128
}
129129
State::sync().await?;
130130
}
@@ -535,7 +535,7 @@ pub async fn java_version_from_cluster(
535535
let state = State::get().await?;
536536
let settings = state.settings.read().await;
537537

538-
if let Some(j) = settings.java_versions.get(&format!("JAVA_{key}")) {
538+
if let Some(j) = settings.java_versions.get(&key.to_string()) {
539539
return Ok(Some(j.clone()));
540540
}
541541

0 commit comments

Comments
 (0)