Add Delete Inventory Slash Command (#865)

* moving branch

* Add deleteinven slash command

* Change name of BRICKS_IN_BBB

* Use string_view instead of strcmp

* Remove GameConfig

* Revert "Remove GameConfig"

This reverts commit cef5cdeea2.
This commit is contained in:
David Markowitz
2022-12-18 07:46:04 -08:00
committed by GitHub
parent b972acbacc
commit 84c5d74450
26 changed files with 130 additions and 27 deletions

View File

@@ -1803,6 +1803,33 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
ChatPackets::SendSystemMessage(sysAddr, message);
}
if (chatCommand == "deleteinven" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
eInventoryType inventoryType = eInventoryType::INVALID;
if (!GeneralUtils::TryParse(args[0], inventoryType)) {
// In this case, we treat the input as a string and try to find it in the reflection list
std::transform(args[0].begin(), args[0].end(),args[0].begin(), ::toupper);
Game::logger->Log("SlashCommandHandler", "looking for inventory %s", args[0].c_str());
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
if (std::string_view(args[0]) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) inventoryType = static_cast<eInventoryType>(index);
}
}
if (inventoryType == eInventoryType::INVALID || inventoryType >= NUMBER_OF_INVENTORIES) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid inventory provided.");
return;
}
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
if (!inventoryComponent) return;
auto* inventoryToDelete = inventoryComponent->GetInventory(inventoryType);
if (!inventoryToDelete) return;
inventoryToDelete->DeleteAllItems();
Game::logger->Log("SlashCommandHandler", "Deleted inventory %s for user %llu", args[0].c_str(), entity->GetObjectID());
ChatPackets::SendSystemMessage(sysAddr, u"Deleted inventory " + GeneralUtils::UTF8ToUTF16(args[0]));
}
if (chatCommand == "inspect" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER && args.size() >= 1) {
Entity* closest = nullptr;