diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 769d081933..73bdc649a4 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -92,6 +92,7 @@ fn main() -> io::Result<()> { // Load server settings let mut server_settings = server::Settings::load(&server_data_dir); let mut editable_settings = server::EditableSettings::load(&server_data_dir); + #[allow(clippy::single_match)] // Note: remove this when there are more subcommands match matches.subcommand() { ("admin", Some(sub_m)) => { admin::admin_subcommand( diff --git a/server/src/lib.rs b/server/src/lib.rs index 3b52937a57..2cb6b1e1d9 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -934,18 +934,30 @@ impl Server { self.state.ecs().read_storage::().join().count() as i64 } + // TODO: add Admin comp if ingame pub fn add_admin(&self, username: &str) { let mut editable_settings = self.editable_settings_mut(); let login_provider = self.state.ecs().fetch::(); let data_dir = self.data_dir(); - add_admin(username, &login_provider, &mut editable_settings, &data_dir.path); + add_admin( + username, + &login_provider, + &mut editable_settings, + &data_dir.path, + ); } + // TODO: remove Admin comp if ingame pub fn remove_admin(&self, username: &str) { let mut editable_settings = self.editable_settings_mut(); let login_provider = self.state.ecs().fetch::(); let data_dir = self.data_dir(); - remove_admin(username, &login_provider, &mut editable_settings, &data_dir.path); + remove_admin( + username, + &login_provider, + &mut editable_settings, + &data_dir.path, + ); } } @@ -958,14 +970,14 @@ impl Drop for Server { pub fn add_admin( username: &str, - login_provider: &LoginProvider, + login_provider: &LoginProvider, editable_settings: &mut EditableSettings, data_dir: &std::path::Path, ) { use crate::settings::EditableSetting; match login_provider.username_to_uuid(username) { Ok(uuid) => editable_settings.admins.edit(data_dir, |admins| { - if admins.insert(uuid.clone()) { + if admins.insert(uuid) { info!("Successfully added {} ({}) as an admin!", username, uuid); } else { info!("{} ({}) is already an admin!", username, uuid); @@ -973,15 +985,15 @@ pub fn add_admin( }), Err(err) => error!( ?err, - "Could not find uuid for this name either the user does not exist or \ - there was an error communicating with the auth server." + "Could not find uuid for this name either the user does not exist or there was an \ + error communicating with the auth server." ), } } pub fn remove_admin( username: &str, - login_provider: &LoginProvider, + login_provider: &LoginProvider, editable_settings: &mut EditableSettings, data_dir: &std::path::Path, ) { @@ -999,8 +1011,8 @@ pub fn remove_admin( }), Err(err) => error!( ?err, - "Could not find uuid for this name either the user does not exist or \ - there was an error communicating with the auth server." + "Could not find uuid for this name either the user does not exist or there was an \ + error communicating with the auth server." ), } } diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index de131a5a9b..ed6eb8ee4a 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -10,8 +10,8 @@ use crate::{ }; use common::{ comp::{ - Admin, CanBuild, ChatMode, ChatType, ControlEvent, Controller, ForceUpdate, Ori, - Player, Pos, Stats, UnresolvedChatMsg, Vel, + Admin, CanBuild, ChatMode, ChatType, ControlEvent, Controller, ForceUpdate, Ori, Player, + Pos, Stats, UnresolvedChatMsg, Vel, }, event::{EventBus, ServerEvent}, msg::{