Module valence_command::scopes
source · Expand description
Scope graph for the Valence Command system.
§Breakdown
Each scope is a node in a graph. A path from one node to another indicates that the first scope implies the second. A dot in the scope name indicates a sub-scope. You can use this to create a hierarchy of scopes. For example, the scope “valence.command” implies “valence.command.tp”. this means that if a player has the “valence.command” scope, they can use the “tp” command.
You may also link scopes together in the registry. This is useful for admin scope umbrellas. For example, if the scope “valence.admin” is linked to “valence.command”, It means that if a player has the “valence.admin” scope, they can use all commands under the command scope.
§Example
use valence_command::scopes::CommandScopeRegistry;
let mut registry = CommandScopeRegistry::new();
// add a scope to the registry
registry.add_scope("valence.command.teleport");
// we added 4 scopes to the registry. "valence", "valence.command", "valence.command.teleport",
// and the root scope.
assert_eq!(registry.scope_count(), 4);
registry.add_scope("valence.admin");
// add a scope to the registry with a link to another scope
registry.link("valence.admin", "valence.command.teleport");
// the "valence.admin" scope implies the "valence.command.teleport" scope
assert_eq!(
registry.grants("valence.admin", "valence.command.teleport"),
true
);
Structs§
- Store the scope graph and provide methods for querying it.
- Command scope Component for players. This is a list of scopes that a player has. If a player has a scope, they can use any command that requires that scope.