New Command: "kit" + Removed Command: "debug"

Update CHANGELOG.md

Update CHANGELOG.md
This commit is contained in:
Vincent Foulon 2021-04-12 18:49:08 +02:00
parent 9289feee23
commit 0692562533
5 changed files with 98 additions and 35 deletions

View File

@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Stun resilience stat display
- Villagers and guards now spawn with potions, and know how to use them.
- Combat music in dungeons when within range of enemies.
- New Command: "kit", place a set of items into your inventory
### Changed
@ -51,6 +52,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Removed command: "debug", use "/kit debug" instead
### Fixed
- Server kicks old client when a user is trying to log in again (often the case when a user's original connection gets dropped)

View File

@ -10,7 +10,7 @@ ItemDef(
),
)
),
quality: Artifact,
quality: Debug,
tags: [],
slots: 900,
)

View File

@ -0,0 +1,29 @@
({
"debug": [
"common.items.debug.admin_back",
"common.items.debug.admin_black_hole",
"common.items.debug.admin_stick",
"common.items.debug.admin_sword",
"common.items.debug.admin",
"common.items.debug.cultist_belt",
"common.items.debug.cultist_boots",
"common.items.debug.cultist_chest_blue",
"common.items.debug.cultist_hands_blue",
"common.items.debug.cultist_legs_blue",
"common.items.debug.cultist_shoulder_blue",
"common.items.debug.dungeon_purple",
],
"cultist": [
"common.items.armor.cultist.chest",
"common.items.armor.cultist.pants",
"common.items.armor.cultist.hand",
"common.items.armor.cultist.foot",
"common.items.armor.cultist.shoulder",
"common.items.armor.cultist.belt",
"common.items.weapons.hammer.cultist_purp_2h-0",
"common.items.weapons.staff.cultist_staff",
"common.items.weapons.sword.cultist",
"common.items.weapons.bow.velorite",
"common.items.weapons.axe.malachite_axe-0",
]
})

View File

@ -44,7 +44,6 @@ pub enum ChatCommand {
BuildAreaList,
BuildAreaRemove,
Campfire,
Debug,
DebugColumn,
DropAll,
Dummy,
@ -65,6 +64,7 @@ pub enum ChatCommand {
Kick,
Kill,
KillNpcs,
Kit,
Lantern,
Light,
MakeBlock,
@ -105,7 +105,6 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
ChatCommand::BuildAreaList,
ChatCommand::BuildAreaRemove,
ChatCommand::Campfire,
ChatCommand::Debug,
ChatCommand::DebugColumn,
ChatCommand::DropAll,
ChatCommand::Dummy,
@ -126,6 +125,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
ChatCommand::Kick,
ChatCommand::Kill,
ChatCommand::KillNpcs,
ChatCommand::Kit,
ChatCommand::Lantern,
ChatCommand::Light,
ChatCommand::MakeBlock,
@ -270,7 +270,6 @@ impl ChatCommand {
Admin,
),
ChatCommand::Campfire => cmd(vec![], "Spawns a campfire", Admin),
ChatCommand::Debug => cmd(vec![], "Place all debug items into your pack.", Admin),
ChatCommand::DebugColumn => cmd(
vec![Integer("x", 15000, Required), Integer("y", 15000, Required)],
"Prints some debug information about a column",
@ -358,6 +357,11 @@ impl ChatCommand {
),
ChatCommand::Kill => cmd(vec![], "Kill yourself", NoAdmin),
ChatCommand::KillNpcs => cmd(vec![], "Kill the NPCs", Admin),
ChatCommand::Kit => cmd(
vec![Any("kit_name", Required)],
"Place a set of items into your inventory.",
Admin,
),
ChatCommand::Lantern => cmd(
vec![
Float("strength", 5.0, Required),
@ -515,7 +519,6 @@ impl ChatCommand {
ChatCommand::BuildAreaList => "build_area_list",
ChatCommand::BuildAreaRemove => "build_area_remove",
ChatCommand::Campfire => "campfire",
ChatCommand::Debug => "debug",
ChatCommand::DebugColumn => "debug_column",
ChatCommand::DropAll => "dropall",
ChatCommand::Dummy => "dummy",
@ -535,6 +538,7 @@ impl ChatCommand {
ChatCommand::Jump => "jump",
ChatCommand::Kick => "kick",
ChatCommand::Kill => "kill",
ChatCommand::Kit => "kit",
ChatCommand::KillNpcs => "kill_npcs",
ChatCommand::Lantern => "lantern",
ChatCommand::Light => "light",

View File

@ -6,9 +6,11 @@ use crate::{
settings::{BanRecord, EditableSetting},
Server, SpawnPoint, StateExt,
};
use assets::AssetExt;
use authc::Uuid;
use chrono::{NaiveTime, Timelike};
use common::{
assets,
cmd::{ChatCommand, CHAT_COMMANDS, CHAT_SHORTCUTS},
comp::{
self,
@ -36,7 +38,10 @@ use common_sys::state::{BuildAreaError, BuildAreas};
use core::{convert::TryFrom, ops::Not, time::Duration};
use hashbrown::HashSet;
use rand::Rng;
use serde::{Deserialize, Serialize};
use specs::{Builder, Entity as EcsEntity, Join, WorldExt};
use std::collections::HashMap;
use vek::*;
use world::util::Sampler;
@ -98,7 +103,6 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
ChatCommand::BuildAreaList => handle_build_area_list,
ChatCommand::BuildAreaRemove => handle_build_area_remove,
ChatCommand::Campfire => handle_spawn_campfire,
ChatCommand::Debug => handle_debug,
ChatCommand::DebugColumn => handle_debug_column,
ChatCommand::DropAll => handle_drop_all,
ChatCommand::Dummy => handle_spawn_training_dummy,
@ -119,6 +123,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
ChatCommand::Kick => handle_kick,
ChatCommand::Kill => handle_kill,
ChatCommand::KillNpcs => handle_kill_npcs,
ChatCommand::Kit => handle_kit,
ChatCommand::Lantern => handle_lantern,
ChatCommand::Light => handle_light,
ChatCommand::MakeBlock => handle_make_block,
@ -1397,9 +1402,60 @@ fn handle_kill_npcs(
client,
ServerGeneral::server_msg(ChatType::CommandInfo, text),
);
Ok(())
}
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
struct KitManifest(HashMap<String, Vec<String>>);
impl assets::Asset for KitManifest {
type Loader = assets::RonLoader;
const EXTENSION: &'static str = "ron";
}
fn handle_kit(
server: &mut Server,
_client: EcsEntity,
target: EcsEntity,
args: String,
action: &ChatCommand,
) -> CmdResult<()> {
let kit_name = scan_fmt!(&args, &action.arg_fmt(), String);
if let Ok(name) = kit_name {
if let Ok(kits) = KitManifest::load("server.manifests.kits") {
let kits = kits.read();
if let Some(kit) = kits.0.get(&name) {
for item_id in kit.iter() {
if let Ok(item) = comp::Item::new_from_asset(item_id) {
server
.state()
.ecs()
.write_storage::<comp::Inventory>()
.get_mut(target)
.map(|mut inv| inv.push(item));
let _ = server
.state
.ecs()
.write_storage::<comp::InventoryUpdate>()
.insert(
target,
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Debug),
);
}
}
Ok(())
} else {
Err(format!("Kit '{}' not found", name))
}
} else {
Err("Could not load manifest file 'server.manifests.kits'".to_string())
}
} else {
Err(action.help_string())
}
}
#[allow(clippy::float_cmp)] // TODO: Pending review in #587
#[allow(clippy::needless_return)] // TODO: Pending review in #587
#[allow(clippy::useless_format)] // TODO: Pending review in #587
@ -2112,35 +2168,6 @@ fn parse_skill_tree(skill_tree: &str) -> CmdResult<comp::skills::SkillGroupKind>
}
}
fn handle_debug(
server: &mut Server,
_client: EcsEntity,
target: EcsEntity,
_args: String,
_action: &ChatCommand,
) -> CmdResult<()> {
if let Ok(items) = comp::Item::new_from_asset_glob("common.items.debug.*") {
server
.state()
.ecs()
.write_storage::<comp::Inventory>()
.get_mut(target)
.ok_or("Cannot get inventory for target")?
.push_all_unique(items.into_iter())
// Deliberately swallow the error if not enough debug items could be added--though it
// might be nice to let the admin know, it's better than dropping them on the ground.
.ok();
insert_or_replace_component(
server,
target,
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Debug),
"target",
)
} else {
Err("Debug items not found? Something is very broken.".into())
}
}
fn handle_remove_lights(
server: &mut Server,
client: EcsEntity,