mirror of
https://github.com/zyllian/classics.git
synced 2025-05-11 14:26:40 -07:00
This commit is contained in:
parent
d53f37d664
commit
be81b8d581
11 changed files with 199 additions and 45 deletions
|
@ -29,6 +29,8 @@ pub struct Player {
|
|||
pub _addr: SocketAddr,
|
||||
/// the player's supported extensions
|
||||
pub extensions: ExtBitmask,
|
||||
/// the level of custom blocks this client supports
|
||||
pub custom_blocks_support_level: u8,
|
||||
/// queue of packets to be sent to this player
|
||||
pub packets_to_send: Vec<ServerPacket>,
|
||||
/// whether this player should be kicked and the message to give
|
||||
|
@ -36,7 +38,20 @@ pub struct Player {
|
|||
}
|
||||
|
||||
/// enum describing types of players
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
strum::EnumString,
|
||||
strum::IntoStaticStr,
|
||||
)]
|
||||
#[strum(ascii_case_insensitive)]
|
||||
pub enum PlayerType {
|
||||
/// a normal player
|
||||
Normal,
|
||||
|
@ -61,16 +76,3 @@ impl From<&PlayerType> for u8 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for PlayerType {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
Ok(match value.to_lowercase().as_str() {
|
||||
"normal" => Self::Normal,
|
||||
"moderator" => Self::Moderator,
|
||||
"operator" => Self::Operator,
|
||||
value => return Err(format!("Unknown permissions type: {value}")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue