cloak sec and hats
This commit is contained in:
+37
-9
@@ -1,9 +1,7 @@
|
||||
pub type Result<T = Response> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Response {
|
||||
Pong,
|
||||
Success,
|
||||
pub enum PlayerResponse {
|
||||
Player {
|
||||
uuid: String,
|
||||
cloaks: Vec<String>,
|
||||
@@ -11,14 +9,12 @@ pub enum Response {
|
||||
hats: Vec<String>,
|
||||
hat: String,
|
||||
},
|
||||
NonSaturnPlayer,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Response {
|
||||
impl std::fmt::Display for PlayerResponse {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Response::Pong => write!(f, "Pong"),
|
||||
Response::Success => write!(f, "Success"),
|
||||
Response::Player {
|
||||
PlayerResponse::Player {
|
||||
uuid,
|
||||
cloaks,
|
||||
cloak,
|
||||
@@ -26,10 +22,40 @@ impl std::fmt::Display for Response {
|
||||
hat,
|
||||
} => write!(
|
||||
f,
|
||||
"@cloak={cloak}@uuid={uuid}@cloaks={}@hats={}@hat={hat}",
|
||||
"player@cloak={cloak}@uuid={uuid}@cloaks={}@hats={}@hat={hat}@saturn=true",
|
||||
cloaks.join("$"),
|
||||
hats.join("$"),
|
||||
),
|
||||
PlayerResponse::NonSaturnPlayer => write!(f, "@saturn=false"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Response {
|
||||
Pong,
|
||||
Success,
|
||||
Player(PlayerResponse),
|
||||
Players(Vec<PlayerResponse>),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Response {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Response::Pong => write!(f, "Pong"),
|
||||
Response::Success => write!(f, "Success"),
|
||||
Response::Player(player) => write!(f, "{player}"),
|
||||
Response::Players(players) => {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
players
|
||||
.iter()
|
||||
.map(|p| format!("{p}"))
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +69,7 @@ pub enum Error {
|
||||
InvalidSession,
|
||||
InvalidHandshake,
|
||||
DatabaseError,
|
||||
SomethingWentWrong,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
@@ -55,6 +82,7 @@ impl std::fmt::Display for Error {
|
||||
Error::InvalidSession => write!(f, "Invalid session"),
|
||||
Error::InvalidHandshake => write!(f, "Invalid handshake"),
|
||||
Error::DatabaseError => write!(f, "Database error"),
|
||||
Error::SomethingWentWrong => write!(f, "Something went wrong"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user