feat: add info event listener and payload for enhanced event handling

- Implemented `info_listener` in `events.js` to listen for 'info' events and handle payloads.
- Added `emit_info` function in `emit.rs` to emit 'info' events with a message payload.
- Defined `InfoPayload` struct in `mod.rs` to structure the data for 'info' events.
- Integrated `emit_info` calls in the Minecraft launch logic to provide feedback on account types.
- Introduced a new offline icon in SVG format and removed outdated pirate icons from assets.
- Updated asset index to include the new offline icon and removed references to deleted icons.
This commit is contained in:
2026-01-27 20:41:55 +03:00
parent 45519f5dbb
commit 572800d9ca
10 changed files with 293 additions and 194 deletions

View File

@@ -5,7 +5,7 @@ use crate::event::{
};
#[cfg(feature = "tauri")]
use crate::event::{
LoadingPayload, ProcessPayload, ProfilePayload, WarningPayload,
LoadingPayload, ProcessPayload, ProfilePayload, WarningPayload, InfoPayload
};
use futures::prelude::*;
#[cfg(feature = "tauri")]
@@ -219,6 +219,26 @@ pub async fn emit_warning(message: &str) -> crate::Result<()> {
Ok(())
}
// This code is modified by AstralRinth
// emit_info(message)
pub async fn emit_info(message: &str) -> crate::Result<()> {
#[cfg(feature = "tauri")]
{
let event_state = crate::EventState::get()?;
event_state
.app
.emit(
"info",
InfoPayload {
message: message.to_string(),
},
)
.map_err(EventError::from)?;
}
tracing::info!("{}", message);
Ok(())
}
// emit_command(CommandPayload::Something { something })
// ie: installing a pack, opening an .mrpack, etc
// Generally used for url deep links and file opens that we want to handle in the frontend

View File

@@ -200,6 +200,13 @@ pub struct WarningPayload {
pub message: String,
}
// This code is modified by AstralRinth
#[derive(Serialize, Clone)]
#[cfg(feature = "tauri")]
pub struct InfoPayload {
pub message: String,
}
#[derive(Serialize, Clone)]
#[serde(tag = "event")]
pub enum CommandPayload {

View File

@@ -1,6 +1,6 @@
//! Logic for launching Minecraft
use crate::data::ModLoader;
use crate::event::emit::{emit_loading, init_or_edit_loading};
use crate::event::emit::{emit_loading, emit_info, init_or_edit_loading};
use crate::event::{LoadingBarId, LoadingBarType};
use crate::launcher::download::download_log_config;
use crate::launcher::io::IOError;
@@ -666,31 +666,35 @@ pub async fn launch_minecraft(
command.arg("--add-opens=jdk.internal/jdk.internal.misc=ALL-UNNAMED");
}
// [AR] Patch
// This code is modified by AstralRinth
if credentials.account_type == AccountType::Pirate.as_lowercase_str() {
if version_jar == "1.16.4" || version_jar == "1.16.5" {
let invalid_url = "https://invalid.invalid";
tracing::info!(
"[AR] • The launcher detected the launch of {} on the offline account. Applying offline multiplayer fixes.",
let _ = emit_info(&format!(
"[AR] • Detected launch of {} on the offline account. Applying 1.16.4/5 multiplayer fixes.",
version_jar
);
)
).await;
command.arg("-Dminecraft.api.env=custom");
command.arg(format!("-Dminecraft.api.auth.host={}", invalid_url));
command
.arg(format!("-Dminecraft.api.account.host={}", invalid_url));
command
.arg(format!("-Dminecraft.api.session.host={}", invalid_url));
command
.arg(format!("-Dminecraft.api.services.host={}", invalid_url));
command.arg(format!("-Dminecraft.api.account.host={}", invalid_url));
command.arg(format!("-Dminecraft.api.session.host={}", invalid_url));
command.arg(format!("-Dminecraft.api.services.host={}", invalid_url));
}
} else if credentials.account_type == AccountType::ElyBy.as_lowercase_str()
{
tracing::info!(
"[AR] • The launcher detected the launch of {} on the Ely.by account. Applying Ely.by Java Injector.",
let _ = emit_info(&format!(
"[AR] • Detected launch of {} on the Ely.by account. Loading Ely.by AuthLib Injector...",
version_jar
);
)
).await;
let path_buf = utils::get_or_download_elyby_injector().await?;
let path = path_buf.to_str().unwrap();
let _ = emit_info(&format!(
"[AR] • Launching minecraft instance with {}",
path
)
).await;
command.arg(format!("-javaagent:{}=ely.by", path));
}