mirror of https://github.com/zyllian/classics.git synced 2025-05-10 02:26:53 -07:00

add basic server configuration + password protection

This commit is contained in:
Zoey 2024-04-19 11:50:11 -07:00
parent ca94ec10f2
commit c78303cf44
No known key found for this signature in database
GPG key ID: 8611B896D1AAFAF2
7 changed files with 146 additions and 17 deletions

39
src/server/config.rs Normal file
View file

@ -0,0 +1,39 @@
use serde::{Deserialize, Serialize};
/// configuration for the server
#[derive(Debug, Serialize, Deserialize)]
pub struct ServerConfig {
/// the server's name
pub name: String,
/// the server's motd
pub motd: String,
/// the server's password, if any
pub password: Option<String>,
/// the level's size
pub level_size: Option<ConfigCoordinates>,
/// the level's spawn point
pub spawn: Option<ConfigCoordinates>,
}
impl Default for ServerConfig {
fn default() -> Self {
Self {
name: "classic server wowie".to_string(),
motd: "here's the default server motd".to_string(),
password: None,
level_size: None,
spawn: None,
}
}
}
/// coordinates as stored in configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConfigCoordinates {
/// the X coordinate
pub x: usize,
/// the Y coordinate
pub y: usize,
/// the Z coordinate
pub z: usize,
}