diff options
| author | mat <git@matdoes.dev> | 2023-05-12 23:40:34 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-05-12 23:40:34 -0500 |
| commit | 49952dd1507d70cd63305ffbcae4b062dfb4ce68 (patch) | |
| tree | 1b3e5bbd757634048988b9c8d96d5fb97f669427 /azalea-brigadier/src/context/command_context.rs | |
| parent | 657c073eab0f09d873bde21d5cdeb13a1bebb71b (diff) | |
| parent | 2057877eba5f6f13ba6863b48a9cdd44910a44f8 (diff) | |
| download | azalea-drasl-49952dd1507d70cd63305ffbcae4b062dfb4ce68.tar.xz | |
Merge branch 'main' into 1.20
Diffstat (limited to 'azalea-brigadier/src/context/command_context.rs')
| -rwxr-xr-x | azalea-brigadier/src/context/command_context.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs index 98609a6e..1734bb05 100755 --- a/azalea-brigadier/src/context/command_context.rs +++ b/azalea-brigadier/src/context/command_context.rs @@ -1,21 +1,23 @@ +use parking_lot::RwLock; + use super::{parsed_command_node::ParsedCommandNode, string_range::StringRange, ParsedArgument}; use crate::{ modifier::RedirectModifier, tree::{Command, CommandNode}, }; -use std::{any::Any, cell::RefCell, collections::HashMap, fmt::Debug, rc::Rc}; +use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; /// A built `CommandContextBuilder`. pub struct CommandContext<S> { - pub source: Rc<S>, + pub source: Arc<S>, pub input: String, pub arguments: HashMap<String, ParsedArgument>, pub command: Command<S>, - pub root_node: Rc<RefCell<CommandNode<S>>>, + pub root_node: Arc<RwLock<CommandNode<S>>>, pub nodes: Vec<ParsedCommandNode<S>>, pub range: StringRange, - pub child: Option<Rc<CommandContext<S>>>, - pub modifier: Option<Rc<RedirectModifier<S>>>, + pub child: Option<Arc<CommandContext<S>>>, + pub modifier: Option<Arc<RedirectModifier<S>>>, pub forks: bool, } @@ -54,8 +56,8 @@ impl<S> Debug for CommandContext<S> { } impl<S> CommandContext<S> { - pub fn copy_for(&self, source: Rc<S>) -> Self { - if Rc::ptr_eq(&source, &self.source) { + pub fn copy_for(&self, source: Arc<S>) -> Self { + if Arc::ptr_eq(&source, &self.source) { return self.clone(); } CommandContext { |
