|
1 |
| -use serde::{Deserialize, Serialize}; |
| 1 | +use serde::Deserialize; |
2 | 2 |
|
3 |
| -#[derive(Serialize, Deserialize, Debug)] |
| 3 | +#[derive(Deserialize, Debug)] |
4 | 4 | pub struct Config {
|
5 |
| - /// Minecraft server port (Minecraft's default port is `25565`) |
6 |
| - pub server_port: u16, |
| 5 | + /// API config |
| 6 | + pub api: API, |
| 7 | + |
| 8 | + /// Minecraft server config |
| 9 | + pub server: Server, |
| 10 | + |
| 11 | + /// Messages config |
| 12 | + pub messages: Messages, |
| 13 | + |
| 14 | + #[serde(skip)] |
| 15 | + /// Base 64 encoded server icon |
| 16 | + pub image: Option<String>, |
| 17 | +} |
| 18 | + |
| 19 | +#[derive(Deserialize, Debug)] |
| 20 | +pub struct API { |
| 21 | + /// API address |
| 22 | + pub addr: String, |
7 | 23 |
|
8 | 24 | /// API port
|
9 |
| - pub api_port: u16, |
| 25 | + pub port: u16, |
10 | 26 |
|
11 |
| - /// Display count of max server players |
12 |
| - pub players_max: usize, |
| 27 | + /// Life time of assigned code |
| 28 | + pub code_life_time: u64, |
| 29 | +} |
13 | 30 |
|
14 |
| - /// Display count of max server players |
15 |
| - pub players_online: usize, |
| 31 | +#[derive(Deserialize, Debug)] |
| 32 | +pub struct Server { |
| 33 | + /// Server address |
| 34 | + pub addr: String, |
16 | 35 |
|
17 |
| - /// Server protocol version (0 for auto) |
18 |
| - pub proto_ver: usize, |
| 36 | + /// Server port |
| 37 | + pub port: u16, |
19 | 38 |
|
20 |
| - /// Server version string (e.g. 1.20.5) |
21 |
| - pub server_ver: String, |
| 39 | + /// Server connection timeout |
| 40 | + pub timeout: u64, |
22 | 41 |
|
23 |
| - /// Server description (you can use a `§` codes) |
24 |
| - pub motd: String, |
| 42 | + /// Minecraft server config |
| 43 | + pub config: ServerConfig, |
25 | 44 |
|
26 |
| - /// Assigned 6-digit code life time in seconds |
27 |
| - pub code_life_time: u64, |
| 45 | + /// Server list ping config |
| 46 | + pub status: ServerStatus, |
| 47 | +} |
| 48 | + |
| 49 | +#[derive(Deserialize, Debug)] |
| 50 | +pub struct ServerConfig { |
| 51 | + /// Protocol version (`0` for auto) |
| 52 | + pub protocol: usize, |
| 53 | + |
| 54 | + /// Minecraft version string (e.g. `1.20.1`) |
| 55 | + pub version: String, |
| 56 | + |
| 57 | + /// Session Auth URL |
| 58 | + /// `{{NAME}}` in string will be replaced to client nickname |
| 59 | + /// `{{HASH}}` will be replaced to generated client hash |
| 60 | + pub auth_url: String, |
| 61 | +} |
| 62 | + |
| 63 | +#[derive(Deserialize, Debug)] |
| 64 | +pub struct ServerStatus { |
| 65 | + /// Server description (you can use MOTD) |
| 66 | + pub description: String, |
| 67 | + |
| 68 | + /// Max players count, displayed in server list |
| 69 | + pub players_max: usize, |
| 70 | + |
| 71 | + /// Online players count, displayed in server list |
| 72 | + pub players_online: usize, |
28 | 73 |
|
29 | 74 | /// Path to the server icon
|
30 | 75 | pub icon_path: String,
|
| 76 | +} |
31 | 77 |
|
32 |
| - #[serde(skip)] |
33 |
| - /// Base 64 encoded server icon |
34 |
| - pub image: Option<String>, |
| 78 | +#[derive(Deserialize, Debug)] |
| 79 | +pub struct Messages { |
| 80 | + /// Message for success auth |
| 81 | + /// `{{NAME}}` will be replaced to client nickname |
| 82 | + /// `{{UUID}}` will be replaced to client UUID |
| 83 | + /// `{{CODE}}` will be replaced to generated code |
| 84 | + pub success: String, |
| 85 | + |
| 86 | + /// Message for Mojang API error |
| 87 | + pub bad_session: String, |
35 | 88 | }
|
0 commit comments