diff --git a/pumpkin/src/configuration.rs b/pumpkin/src/configuration.rs index 32c2f7373..f7166b875 100644 --- a/pumpkin/src/configuration.rs +++ b/pumpkin/src/configuration.rs @@ -2,7 +2,7 @@ use std::path::Path; use serde::{Deserialize, Serialize}; -use crate::server::Difficulty; +use crate::{entity::player::GameMode, server::Difficulty}; /// Current Config version of the Base Config const CURRENT_BASE_VERSION: &str = "1.0.0"; @@ -59,6 +59,8 @@ pub struct BasicConfiguration { pub prevent_proxy_connections: bool, /// The description send when Client performs a Status request, (e.g Multiplayer Screen) pub motd: String, + /// default gamemode (e.g. Survival, Creative...) + pub default_gamemode: GameMode, } impl Default for BasicConfiguration { @@ -80,6 +82,7 @@ impl Default for BasicConfiguration { encryption: true, prevent_proxy_connections: true, motd: "A Blazing fast Pumpkin Server!".to_string(), + default_gamemode: GameMode::Survival, } } } diff --git a/pumpkin/src/entity/player.rs b/pumpkin/src/entity/player.rs index 256df0e29..ff4fb4678 100644 --- a/pumpkin/src/entity/player.rs +++ b/pumpkin/src/entity/player.rs @@ -1,4 +1,5 @@ use pumpkin_protocol::VarInt; +use serde::{Deserialize, Serialize}; use super::{Entity, EntityId}; @@ -74,7 +75,7 @@ impl ChatMode { } } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum GameMode { Undefined, Survival, diff --git a/pumpkin/src/server.rs b/pumpkin/src/server.rs index bb0019d05..4fc9358ec 100644 --- a/pumpkin/src/server.rs +++ b/pumpkin/src/server.rs @@ -131,8 +131,12 @@ impl Server { 0, "minecraft:overworld".into(), 0, // seed - GameMode::Survival.to_byte() as u8, - GameMode::Survival.to_byte(), + match self.base_config.default_gamemode { + GameMode::Undefined => GameMode::Survival, + game_mode => game_mode, + } + .to_byte() as u8, + self.base_config.default_gamemode.to_byte(), false, false, false, // deth loc