mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added /server_physics
admin command.
This commit is contained in:
parent
c83c1a5571
commit
af47c0dc21
@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added disconnectall CLI command
|
||||
- One handed weapons can now be used and found in the world
|
||||
- Players can now opt-in to server-authoritiative physics in gameplay settings.
|
||||
- Added `/server_physics` admin command.
|
||||
|
||||
|
||||
### Changed
|
||||
|
@ -82,6 +82,7 @@ pub enum ChatCommand {
|
||||
RevokeBuildAll,
|
||||
Safezone,
|
||||
Say,
|
||||
ServerPhysics,
|
||||
SetMotd,
|
||||
Site,
|
||||
SkillPoint,
|
||||
@ -144,6 +145,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
|
||||
ChatCommand::RevokeBuildAll,
|
||||
ChatCommand::Safezone,
|
||||
ChatCommand::Say,
|
||||
ChatCommand::ServerPhysics,
|
||||
ChatCommand::SetMotd,
|
||||
ChatCommand::Site,
|
||||
ChatCommand::SkillPoint,
|
||||
@ -466,6 +468,14 @@ impl ChatCommand {
|
||||
"Send messages to everyone within shouting distance",
|
||||
NoAdmin,
|
||||
),
|
||||
ChatCommand::ServerPhysics => cmd(
|
||||
vec![
|
||||
Any("username", Required),
|
||||
Boolean("enabled", "true".to_string(), Optional),
|
||||
],
|
||||
"Set/unset server-authoritative physics for an account",
|
||||
Admin,
|
||||
),
|
||||
ChatCommand::SetMotd => {
|
||||
cmd(vec![Message(Optional)], "Set the server description", Admin)
|
||||
},
|
||||
@ -580,6 +590,7 @@ impl ChatCommand {
|
||||
ChatCommand::RevokeBuildAll => "revoke_build_all",
|
||||
ChatCommand::Safezone => "safezone",
|
||||
ChatCommand::Say => "say",
|
||||
ChatCommand::ServerPhysics => "server_physics",
|
||||
ChatCommand::SetMotd => "set_motd",
|
||||
ChatCommand::Site => "site",
|
||||
ChatCommand::SkillPoint => "skill_point",
|
||||
|
@ -24,7 +24,7 @@ use common::{
|
||||
effect::Effect,
|
||||
event::{EventBus, ServerEvent},
|
||||
npc::{self, get_npc_name},
|
||||
resources::TimeOfDay,
|
||||
resources::{PlayerPhysicsSettings, TimeOfDay},
|
||||
terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize},
|
||||
uid::Uid,
|
||||
vol::RectVolSize,
|
||||
@ -137,6 +137,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
|
||||
ChatCommand::RevokeBuildAll => handle_revoke_build_all,
|
||||
ChatCommand::Safezone => handle_safezone,
|
||||
ChatCommand::Say => handle_say,
|
||||
ChatCommand::ServerPhysics => handle_server_physics,
|
||||
ChatCommand::SetMotd => handle_set_motd,
|
||||
ChatCommand::Site => handle_site,
|
||||
ChatCommand::SkillPoint => handle_skill_point,
|
||||
@ -2477,3 +2478,35 @@ fn handle_unban(
|
||||
Err(action.help_string())
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_server_physics(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
_target: EcsEntity,
|
||||
args: String,
|
||||
action: &ChatCommand,
|
||||
) -> CmdResult<()> {
|
||||
if let (Some(username), enabled_opt) = scan_fmt_some!(&args, &action.arg_fmt(), String, bool) {
|
||||
let uuid = find_username(server, &username)?;
|
||||
let server_force = enabled_opt.unwrap_or(true);
|
||||
|
||||
let mut player_physics_settings =
|
||||
server.state.ecs().write_resource::<PlayerPhysicsSettings>();
|
||||
let entry = player_physics_settings.settings.entry(uuid).or_default();
|
||||
entry.server_force = server_force;
|
||||
|
||||
server.notify_client(
|
||||
client,
|
||||
ServerGeneral::server_msg(
|
||||
ChatType::CommandInfo,
|
||||
format!(
|
||||
"Updated physics settings for {} ({}): {:?}",
|
||||
username, uuid, entry
|
||||
),
|
||||
),
|
||||
);
|
||||
Ok(())
|
||||
} else {
|
||||
Err(action.help_string())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user