From 5f5ec3bc45c61fc26ca6318aba75d3eb5d44c321 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 20 Jun 2021 23:07:29 +0100 Subject: [PATCH] More command permissions --- common/src/cmd.rs | 18 +++++++++--------- server/src/cmd.rs | 8 ++++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/common/src/cmd.rs b/common/src/cmd.rs index 190444290e..41d45416f9 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -334,13 +334,13 @@ impl ChatCommand { "Adds a new build area", Some(Admin), ), - ChatCommand::BuildAreaList => cmd(vec![], "List all build areas", Some(Admin)), + ChatCommand::BuildAreaList => cmd(vec![], "List all build areas", None), ChatCommand::BuildAreaRemove => cmd( vec![Any("name", Required)], "Removes specified build area", Some(Admin), ), - ChatCommand::Campfire => cmd(vec![], "Spawns a campfire", Some(Admin)), + ChatCommand::Campfire => cmd(vec![], "Spawns a campfire", None), ChatCommand::DebugColumn => cmd( vec![Integer("x", 15000, Required), Integer("y", 15000, Required)], "Prints some debug information about a column", @@ -459,17 +459,17 @@ impl ChatCommand { Float("strength", 5.0, Optional), ], "Spawn entity with light", - Some(Admin), + None, ), ChatCommand::MakeBlock => cmd( vec![Enum("block", BLOCK_KINDS.clone(), Required)], "Make a block at your location", - Some(Admin), + None, ), ChatCommand::MakeSprite => cmd( vec![Enum("sprite", SPRITE_KINDS.clone(), Required)], "Make a sprite at your location", - Some(Admin), + None, ), ChatCommand::Motd => cmd(vec![Message(Optional)], "View the server description", None), ChatCommand::Object => cmd( @@ -531,7 +531,7 @@ impl ChatCommand { ChatCommand::Site => cmd( vec![Message(Required)], "Teleport to a site", - Some(Moderator), + None, ), ChatCommand::SkillPoint => cmd( vec![ @@ -569,12 +569,12 @@ impl ChatCommand { ChatCommand::Time => cmd( vec![Enum("time", TIMES.clone(), Optional)], "Set the time of day", - Some(Admin), + None, ), ChatCommand::Tp => cmd( vec![PlayerName(Optional)], "Teleport to another player", - Some(Moderator), + None, ), ChatCommand::Unban => cmd( vec![Any("username", Required)], @@ -585,7 +585,7 @@ impl ChatCommand { ChatCommand::Waypoint => cmd( vec![], "Set your waypoint to your current position", - Some(Admin), + None, ), ChatCommand::Wiring => cmd(vec![], "Create wiring element", Some(Admin)), ChatCommand::Whitelist => cmd( diff --git a/server/src/cmd.rs b/server/src/cmd.rs index f1948cf3ab..586daf29d6 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -519,10 +519,13 @@ fn handle_make_block( if let Some(block_name) = scan_fmt_some!(&args, &action.arg_fmt(), String) { if let Ok(bk) = BlockKind::from_str(block_name.as_str()) { 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( - pos.0.map(|e| e.floor() as i32), - Block::new(bk, Rgb::broadcast(255)), + pos, + new_block, ); + server.state.ecs().write_resource::().set_block(pos, new_block); Ok(()) } else { Err(format!("Invalid block kind: {}", block_name)) @@ -550,6 +553,7 @@ fn handle_make_sprite( .unwrap_or_else(|| Block::air(SpriteKind::Empty)) .with_sprite(sk); server.state.set_block(pos, new_block); + server.state.ecs().write_resource::().set_block(pos, new_block); Ok(()) } else { Err(format!("Invalid sprite kind: {}", sprite_name))