mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix clippy, minor fmt, add TODO comments
This commit is contained in:
parent
39f78e9116
commit
fa45edb541
@ -92,6 +92,7 @@ fn main() -> io::Result<()> {
|
|||||||
// Load server settings
|
// Load server settings
|
||||||
let mut server_settings = server::Settings::load(&server_data_dir);
|
let mut server_settings = server::Settings::load(&server_data_dir);
|
||||||
let mut editable_settings = server::EditableSettings::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() {
|
match matches.subcommand() {
|
||||||
("admin", Some(sub_m)) => {
|
("admin", Some(sub_m)) => {
|
||||||
admin::admin_subcommand(
|
admin::admin_subcommand(
|
||||||
|
@ -934,18 +934,30 @@ impl Server {
|
|||||||
self.state.ecs().read_storage::<Client>().join().count() as i64
|
self.state.ecs().read_storage::<Client>().join().count() as i64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add Admin comp if ingame
|
||||||
pub fn add_admin(&self, username: &str) {
|
pub fn add_admin(&self, username: &str) {
|
||||||
let mut editable_settings = self.editable_settings_mut();
|
let mut editable_settings = self.editable_settings_mut();
|
||||||
let login_provider = self.state.ecs().fetch::<LoginProvider>();
|
let login_provider = self.state.ecs().fetch::<LoginProvider>();
|
||||||
let data_dir = self.data_dir();
|
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) {
|
pub fn remove_admin(&self, username: &str) {
|
||||||
let mut editable_settings = self.editable_settings_mut();
|
let mut editable_settings = self.editable_settings_mut();
|
||||||
let login_provider = self.state.ecs().fetch::<LoginProvider>();
|
let login_provider = self.state.ecs().fetch::<LoginProvider>();
|
||||||
let data_dir = self.data_dir();
|
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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,7 +977,7 @@ pub fn add_admin(
|
|||||||
use crate::settings::EditableSetting;
|
use crate::settings::EditableSetting;
|
||||||
match login_provider.username_to_uuid(username) {
|
match login_provider.username_to_uuid(username) {
|
||||||
Ok(uuid) => editable_settings.admins.edit(data_dir, |admins| {
|
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);
|
info!("Successfully added {} ({}) as an admin!", username, uuid);
|
||||||
} else {
|
} else {
|
||||||
info!("{} ({}) is already an admin!", username, uuid);
|
info!("{} ({}) is already an admin!", username, uuid);
|
||||||
@ -973,8 +985,8 @@ pub fn add_admin(
|
|||||||
}),
|
}),
|
||||||
Err(err) => error!(
|
Err(err) => error!(
|
||||||
?err,
|
?err,
|
||||||
"Could not find uuid for this name either the user does not exist or \
|
"Could not find uuid for this name either the user does not exist or there was an \
|
||||||
there was an error communicating with the auth server."
|
error communicating with the auth server."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -999,8 +1011,8 @@ pub fn remove_admin(
|
|||||||
}),
|
}),
|
||||||
Err(err) => error!(
|
Err(err) => error!(
|
||||||
?err,
|
?err,
|
||||||
"Could not find uuid for this name either the user does not exist or \
|
"Could not find uuid for this name either the user does not exist or there was an \
|
||||||
there was an error communicating with the auth server."
|
error communicating with the auth server."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
comp::{
|
comp::{
|
||||||
Admin, CanBuild, ChatMode, ChatType, ControlEvent, Controller, ForceUpdate, Ori,
|
Admin, CanBuild, ChatMode, ChatType, ControlEvent, Controller, ForceUpdate, Ori, Player,
|
||||||
Player, Pos, Stats, UnresolvedChatMsg, Vel,
|
Pos, Stats, UnresolvedChatMsg, Vel,
|
||||||
},
|
},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
msg::{
|
msg::{
|
||||||
|
Loading…
Reference in New Issue
Block a user