Skip to main content

CommandContext

Struct CommandContext 

Source
pub(crate) struct CommandContext<S, R = BrigadierRuntime>
where R: CommandRuntime<S>,
{ source: Arc<S>, input: Arc<str>, root: NodeId, arguments: Arc<ParsedArguments<R::ArgumentValue>>, executor: Option<Arc<R::Executor>>, nodes: Arc<[ParsedCommandNode]>, range: StringRange, child: Option<Arc<Self>>, modifier: Option<Arc<R::Modifier>>, forks: bool, }
Expand description

Immutable parsed input supplied to commands and redirect modifiers.

Fields§

§source: Arc<S>§input: Arc<str>§root: NodeId§arguments: Arc<ParsedArguments<R::ArgumentValue>>§executor: Option<Arc<R::Executor>>§nodes: Arc<[ParsedCommandNode]>§range: StringRange§child: Option<Arc<Self>>§modifier: Option<Arc<R::Modifier>>§forks: bool

Implementations§

Source§

impl<S, R> CommandContext<S, R>
where R: CommandRuntime<S>,

Source

pub(crate) fn source(&self) -> &S

Returns the source used for this execution stage.

Source

pub(crate) fn input(&self) -> &str

Returns the complete parsed command input.

Source

pub(crate) const fn root(&self) -> NodeId

Returns the root at which this context segment began parsing.

Source

pub(crate) fn nodes(&self) -> &[ParsedCommandNode]

Returns all nodes consumed by this context segment.

Source

pub(crate) const fn range(&self) -> StringRange

Returns the range covered by this context segment.

Source

pub(crate) fn argument(&self, name: &str) -> Option<&R::ArgumentValue>

Returns a parsed runtime argument by name.

Source

pub(crate) fn child(&self) -> Option<&Self>

Returns the context reached through a redirect.

Source

pub(super) const fn child_arc(&self) -> Option<&Arc<Self>>

Source

pub(crate) fn executor(&self) -> Option<&R::Executor>

Source

pub(crate) fn modifier(&self) -> Option<&R::Modifier>

Source

pub(crate) const fn is_forked(&self) -> bool

Source

pub(crate) fn copy_for(&self, source: Arc<S>) -> Self

Source§

impl<S, R> CommandContext<S, R>

Source

pub(crate) fn boolean(&self, name: &str) -> Option<bool>

Returns a parsed boolean argument.

Source

pub(crate) fn integer(&self, name: &str) -> Option<i32>

Returns a parsed integer argument.

Source

pub(crate) fn long(&self, name: &str) -> Option<i64>

Returns a parsed long argument.

Source

pub(crate) fn float(&self, name: &str) -> Option<f32>

Returns a parsed float argument.

Source

pub(crate) fn double(&self, name: &str) -> Option<f64>

Returns a parsed double argument.

Source

pub(crate) fn string(&self, name: &str) -> Option<&str>

Returns a parsed string argument.

Source§

impl<S> CommandContext<S, SteelCommandRuntime>

Source

fn typed_argument<T: DowncastType>(&self, name: &str) -> Option<&T>

Source

pub(crate) fn time(&self, name: &str) -> Option<i32>

Returns a parsed Minecraft time argument in ticks.

Source

pub(crate) fn coordinates(&self, name: &str) -> Option<Coordinates>

Returns a parsed coordinate expression without resolving it early.

Source

pub(crate) fn entity_anchor(&self, name: &str) -> Option<EntityAnchor>

Returns a parsed entity position anchor.

Source

pub(crate) fn swizzle(&self, name: &str) -> Option<CoordinateAxes>

Source

pub(crate) fn heightmap(&self, name: &str) -> Option<HeightmapType>

Source

pub(crate) fn score_holder_argument( &self, name: &str, ) -> Option<&ScoreHolderArgument>

Source

pub(crate) fn objective_name(&self, name: &str) -> Option<&str>

Source

pub(crate) fn int_range(&self, name: &str) -> Option<IntRange>

Source

pub(crate) fn biome_or_tag(&self, name: &str) -> Option<&BiomeOrTag>

Source

pub(crate) fn structure_or_tag_key( &self, name: &str, ) -> Option<&StructureOrTagKey>

Source

pub(crate) fn block_predicate(&self, name: &str) -> Option<&BlockPredicate>

Source

pub(crate) fn domain(&self, name: &str) -> Option<&str>

Returns a configured Steel domain name.

Source

pub(crate) fn world_argument(&self, name: &str) -> Option<&WorldArgument>

Source

pub(crate) fn game_mode(&self, name: &str) -> Option<GameType>

Returns a parsed vanilla game mode.

Source

pub(crate) fn entity_type(&self, name: &str) -> Option<EntityTypeRef>

Source

pub(crate) fn enchantment(&self, name: &str) -> Option<EnchantmentRef>

Source

pub(crate) fn damage_type(&self, name: &str) -> Option<DamageTypeRef>

Source

pub(crate) fn item_stack(&self, name: &str) -> Option<&ItemStack>

Source

pub(crate) fn item_predicate(&self, name: &str) -> Option<&ItemPredicate>

Source

pub(crate) fn text_component(&self, name: &str) -> Option<&TextComponent>

Source

pub(crate) fn nbt_path(&self, name: &str) -> Option<&NbtPath>

Source

pub(crate) fn identifier(&self, name: &str) -> Option<&Identifier>

Source

pub(crate) fn world_clock(&self, name: &str) -> Option<WorldClockRef>

Source

pub(crate) fn timeline(&self, name: &str) -> Option<TimelineRef>

Source

pub(crate) fn entity_selector(&self, name: &str) -> Option<&EntitySelector>

Source

pub(crate) fn game_profile_argument( &self, name: &str, ) -> Option<&GameProfileArgument>

Source

pub(crate) fn permission_rule_expression( &self, name: &str, ) -> Option<&PermissionRuleExpression>

Source

pub(crate) fn permission_metadata_expression( &self, name: &str, ) -> Option<&PermissionMetadataExpression>

Source

pub(crate) fn permission_group( &self, name: &str, ) -> Option<&PermissionGroupName>

Source§

impl CommandContext<CommandSource, SteelCommandRuntime>

Source

pub(crate) fn score_holders( &self, name: &str, wildcard: ScoreHolderWildcard, ) -> Result<Vec<ScoreHolder>, CommandSyntaxError>

Source

pub(crate) fn score_holder( &self, name: &str, ) -> Result<ScoreHolder, CommandSyntaxError>

Source

pub(crate) fn optional_entities( &self, name: &str, ) -> Result<Vec<SharedEntity>, CommandSyntaxError>

Source

pub(crate) fn entities( &self, name: &str, ) -> Result<Vec<SharedEntity>, CommandSyntaxError>

Source

pub(crate) fn entity( &self, name: &str, ) -> Result<SharedEntity, CommandSyntaxError>

Source

pub(crate) fn optional_players( &self, name: &str, ) -> Result<Vec<Arc<Player>>, CommandSyntaxError>

Source

pub(crate) fn players( &self, name: &str, ) -> Result<Vec<Arc<Player>>, CommandSyntaxError>

Source

pub(crate) fn player( &self, name: &str, ) -> Result<Arc<Player>, CommandSyntaxError>

Auto Trait Implementations§

§

impl<S, R> Freeze for CommandContext<S, R>

§

impl<S, R> RefUnwindSafe for CommandContext<S, R>

§

impl<S, R> Send for CommandContext<S, R>
where S: Sync + Send,

§

impl<S, R> Sync for CommandContext<S, R>
where S: Sync + Send,

§

impl<S, R> Unpin for CommandContext<S, R>

§

impl<S, R> UnsafeUnpin for CommandContext<S, R>

§

impl<S, R> UnwindSafe for CommandContext<S, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more