From 60c633293671df054b6bd052dba59edcc8fdde07 Mon Sep 17 00:00:00 2001 From: Greened <108997309+GreenedDev@users.noreply.github.com> Date: Thu, 12 Feb 2026 04:22:51 +0400 Subject: [PATCH] Make pumpkin console colorful (#1531) * feat: make pumpkin colorful * chore: use .to_string() instead of format!() * chore: no from_legacy_string * chore: make clippy happy * chore: move some startup logs to a separate function --- pumpkin/src/main.rs | 84 +++++++++++++++++++++++++++++++++------ pumpkin/src/net/query.rs | 14 +++++-- pumpkin/src/server/mod.rs | 8 +++- 3 files changed, 89 insertions(+), 17 deletions(-) diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index ebdcfafa4..348c4297c 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -67,7 +67,22 @@ async fn main() { // We need to abide by the panic rules here. std::process::exit(1); })); - log::info!("Starting Pumpkin {CARGO_PKG_VERSION} Minecraft (Protocol {CURRENT_MC_PROTOCOL})",); + log::info!( + "{}", + TextComponent::text(format!( + "Starting {} {} Minecraft (Protocol {})", + TextComponent::text("Pumpkin") + .color_named(NamedColor::Gold) + .to_pretty_console(), + TextComponent::text(CARGO_PKG_VERSION.to_string()) + .color_named(NamedColor::Green) + .to_pretty_console(), + TextComponent::text(CURRENT_MC_PROTOCOL.to_string()) + .color_named(NamedColor::DarkBlue) + .to_pretty_console() + )) + .to_pretty_console(), + ); log::debug!( "Build info: FAMILY: \"{}\", OS: \"{}\", ARCH: \"{}\", BUILD: \"{}\"", @@ -80,10 +95,7 @@ async fn main() { "Release" } ); - - log::warn!("Pumpkin is currently under heavy development!"); - log::info!("Report issues on https://github.com/Pumpkin-MC/Pumpkin/issues"); - log::info!("Join our Discord for community support: https://discord.gg/pumpkinmc"); + print_support_links_and_warning(); tokio::spawn(async { setup_sighandler() @@ -94,14 +106,27 @@ async fn main() { let pumpkin_server = PumpkinServer::new(basic_config, advanced_config, vanilla_data).await; pumpkin_server.init_plugins().await; - log::info!("Started server; took {}ms", time.elapsed().as_millis()); + log::info!( + "Started server; took {}", + TextComponent::text(format!("{}ms", time.elapsed().as_millis())) + .color_named(NamedColor::Gold) + .to_pretty_console() + ); let basic_config = &pumpkin_server.server.basic_config; log::info!( "Server is now running. Connect using port: {}{}{}", if basic_config.java_edition { - format!("Java Edition: {}", basic_config.java_edition_address) + format!( + "{} {}", + TextComponent::text("Java Edition:") + .color_named(NamedColor::Yellow) + .to_pretty_console(), + TextComponent::text(format!("{}", basic_config.java_edition_address)) + .color_named(NamedColor::DarkBlue) + .to_pretty_console() + ) } else { - String::new() + TextComponent::text(String::new()).to_pretty_console() }, if basic_config.java_edition && basic_config.bedrock_edition { " | " // Separator if both are enabled @@ -109,16 +134,51 @@ async fn main() { "" }, if basic_config.bedrock_edition { - format!("Bedrock Edition: {}", basic_config.bedrock_edition_address) + format!( + "{} {}", + TextComponent::text("Bedrock Edition:") + .color_named(NamedColor::Gold) + .to_pretty_console(), + TextComponent::text(format!("{}", basic_config.bedrock_edition_address)) + .color_named(NamedColor::DarkBlue) + .to_pretty_console() + ) } else { - String::new() + TextComponent::text(String::new()).to_pretty_console() } ); pumpkin_server.start().await; - log::info!("The server has stopped."); + log::info!( + "{}", + TextComponent::text("The server has stopped.") + .color_named(NamedColor::Red) + .to_pretty_console() + ); +} +fn print_support_links_and_warning() { + log::warn!( + "{}", + TextComponent::text("Pumpkin is currently under heavy development!") + .color_named(NamedColor::DarkRed) + .to_pretty_console(), + ); + log::info!( + "Report issues on {}", + TextComponent::text("https://github.com/Pumpkin-MC/Pumpkin/issues") + .color_named(NamedColor::DarkAqua) + .to_pretty_console() + ); + log::info!( + "Join our {} for community support: {}", + TextComponent::text("Discord") + .color_named(NamedColor::DarkBlue) + .to_pretty_console(), + TextComponent::text("https://discord.gg/pumpkinmc") + .color_named(NamedColor::Aqua) + .to_pretty_console() + ); } - fn handle_interrupt() { log::warn!( "{}", diff --git a/pumpkin/src/net/query.rs b/pumpkin/src/net/query.rs index b71bb0c0a..3b61e9d25 100644 --- a/pumpkin/src/net/query.rs +++ b/pumpkin/src/net/query.rs @@ -9,6 +9,7 @@ use std::{ use pumpkin_protocol::query::{ CBasicStatus, CFullStatus, CHandshake, PacketType, RawQueryPacket, SHandshake, SStatusRequest, }; +use pumpkin_util::text::{TextComponent, color::NamedColor}; use pumpkin_world::CURRENT_MC_VERSION; use rand::RngExt; use tokio::{net::UdpSocket, sync::RwLock, time}; @@ -37,10 +38,15 @@ pub async fn start_query_handler(server: Arc, query_addr: SocketAddr) { log::info!( "Server query running on port {}", - socket - .local_addr() - .expect("Unable to find running address!") - .port() + TextComponent::text(format!( + "{}", + socket + .local_addr() + .expect("Unable to find running address!") + .port() + )) + .color_named(NamedColor::DarkBlue) + .to_pretty_console() ); while !SHOULD_STOP.load(Ordering::Relaxed) { diff --git a/pumpkin/src/server/mod.rs b/pumpkin/src/server/mod.rs index 265a1d4d3..f27c785a5 100644 --- a/pumpkin/src/server/mod.rs +++ b/pumpkin/src/server/mod.rs @@ -19,6 +19,7 @@ use key_store::KeyStore; use pumpkin_config::{AdvancedConfiguration, BasicConfiguration}; use pumpkin_data::dimension::Dimension; use pumpkin_util::permission::{PermissionManager, PermissionRegistry}; +use pumpkin_util::text::color::NamedColor; use pumpkin_world::dimension::into_level; use crate::command::CommandSender; @@ -263,7 +264,12 @@ impl Server { let config = Arc::new(server.advanced_config.world.clone()); tokio::task::spawn_blocking(move || { - log::info!("Loading {}", dim.minecraft_name); + log::info!( + "Loading {}", + TextComponent::text(dim.minecraft_name.to_string()) + .color_named(NamedColor::DarkGreen) + .to_pretty_console() + ); World::load( into_level(dim, &config, path, registry.clone(), seed), l_info,