classics/src/main.rs

38 lines
725 B
Rust
Raw Normal View History

use std::path::PathBuf;
use error::GeneralError;
2024-04-22 10:18:05 -07:00
use server::{
config::{OptionalServerConfig, ServerConfig},
Server,
};
2024-04-18 19:43:27 -07:00
2024-04-22 22:02:06 -07:00
mod command;
mod error;
2024-04-18 19:43:27 -07:00
mod level;
mod packet;
mod player;
mod server;
mod util;
2024-04-18 19:43:27 -07:00
const SERVER_NAME: &str = "classics";
const CONFIG_FILE: &str = "./server-config.json";
2024-04-18 19:43:27 -07:00
#[tokio::main]
async fn main() -> Result<(), GeneralError> {
let config_path = PathBuf::from(CONFIG_FILE);
let config = if config_path.exists() {
serde_json::from_str::<OptionalServerConfig>(&std::fs::read_to_string(&config_path)?)?
2024-04-22 10:18:05 -07:00
.build_default()
} else {
2024-04-22 10:18:05 -07:00
ServerConfig::default()
};
println!("starting server with config: {config:#?}");
2024-04-23 01:14:17 -07:00
let server = Server::new(config).await?;
2024-04-18 19:43:27 -07:00
server.run().await?;
Ok(())
}