From 811d71508208f8415d881f7c4d73429f1a73f36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20H=C3=B6lting?= <87192362+moritz-hoelting@users.noreply.github.com> Date: Thu, 27 Feb 2025 21:38:32 +0100 Subject: [PATCH] allow access to registered scoreboards --- CHANGELOG.md | 1 + src/datapack/mod.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58c20c5..f7c9094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - support for commands using macros +- support for registering scoreboards (automatic creation and deletion) ### Changed - use "return" command for conditionals instead of data storage when using supported pack format diff --git a/src/datapack/mod.rs b/src/datapack/mod.rs index eccfced..645f6d6 100644 --- a/src/datapack/mod.rs +++ b/src/datapack/mod.rs @@ -128,6 +128,12 @@ impl Datapack { ); } + /// Scoreboards registered in the datapack. + #[must_use] + pub fn scoreboards(&self) -> &BTreeMap, Option)> { + &self.scoreboards + } + /// Add a custom file to the datapack. pub fn add_custom_file(&mut self, path: &str, file: VFile) { self.custom_files.add_file(path, file); @@ -164,7 +170,7 @@ impl Datapack { .or_insert_with(|| Cow::Owned(Namespace::new(&self.main_namespace_name))); let register_scoreboard_function = main_namespace .to_mut() - .function_mut("shu/register_scoreboards"); + .function_mut("sb/register_scoreboards"); for (name, (criteria, display_name)) in &self.scoreboards { let mut creation_command = format!( "scoreboard objectives add {name} {criteria}", @@ -189,7 +195,7 @@ impl Datapack { .to_mut() .tag_mut("load", tag::TagType::Function) .add_value(tag::TagValue::Simple(format!( - "{}:shu/register_scoreboards", + "{}:sb/register_scoreboards", self.main_namespace_name ))); }