Removed /home, replaced with /respawn

This commit is contained in:
Joshua Barretto 2023-04-01 17:37:01 +01:00
parent c0723c659e
commit 42c534b7b4
2 changed files with 14 additions and 16 deletions

View File

@ -272,7 +272,6 @@ pub enum ServerChatCommand {
GroupPromote, GroupPromote,
Health, Health,
Help, Help,
Home,
JoinFaction, JoinFaction,
Jump, Jump,
Kick, Kick,
@ -294,6 +293,7 @@ pub enum ServerChatCommand {
Region, Region,
ReloadChunks, ReloadChunks,
RemoveLights, RemoveLights,
Respawn,
RevokeBuild, RevokeBuild,
RevokeBuildAll, RevokeBuildAll,
Safezone, Safezone,
@ -487,7 +487,7 @@ impl ServerChatCommand {
"Display information about commands", "Display information about commands",
None, None,
), ),
ServerChatCommand::Home => cmd(vec![], "Return to the home town", Some(Moderator)), ServerChatCommand::Respawn => cmd(vec![], "Teleport to your waypoint", Some(Moderator)),
ServerChatCommand::JoinFaction => ChatCommandData::new( ServerChatCommand::JoinFaction => ChatCommandData::new(
vec![Any("faction", Optional)], vec![Any("faction", Optional)],
"Join/leave the specified faction", "Join/leave the specified faction",
@ -762,7 +762,7 @@ impl ServerChatCommand {
ServerChatCommand::GroupLeave => "group_leave", ServerChatCommand::GroupLeave => "group_leave",
ServerChatCommand::Health => "health", ServerChatCommand::Health => "health",
ServerChatCommand::Help => "help", ServerChatCommand::Help => "help",
ServerChatCommand::Home => "home", ServerChatCommand::Respawn => "respawn",
ServerChatCommand::JoinFaction => "join_faction", ServerChatCommand::JoinFaction => "join_faction",
ServerChatCommand::Jump => "jump", ServerChatCommand::Jump => "jump",
ServerChatCommand::Kick => "kick", ServerChatCommand::Kick => "kick",

View File

@ -13,7 +13,7 @@ use crate::{
weather::WeatherSim, weather::WeatherSim,
wiring, wiring,
wiring::OutputFormula, wiring::OutputFormula,
Server, Settings, SpawnPoint, StateExt, Server, Settings, StateExt,
}; };
use assets::AssetExt; use assets::AssetExt;
use authc::Uuid; use authc::Uuid;
@ -150,7 +150,7 @@ fn do_command(
ServerChatCommand::GroupPromote => handle_group_promote, ServerChatCommand::GroupPromote => handle_group_promote,
ServerChatCommand::Health => handle_health, ServerChatCommand::Health => handle_health,
ServerChatCommand::Help => handle_help, ServerChatCommand::Help => handle_help,
ServerChatCommand::Home => handle_home, ServerChatCommand::Respawn => handle_respawn,
ServerChatCommand::JoinFaction => handle_join_faction, ServerChatCommand::JoinFaction => handle_join_faction,
ServerChatCommand::Jump => handle_jump, ServerChatCommand::Jump => handle_jump,
ServerChatCommand::Kick => handle_kick, ServerChatCommand::Kick => handle_kick,
@ -874,25 +874,23 @@ fn handle_site(
Ok(()) Ok(())
} }
fn handle_home( fn handle_respawn(
server: &mut Server, server: &mut Server,
_client: EcsEntity, _client: EcsEntity,
target: EcsEntity, target: EcsEntity,
_args: Vec<String>, _args: Vec<String>,
_action: &ServerChatCommand, _action: &ServerChatCommand,
) -> CmdResult<()> { ) -> CmdResult<()> {
let home_pos = server.state.mut_resource::<SpawnPoint>().0; let waypoint = server
let time = *server.state.mut_resource::<Time>(); .state
.read_storage::<comp::Waypoint>()
.get(target)
.ok_or_else(|| format!("No waypoint set"))?
.get_pos();
position_mut(server, target, "target", |current_pos| { position_mut(server, target, "target", |current_pos| {
current_pos.0 = home_pos current_pos.0 = waypoint;
})?; })
insert_or_replace_component(
server,
target,
comp::Waypoint::temp_new(home_pos, time),
"target",
)
} }
fn handle_kill( fn handle_kill(