mirror of https://github.com/zyllian/classics.git synced 2025-05-10 00:06:40 -07:00

write server config on change

This commit is contained in:
Zoey 2024-04-23 00:53:36 -07:00
parent 5b7b947804
commit ab4f81b836
No known key found for this signature in database
GPG key ID: 8611B896D1AAFAF2
3 changed files with 39 additions and 12 deletions

View file

@ -393,18 +393,31 @@ async fn handle_stream_inner(
serde_json::to_string(&permissions)
.expect("should never fail");
let current = data
if let Some(current) = data
.config
.player_perms
.entry(player_username.to_string())
.or_default();
if *current >= player_perms {
msg!("&cThis player outranks or is the same rank as you"
.get(player_username)
{
if *current >= player_perms {
msg!("&cThis player outranks or is the same rank as you"
.to_string());
continue;
continue;
}
}
*current = permissions;
data.config_needs_saving = true;
if matches!(permissions, PlayerType::Normal)
{
data.config
.player_perms
.remove(player_username);
} else {
data.config.player_perms.insert(
player_username.to_string(),
permissions,
);
}
if let Some(p) = data
.players
.iter_mut()