Skip to content

Commit

Permalink
Merge pull request #16 from lukas0008/master
Browse files Browse the repository at this point in the history
Add default gamemode to configuration
  • Loading branch information
Snowiiii authored Aug 4, 2024
2 parents 42bc84b + 02337ad commit 5714c1b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pumpkin/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pumpkin/src/entity/player.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use pumpkin_protocol::VarInt;
use serde::{Deserialize, Serialize};

use super::{Entity, EntityId};

Expand Down Expand Up @@ -74,7 +75,7 @@ impl ChatMode {
}
}

#[derive(Clone, Copy)]
#[derive(Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum GameMode {
Undefined,
Survival,
Expand Down
8 changes: 6 additions & 2 deletions pumpkin/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5714c1b

Please sign in to comment.