From a1c6ccae2843cf76cf126ef0d8222210f90195a3 Mon Sep 17 00:00:00 2001 From: ReCore Date: Mon, 29 Jun 2026 22:37:45 +0930 Subject: [PATCH 1/2] Player are opped on join --- assets/data/configs/main-config.toml | 5 ++++- src/config/src/server_config.rs | 5 +++++ src/game_systems/src/player/src/new_connections.rs | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) 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/game_systems/src/player/src/new_connections.rs b/src/game_systems/src/player/src/new_connections.rs index 527c5f64..1fcc3c23 100644 --- a/src/game_systems/src/player/src/new_connections.rs +++ b/src/game_systems/src/player/src/new_connections.rs @@ -59,6 +59,16 @@ pub fn accept_new_connections( abilities: PlayerAbilities::for_game_mode( GameMode::from_string(&state.0.config.default_gamemode).unwrap(), ), + permissions: if state.0.config.op_by_default { + let mut perms = temper_permissions::player::PlayerPermission::new(); + perms.set_permission( + temper_permissions::Permissions::Op, + temper_permissions::Access::Allow, + ); + perms + } else { + temper_permissions::player::PlayerPermission::new() + }, ..Default::default() }); // --- 2. Build the PlayerBundle --- From ce04d1a342a58ecd812ccdb9f172017bd8a98d0a Mon Sep 17 00:00:00 2001 From: ReCore Date: Wed, 1 Jul 2026 22:29:52 +0930 Subject: [PATCH 2/2] Actually tested it and it didn't work Mojang's servers were down when i tried to test the other day :( --- src/game_systems/src/player/src/new_connections.rs | 10 ---------- src/net/runtime/src/conn_init/login.rs | 11 ++++++++++- src/net/runtime/src/connection.rs | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/game_systems/src/player/src/new_connections.rs b/src/game_systems/src/player/src/new_connections.rs index 1fcc3c23..527c5f64 100644 --- a/src/game_systems/src/player/src/new_connections.rs +++ b/src/game_systems/src/player/src/new_connections.rs @@ -59,16 +59,6 @@ pub fn accept_new_connections( abilities: PlayerAbilities::for_game_mode( GameMode::from_string(&state.0.config.default_gamemode).unwrap(), ), - permissions: if state.0.config.op_by_default { - let mut perms = temper_permissions::player::PlayerPermission::new(); - perms.set_permission( - temper_permissions::Permissions::Op, - temper_permissions::Access::Allow, - ); - perms - } else { - temper_permissions::player::PlayerPermission::new() - }, ..Default::default() }); // --- 2. Build the PlayerBundle --- 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()))?;