rename Player::player_type to Player::permissions

This commit is contained in:
Zoey 2024-04-23 11:54:54 -07:00
parent b3050b5f29
commit b76bb5bbc6
No known key found for this signature in database
GPG key ID: 8611B896D1AAFAF2
2 changed files with 10 additions and 10 deletions

View file

@ -23,7 +23,7 @@ pub struct Player {
/// the player's pitch /// the player's pitch
pub pitch: u8, pub pitch: u8,
/// the player's permission state /// the player's permission state
pub player_type: PlayerType, pub permissions: PlayerType,
/// the player's IP address /// the player's IP address
pub _addr: SocketAddr, pub _addr: SocketAddr,

View file

@ -186,7 +186,7 @@ async fn handle_stream_inner(
z: zero, z: zero,
yaw: 0, yaw: 0,
pitch: 0, pitch: 0,
player_type, permissions: player_type,
packets_to_send: Vec::new(), packets_to_send: Vec::new(),
should_be_kicked: None, should_be_kicked: None,
}; };
@ -282,7 +282,7 @@ async fn handle_stream_inner(
let player_type = data let player_type = data
.players .players
.iter() .iter()
.find_map(|p| (p.id == *own_id).then_some(p.player_type)) .find_map(|p| (p.id == *own_id).then_some(p.permissions))
.unwrap_or_default(); .unwrap_or_default();
if player_type < new_block_info.place_permissions { if player_type < new_block_info.place_permissions {
cancel = true; cancel = true;
@ -344,7 +344,7 @@ async fn handle_stream_inner(
.find(|p| p.id == *own_id) .find(|p| p.id == *own_id)
.expect("missing player"); .expect("missing player");
if cmd.perms_required() > player.player_type { if cmd.perms_required() > player.permissions {
msg!("&cPermissions do not allow you to use this command".to_string()); msg!("&cPermissions do not allow you to use this command".to_string());
continue; continue;
} }
@ -384,7 +384,7 @@ async fn handle_stream_inner(
player_username, player_username,
permissions, permissions,
} => { } => {
let player_perms = player.player_type; let player_perms = player.permissions;
if player_username == player.username { if player_username == player.username {
msg!("&cCannot change your own permissions".to_string()); msg!("&cCannot change your own permissions".to_string());
continue; continue;
@ -427,10 +427,10 @@ async fn handle_stream_inner(
.iter_mut() .iter_mut()
.find(|p| p.username == player_username) .find(|p| p.username == player_username)
{ {
p.player_type = permissions; p.permissions = permissions;
p.packets_to_send.push( p.packets_to_send.push(
ServerPacket::UpdateUserType { ServerPacket::UpdateUserType {
user_type: p.player_type, user_type: p.permissions,
}, },
); );
p.packets_to_send.push(ServerPacket::Message { p.packets_to_send.push(ServerPacket::Message {
@ -441,7 +441,7 @@ async fn handle_stream_inner(
msg!(format!("Set permissions for {player_username} to {perm_string}")); msg!(format!("Set permissions for {player_username} to {perm_string}"));
} }
Command::Kick { username, message } => { Command::Kick { username, message } => {
let player_perms = player.player_type; let player_perms = player.permissions;
if let Some(other_player) = data if let Some(other_player) = data
.players .players
@ -449,7 +449,7 @@ async fn handle_stream_inner(
.find(|p| p.username == username) .find(|p| p.username == username)
{ {
if player_perms if player_perms
<= other_player.player_type <= other_player.permissions
{ {
msg!("&cThis player outranks or is the same rank as you".to_string()); msg!("&cThis player outranks or is the same rank as you".to_string());
continue; continue;
@ -489,7 +489,7 @@ async fn handle_stream_inner(
"&f".to_string(); "&f".to_string();
for command in COMMANDS_LIST.iter() for command in COMMANDS_LIST.iter()
{ {
if Command::perms_required_by_name(command) > player.player_type { if Command::perms_required_by_name(command) > player.permissions {
continue; continue;
} }
if current_message.len() if current_message.len()