1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
use super::*;
#[mt_derive(to = "clt", repr = "u8", tag = "reason")]
pub enum KickReason {
WrongPasswd,
UnexpectedData,
SrvIsSingleplayer,
UnsupportedVersion,
BadNameChars,
BadName,
TooManyClts,
EmptyPasswd,
AlreadyConnected,
SrvErr,
Custom { custom: String },
Shutdown { custom: String, reconnect: bool },
Crash { custom: String, reconnect: bool },
}
impl KickReason {
pub fn reconnect(&self) -> bool {
use KickReason::*;
match self {
Shutdown { reconnect, .. } | Crash { reconnect, .. } => *reconnect,
_ => false,
}
}
}
impl fmt::Display for KickReason {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use KickReason::*;
match self {
WrongPasswd => write!(f, "wrong password"),
UnexpectedData => write!(f, "unexpected data"),
SrvIsSingleplayer => write!(f, "server is singleplayer"),
UnsupportedVersion => write!(f, "unsupported client version"),
BadNameChars => write!(f, "disallowed character(s) in player name"),
BadName => write!(f, "disallowed player name"),
TooManyClts => write!(f, "too many clients"),
EmptyPasswd => write!(f, "empty password"),
AlreadyConnected => write!(f, "another client is already connected with the same name"),
SrvErr => write!(f, "unsupported client version"),
Custom { custom } => write!(f, "{custom}"),
Shutdown { custom, .. } => {
if custom.is_empty() {
write!(f, "server shutdown")
} else {
write!(f, "server shutdown: {custom}")
}
}
Crash { custom, .. } => {
if custom.is_empty() {
write!(f, "server crash")
} else {
write!(f, "server crash: {custom}")
}
}
}
}
}
#[mt_derive(to = "clt", repr = "u32", enumset)]
pub enum AuthMethod {
LegacyPasswd,
Srp,
FirstSrp,
}
#[mt_derive(to = "clt", repr = "u64", enumset)]
pub enum CsmRestrictionFlag {
NoCsms,
NoChatMsgs,
NoItemDefs,
NoNodeDefs,
LimitMapRange,
NoPlayerList,
}
|