diff --git a/pumpkin-util/src/text/mod.rs b/pumpkin-util/src/text/mod.rs index 0d95d7970..9e6987f99 100644 --- a/pumpkin-util/src/text/mod.rs +++ b/pumpkin-util/src/text/mod.rs @@ -102,6 +102,10 @@ impl TextComponentBase { /// A formatted string ready for console output. #[must_use] pub fn to_pretty_console(self) -> String { + fn osc8_link(url: &str, text: &str) -> String { + format!("\x1b]8;;{url}\x1b\\{text}\x1b]8;;\x1b\\") + } + let mut text = match *self.content { TextContent::Text { text } => text.into_owned(), TextContent::Translate { @@ -133,6 +137,13 @@ impl TextComponentBase { if style.strikethrough.is_some() { text = text.strikethrough().to_string(); } + if let Some(ClickEvent::OpenUrl { url }) = style.click_event.as_ref() { + text = osc8_link(url, &text); + } + if let Some(ClickEvent::OpenFile { path }) = style.click_event.as_ref() { + text = osc8_link(&format!("file://{path}"), &text); + } + for child in self.extra { text += &*child.to_pretty_console(); } diff --git a/pumpkin/src/command/commands/pumpkin.rs b/pumpkin/src/command/commands/pumpkin.rs index acfadff0d..ab6a1a014 100644 --- a/pumpkin/src/command/commands/pumpkin.rs +++ b/pumpkin/src/command/commands/pumpkin.rs @@ -203,7 +203,7 @@ impl CommandExecutor for Executor { .add_child( TextComponent::text("[Donate]") .click_event(ClickEvent::OpenUrl { - url: Cow::from("https://github.com/sponsors/Pumpkin-MC"), + url: Cow::from("https://pumpkinmc.org/donate/"), }) .hover_event(HoverEvent::show_text(TextComponent::text( "Click to open Donate",