Compare commits
3 Commits
b9c319165e
...
811d715082
Author | SHA1 | Date |
---|---|---|
|
811d715082 | |
|
1950c29ac3 | |
|
9337d09d7b |
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- support for commands using macros
|
- support for commands using macros
|
||||||
|
- support for registering scoreboards (automatic creation and deletion)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- use "return" command for conditionals instead of data storage when using supported pack format
|
- use "return" command for conditionals instead of data storage when using supported pack format
|
||||||
|
|
|
@ -128,6 +128,12 @@ impl Datapack {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Scoreboards registered in the datapack.
|
||||||
|
#[must_use]
|
||||||
|
pub fn scoreboards(&self) -> &BTreeMap<String, (Option<String>, Option<String>)> {
|
||||||
|
&self.scoreboards
|
||||||
|
}
|
||||||
|
|
||||||
/// Add a custom file to the datapack.
|
/// Add a custom file to the datapack.
|
||||||
pub fn add_custom_file(&mut self, path: &str, file: VFile) {
|
pub fn add_custom_file(&mut self, path: &str, file: VFile) {
|
||||||
self.custom_files.add_file(path, file);
|
self.custom_files.add_file(path, file);
|
||||||
|
@ -164,7 +170,7 @@ impl Datapack {
|
||||||
.or_insert_with(|| Cow::Owned(Namespace::new(&self.main_namespace_name)));
|
.or_insert_with(|| Cow::Owned(Namespace::new(&self.main_namespace_name)));
|
||||||
let register_scoreboard_function = main_namespace
|
let register_scoreboard_function = main_namespace
|
||||||
.to_mut()
|
.to_mut()
|
||||||
.function_mut("shu/register_scoreboards");
|
.function_mut("sb/register_scoreboards");
|
||||||
for (name, (criteria, display_name)) in &self.scoreboards {
|
for (name, (criteria, display_name)) in &self.scoreboards {
|
||||||
let mut creation_command = format!(
|
let mut creation_command = format!(
|
||||||
"scoreboard objectives add {name} {criteria}",
|
"scoreboard objectives add {name} {criteria}",
|
||||||
|
@ -189,24 +195,23 @@ impl Datapack {
|
||||||
.to_mut()
|
.to_mut()
|
||||||
.tag_mut("load", tag::TagType::Function)
|
.tag_mut("load", tag::TagType::Function)
|
||||||
.add_value(tag::TagValue::Simple(format!(
|
.add_value(tag::TagValue::Simple(format!(
|
||||||
"{}:shu/register_scoreboards",
|
"{}:sb/register_scoreboards",
|
||||||
self.main_namespace_name
|
self.main_namespace_name
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(uninstall_commands) = uninstall_commands {
|
if let Some(uninstall_commands) = uninstall_commands {
|
||||||
let main_namespace = modified_namespaces
|
if !uninstall_commands.is_empty() {
|
||||||
.entry(&self.main_namespace_name)
|
let main_namespace = modified_namespaces
|
||||||
.or_insert_with(|| Cow::Owned(Namespace::new(&self.main_namespace_name)));
|
.entry(&self.main_namespace_name)
|
||||||
let uninstall_function = main_namespace.to_mut().function_mut("uninstall");
|
.or_insert_with(|| Cow::Owned(Namespace::new(&self.main_namespace_name)));
|
||||||
uninstall_function
|
let uninstall_function = main_namespace.to_mut().function_mut("uninstall");
|
||||||
.get_commands_mut()
|
uninstall_function
|
||||||
.extend(uninstall_commands);
|
.get_commands_mut()
|
||||||
|
.extend(uninstall_commands);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg!(&self.namespaces);
|
|
||||||
dbg!(&modified_namespaces);
|
|
||||||
|
|
||||||
// Compile namespaces
|
// Compile namespaces
|
||||||
for (name, namespace) in modified_namespaces {
|
for (name, namespace) in modified_namespaces {
|
||||||
let namespace_folder = namespace.compile(&options, &compiler_state);
|
let namespace_folder = namespace.compile(&options, &compiler_state);
|
||||||
|
|
Loading…
Reference in New Issue