diff --git a/assets/data/configs/main-config.toml b/assets/data/configs/main-config.toml index 35c3d2fb..3dff1fc2 100644 --- a/assets/data/configs/main-config.toml +++ b/assets/data/configs/main-config.toml @@ -37,6 +37,9 @@ default_gamemode = "creative" # https://github.com/pebblehost/hunter/blob/master/ips.txt and updated every 3 hours. block_scanner_ips = true +# If enabled, players will have full permissions upon joining. This does not apply to players who have joined before. +op_by_default = true + # Database configuration [database] # Path to the world database @@ -73,4 +76,4 @@ serve_page = true # The port the dashboard will run on. port = 9000 # Randomly generated secret for accessing the dashboard. -secret = "This will be replaced with a random string on first run, do not change this text. If you see this outside of the default config, something is wrong." \ No newline at end of file +secret = "This will be replaced with a random string on first run, do not change this text. If you see this outside of the default config, something is wrong." diff --git a/src/config/src/server_config.rs b/src/config/src/server_config.rs index a16caaad..74834381 100644 --- a/src/config/src/server_config.rs +++ b/src/config/src/server_config.rs @@ -23,6 +23,9 @@ pub(crate) const DEFAULT_CONFIG: &str = /// - `whitelist`: Whether the server whitelist is enabled or not. /// - `chunk_render_distance`: The render distance of the chunks. This is the number of chunks that will be /// loaded around the player. +/// - `op_by_default`: Whether players are op by default or not. +/// - `default_gamemode`: The default gamemode that players will be in when they join the server. +/// - `block_scanner_ips`: Whether to enable the block scanner IPs feature. This will block IPs that are known to be used by scanners. #[derive(Debug, Deserialize, Serialize, Default)] pub struct ServerConfig { pub host: String, @@ -38,6 +41,7 @@ pub struct ServerConfig { pub online_mode: bool, pub whitelist: bool, pub chunk_render_distance: u32, + pub op_by_default: bool, pub default_gamemode: String, pub block_scanner_ips: bool, pub dashboard: DashboardConfig, @@ -125,6 +129,7 @@ pub fn create_dummy_config() -> ServerConfig { port: 8080, secret: "not very secret".to_string(), }, + op_by_default: true, performance: PerformanceConfig { chunks_per_tick_min: 5, chunks_per_tick: 10, diff --git a/src/net/runtime/src/conn_init/login.rs b/src/net/runtime/src/conn_init/login.rs index 61bfac8e..e23d9f79 100644 --- a/src/net/runtime/src/conn_init/login.rs +++ b/src/net/runtime/src/conn_init/login.rs @@ -533,7 +533,16 @@ pub(super) async fn login( abilities: temper_components::player::abilities::PlayerAbilities::for_game_mode( GameMode::from_string(&state.config.default_gamemode).unwrap_or_default(), ), - + permissions: if state.config.op_by_default { + let mut perms = temper_permissions::player::PlayerPermission::new(); + perms.set_permission( + temper_permissions::Permissions::ALL, + temper_permissions::Access::Allow, + ); + perms + } else { + temper_permissions::player::PlayerPermission::new() + }, ..Default::default() }); diff --git a/src/net/runtime/src/connection.rs b/src/net/runtime/src/connection.rs index f9506e04..d2835072 100644 --- a/src/net/runtime/src/connection.rs +++ b/src/net/runtime/src/connection.rs @@ -354,7 +354,7 @@ pub async fn handle_connection( client_information_component: login_result .client_information_component .unwrap_or_default(), - permissions: login_result.permissions.unwrap_or_default(), + permissions: login_result.permissions.unwrap(), }) .map_err(|_| NetError::Misc("Failed to register new connection".to_string()))?;