mirror of https://github.com/zyllian/classics.git synced 2025-05-11 14:26:40 -07:00

implement CustomBlocks (resolves #19) and InventoryOrder (resolves #43)

This commit is contained in:
Zoey 2024-04-24 23:10:30 -07:00
parent d53f37d664
commit be81b8d581
No known key found for this signature in database
GPG key ID: 8611B896D1AAFAF2
11 changed files with 199 additions and 45 deletions

View file

@ -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}")),
})
}
}