Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion assets/data/configs/main-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
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."
5 changes: 5 additions & 0 deletions src/config/src/server_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion src/net/runtime/src/conn_init/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});

Expand Down
2 changes: 1 addition & 1 deletion src/net/runtime/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))?;

Expand Down