2024-04-19 11:50:11 -07:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2024-04-25 00:01:28 -07:00
|
|
|
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;
|
2024-04-25 00:01:28 -07:00
|
|
|
mod error;
|
2024-04-18 19:43:27 -07:00
|
|
|
mod level;
|
|
|
|
mod packet;
|
|
|
|
mod player;
|
|
|
|
mod server;
|
2024-04-22 16:35:54 -07:00
|
|
|
mod util;
|
2024-04-18 19:43:27 -07:00
|
|
|
|
2024-04-24 18:54:19 -07:00
|
|
|
const SERVER_NAME: &str = "classics";
|
2024-04-19 11:50:11 -07:00
|
|
|
const CONFIG_FILE: &str = "./server-config.json";
|
|
|
|
|
2024-04-18 19:43:27 -07:00
|
|
|
#[tokio::main]
|
2024-04-25 00:01:28 -07:00
|
|
|
async fn main() -> Result<(), GeneralError> {
|
2024-04-19 11:50:11 -07:00
|
|
|
let config_path = PathBuf::from(CONFIG_FILE);
|
|
|
|
let config = if config_path.exists() {
|
2024-04-25 00:01:28 -07:00
|
|
|
serde_json::from_str::<OptionalServerConfig>(&std::fs::read_to_string(&config_path)?)?
|
2024-04-22 10:18:05 -07:00
|
|
|
.build_default()
|
2024-04-19 11:50:11 -07:00
|
|
|
} else {
|
2024-04-22 10:18:05 -07:00
|
|
|
ServerConfig::default()
|
2024-04-19 11:50:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
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(())
|
|
|
|
}
|