add tree-style command parsing utilities, heavily inspired by Mojang's Brigadier and adjust existing commands to use them

This commit is contained in:
user622628252416 committed 2024-08-19 00:31:24 +02:00
1 parent 77b205ada0
commit 943f8fcd4c
11 files changed
+524 -131

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
use pumpkin_text::{color::NamedColor, TextComponent};
use pumpkin_protocol::CURRENT_MC_PROTOCOL;
use crate::server::CURRENT_MC_VERSION;
use crate::commands::tree::CommandTree;
pub(crate) const NAME: &str = "pumpkin";
const DESCRIPTION: &str = "Displays information about Pumpkin";
pub(crate) fn init_command_tree<'a>() -> CommandTree<'a> {
CommandTree::new(DESCRIPTION).execute(&|sender, _| {
let version = env!("CARGO_PKG_VERSION");
let description = env!("CARGO_PKG_DESCRIPTION");
sender.send_message(TextComponent::from(
format!("Pumpkin {version}, {description} (Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL})")).color_named(NamedColor::Green)
);
Ok(())
})
}