Skip to content

Commit

Permalink
allow copying the server version (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
Commandcracker authored Dec 5, 2024
1 parent e26ffae commit 700a3fe
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions pumpkin/src/command/commands/cmd_pumpkin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use async_trait::async_trait;
use pumpkin_core::text::click::ClickEvent;
use pumpkin_core::text::hover::HoverEvent;
use pumpkin_core::text::{color::NamedColor, TextComponent};
use pumpkin_protocol::CURRENT_MC_PROTOCOL;
use std::borrow::Cow;

use crate::{
command::{
Expand Down Expand Up @@ -29,8 +32,34 @@ impl CommandExecutor for PumpkinExecutor {
) -> Result<(), CommandError> {
sender
.send_message(
TextComponent::text(&format!("Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION}), {CARGO_PKG_DESCRIPTION} (Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL})", ))
.color_named(NamedColor::Green),
TextComponent::text(&format!("Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION})"))
.hover_event(HoverEvent::ShowText(Cow::from("Click to Copy Version")))
.click_event(ClickEvent::CopyToClipboard(Cow::from(format!(
"Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION})"
))))
.color_named(NamedColor::Green)
.add_child(
TextComponent::text(&format!(", {CARGO_PKG_DESCRIPTION}"))
.click_event(ClickEvent::CopyToClipboard(Cow::from(
CARGO_PKG_DESCRIPTION,
)))
.hover_event(HoverEvent::ShowText(Cow::from(
"Click to Copy Description",
)))
.color_named(NamedColor::White),
)
.add_child(
TextComponent::text(&format!(
" (Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL})"
))
.click_event(ClickEvent::CopyToClipboard(Cow::from(format!(
"(Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL})"
))))
.hover_event(HoverEvent::ShowText(Cow::from(
"Click to Copy Minecraft Version",
)))
.color_named(NamedColor::Gold),
),
)
.await;
Ok(())
Expand Down

0 comments on commit 700a3fe

Please sign in to comment.