mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
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:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user