More command permissions

This commit is contained in:
Joshua Barretto 2021-06-20 23:07:29 +01:00
parent 86ea5444ab
commit 5f5ec3bc45
2 changed files with 15 additions and 11 deletions

View File

@ -334,13 +334,13 @@ impl ChatCommand {
"Adds a new build area", "Adds a new build area",
Some(Admin), Some(Admin),
), ),
ChatCommand::BuildAreaList => cmd(vec![], "List all build areas", Some(Admin)), ChatCommand::BuildAreaList => cmd(vec![], "List all build areas", None),
ChatCommand::BuildAreaRemove => cmd( ChatCommand::BuildAreaRemove => cmd(
vec![Any("name", Required)], vec![Any("name", Required)],
"Removes specified build area", "Removes specified build area",
Some(Admin), Some(Admin),
), ),
ChatCommand::Campfire => cmd(vec![], "Spawns a campfire", Some(Admin)), ChatCommand::Campfire => cmd(vec![], "Spawns a campfire", None),
ChatCommand::DebugColumn => cmd( ChatCommand::DebugColumn => cmd(
vec![Integer("x", 15000, Required), Integer("y", 15000, Required)], vec![Integer("x", 15000, Required), Integer("y", 15000, Required)],
"Prints some debug information about a column", "Prints some debug information about a column",
@ -459,17 +459,17 @@ impl ChatCommand {
Float("strength", 5.0, Optional), Float("strength", 5.0, Optional),
], ],
"Spawn entity with light", "Spawn entity with light",
Some(Admin), None,
), ),
ChatCommand::MakeBlock => cmd( ChatCommand::MakeBlock => cmd(
vec![Enum("block", BLOCK_KINDS.clone(), Required)], vec![Enum("block", BLOCK_KINDS.clone(), Required)],
"Make a block at your location", "Make a block at your location",
Some(Admin), None,
), ),
ChatCommand::MakeSprite => cmd( ChatCommand::MakeSprite => cmd(
vec![Enum("sprite", SPRITE_KINDS.clone(), Required)], vec![Enum("sprite", SPRITE_KINDS.clone(), Required)],
"Make a sprite at your location", "Make a sprite at your location",
Some(Admin), None,
), ),
ChatCommand::Motd => cmd(vec![Message(Optional)], "View the server description", None), ChatCommand::Motd => cmd(vec![Message(Optional)], "View the server description", None),
ChatCommand::Object => cmd( ChatCommand::Object => cmd(
@ -531,7 +531,7 @@ impl ChatCommand {
ChatCommand::Site => cmd( ChatCommand::Site => cmd(
vec![Message(Required)], vec![Message(Required)],
"Teleport to a site", "Teleport to a site",
Some(Moderator), None,
), ),
ChatCommand::SkillPoint => cmd( ChatCommand::SkillPoint => cmd(
vec![ vec![
@ -569,12 +569,12 @@ impl ChatCommand {
ChatCommand::Time => cmd( ChatCommand::Time => cmd(
vec![Enum("time", TIMES.clone(), Optional)], vec![Enum("time", TIMES.clone(), Optional)],
"Set the time of day", "Set the time of day",
Some(Admin), None,
), ),
ChatCommand::Tp => cmd( ChatCommand::Tp => cmd(
vec![PlayerName(Optional)], vec![PlayerName(Optional)],
"Teleport to another player", "Teleport to another player",
Some(Moderator), None,
), ),
ChatCommand::Unban => cmd( ChatCommand::Unban => cmd(
vec![Any("username", Required)], vec![Any("username", Required)],
@ -585,7 +585,7 @@ impl ChatCommand {
ChatCommand::Waypoint => cmd( ChatCommand::Waypoint => cmd(
vec![], vec![],
"Set your waypoint to your current position", "Set your waypoint to your current position",
Some(Admin), None,
), ),
ChatCommand::Wiring => cmd(vec![], "Create wiring element", Some(Admin)), ChatCommand::Wiring => cmd(vec![], "Create wiring element", Some(Admin)),
ChatCommand::Whitelist => cmd( ChatCommand::Whitelist => cmd(

View File

@ -519,10 +519,13 @@ fn handle_make_block(
if let Some(block_name) = scan_fmt_some!(&args, &action.arg_fmt(), String) { if let Some(block_name) = scan_fmt_some!(&args, &action.arg_fmt(), String) {
if let Ok(bk) = BlockKind::from_str(block_name.as_str()) { if let Ok(bk) = BlockKind::from_str(block_name.as_str()) {
let pos = position(server, target, "target")?; let pos = position(server, target, "target")?;
let new_block = Block::new(bk, Rgb::broadcast(255));
let pos = pos.0.map(|e| e.floor() as i32);
server.state.set_block( server.state.set_block(
pos.0.map(|e| e.floor() as i32), pos,
Block::new(bk, Rgb::broadcast(255)), new_block,
); );
server.state.ecs().write_resource::<crate::TerrainPersistence>().set_block(pos, new_block);
Ok(()) Ok(())
} else { } else {
Err(format!("Invalid block kind: {}", block_name)) Err(format!("Invalid block kind: {}", block_name))
@ -550,6 +553,7 @@ fn handle_make_sprite(
.unwrap_or_else(|| Block::air(SpriteKind::Empty)) .unwrap_or_else(|| Block::air(SpriteKind::Empty))
.with_sprite(sk); .with_sprite(sk);
server.state.set_block(pos, new_block); server.state.set_block(pos, new_block);
server.state.ecs().write_resource::<crate::TerrainPersistence>().set_block(pos, new_block);
Ok(()) Ok(())
} else { } else {
Err(format!("Invalid sprite kind: {}", sprite_name)) Err(format!("Invalid sprite kind: {}", sprite_name))