From 72f98849ea1f59228522bc9c1627c9344c0dd904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:40:25 +0100 Subject: [PATCH] convert debug command to use macro string --- src/datapack/command/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/datapack/command/mod.rs b/src/datapack/command/mod.rs index e4a0ad3..15ee7ac 100644 --- a/src/datapack/command/mod.rs +++ b/src/datapack/command/mod.rs @@ -29,7 +29,7 @@ pub enum Command { /// A command that contains macro usages UsesMacro(MacroString), /// Message to be printed only in debug mode - Debug(String), + Debug(MacroString), /// Execute command Execute(Execute), /// Group of commands to be called instantly after each other @@ -91,8 +91,8 @@ impl Command { #[must_use] pub fn contains_macro(&self, options: &CompileOptions) -> bool { match self { - Self::Raw(_) | Self::Comment(_) | Self::Debug(_) | Self::Execute(_) => false, - Self::UsesMacro(cmd) => cmd.contains_macro(), + Self::Raw(_) | Self::Comment(_) | Self::Execute(_) => false, + Self::UsesMacro(s) | Self::Debug(s) => s.contains_macro(), Self::Group(commands) => group_contains_macro(commands, options), } } @@ -101,8 +101,8 @@ impl Command { #[must_use] pub fn get_macros(&self) -> HashSet<&str> { match self { - Self::Raw(_) | Self::Comment(_) | Self::Debug(_) | Self::Execute(_) => HashSet::new(), - Self::UsesMacro(cmd) => cmd.get_macros(), + Self::Raw(_) | Self::Comment(_) | Self::Execute(_) => HashSet::new(), + Self::UsesMacro(s) | Self::Debug(s) => s.get_macros(), Self::Group(commands) => group_get_macros(commands), } } @@ -124,11 +124,11 @@ impl From<&mut Function> for Command { } } -fn compile_debug(message: &str, option: &CompileOptions) -> Vec { +fn compile_debug(message: &MacroString, option: &CompileOptions) -> Vec { if option.debug { vec![format!( - r#"tellraw @a [{{"text":"[","color":"dark_blue"}},{{"text":"DEBUG","color":"dark_green","hoverEvent":{{"action":"show_text","value":[{{"text":"Debug message generated by Shulkerbox"}},{{"text":"\nSet debug message to 'false' to disable"}}]}}}},{{"text":"]","color":"dark_blue"}},{{"text":" {}","color":"black"}}]"#, - message + r#"tellraw @a [{{"text":"[","color":"dark_blue"}},{{"text":"DEBUG","color":"dark_green","hoverEvent":{{"action":"show_text","value":[{{"text":"Debug message generated by Shulkerbox"}},{{"text":"\nSet debug to 'false' to disable"}}]}}}},{{"text":"] ","color":"dark_blue"}},{{"text":"{}","color":"black"}}]"#, + message.compile() )] } else { Vec::new()