diff --git a/pumpkin/src/config/commands.rs b/pumpkin/src/config/commands.rs new file mode 100644 index 000000000..94ee4d8c2 --- /dev/null +++ b/pumpkin/src/config/commands.rs @@ -0,0 +1,14 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize)] +pub struct CommandsConfig { + /// Are commands from the Console accepted ? + pub use_console: bool, + // TODO: commands... +} + +impl Default for CommandsConfig { + fn default() -> Self { + Self { use_console: true } + } +} diff --git a/pumpkin/src/config/compression.rs b/pumpkin/src/config/compression.rs new file mode 100644 index 000000000..544c8d31d --- /dev/null +++ b/pumpkin/src/config/compression.rs @@ -0,0 +1,24 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize)] +// Packet compression +pub struct CompressionConfig { + /// Is compression enabled ? + pub enabled: bool, + /// The compression threshold used when compression is enabled + pub compression_threshold: u32, + /// A value between 0..9 + /// 1 = Optimize for the best speed of encoding. + /// 9 = Optimize for the size of data being encoded. + pub compression_level: u32, +} + +impl Default for CompressionConfig { + fn default() -> Self { + Self { + enabled: true, + compression_threshold: 256, + compression_level: 4, + } + } +} diff --git a/pumpkin/src/config/mod.rs b/pumpkin/src/config/mod.rs index 9baa3fad4..50c40b977 100644 --- a/pumpkin/src/config/mod.rs +++ b/pumpkin/src/config/mod.rs @@ -14,7 +14,16 @@ pub mod auth; pub mod proxy; pub mod resource_pack; -use auth::AuthenticationConfig; +mod commands; +mod compression; +mod pvp; +mod rcon; + +pub use auth::AuthenticationConfig; +pub use commands::CommandsConfig; +pub use compression::CompressionConfig; +pub use pvp::PVPConfig; +pub use rcon::RCONConfig; /// Current Config version of the Base Config const CURRENT_BASE_VERSION: &str = "1.0.0"; @@ -35,85 +44,6 @@ pub struct AdvancedConfiguration { pub pvp: PVPConfig, } -#[derive(Deserialize, Serialize, Clone)] -pub struct RCONConfig { - pub enabled: bool, - pub address: SocketAddr, - pub password: String, -} - -impl Default for RCONConfig { - fn default() -> Self { - Self { - enabled: false, - address: SocketAddr::new(Ipv4Addr::new(0, 0, 0, 0).into(), 25575), - password: "".to_string(), - } - } -} - -#[derive(Deserialize, Serialize)] -pub struct CommandsConfig { - /// Are commands from the Console accepted ? - pub use_console: bool, - // TODO: commands... -} - -impl Default for CommandsConfig { - fn default() -> Self { - Self { use_console: true } - } -} - -#[derive(Deserialize, Serialize)] -pub struct PVPConfig { - /// Is PVP enabled ? - pub enabled: bool, - /// Do we want to have the Red hurt animation & fov bobbing - pub hurt_animation: bool, - /// Should players in creative be protected against PVP - pub protect_creative: bool, - /// Has PVP Knockback? - pub knockback: bool, - /// Should player swing when attacking? - pub swing: bool, -} - -impl Default for PVPConfig { - fn default() -> Self { - Self { - enabled: true, - hurt_animation: true, - protect_creative: true, - knockback: true, - swing: true, - } - } -} - -#[derive(Deserialize, Serialize)] -// Packet compression -pub struct CompressionConfig { - /// Is compression enabled ? - pub enabled: bool, - /// The compression threshold used when compression is enabled - pub compression_threshold: u32, - /// A value between 0..9 - /// 1 = Optimize for the best speed of encoding. - /// 9 = Optimize for the size of data being encoded. - pub compression_level: u32, -} - -impl Default for CompressionConfig { - fn default() -> Self { - Self { - enabled: true, - compression_threshold: 256, - compression_level: 4, - } - } -} - #[derive(Serialize, Deserialize)] pub struct BasicConfiguration { /// A version identifier for the configuration format. diff --git a/pumpkin/src/config/pvp.rs b/pumpkin/src/config/pvp.rs new file mode 100644 index 000000000..cfbddc6c4 --- /dev/null +++ b/pumpkin/src/config/pvp.rs @@ -0,0 +1,27 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize)] +pub struct PVPConfig { + /// Is PVP enabled ? + pub enabled: bool, + /// Do we want to have the Red hurt animation & fov bobbing + pub hurt_animation: bool, + /// Should players in creative be protected against PVP + pub protect_creative: bool, + /// Has PVP Knockback? + pub knockback: bool, + /// Should player swing when attacking? + pub swing: bool, +} + +impl Default for PVPConfig { + fn default() -> Self { + Self { + enabled: true, + hurt_animation: true, + protect_creative: true, + knockback: true, + swing: true, + } + } +} diff --git a/pumpkin/src/config/rcon.rs b/pumpkin/src/config/rcon.rs new file mode 100644 index 000000000..af5aa6ac0 --- /dev/null +++ b/pumpkin/src/config/rcon.rs @@ -0,0 +1,20 @@ +use std::net::{Ipv4Addr, SocketAddr}; + +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize, Clone)] +pub struct RCONConfig { + pub enabled: bool, + pub address: SocketAddr, + pub password: String, +} + +impl Default for RCONConfig { + fn default() -> Self { + Self { + enabled: false, + address: SocketAddr::new(Ipv4Addr::new(0, 0, 0, 0).into(), 25575), + password: "".to_string(), + } + } +}