mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
feat: make commands available for console and for player offline
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "Transmogrification.h"
|
#include "Transmogrification.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
using namespace Acore::ChatCommands;
|
using namespace Acore::ChatCommands;
|
||||||
|
|
||||||
@@ -32,8 +33,8 @@ public:
|
|||||||
{
|
{
|
||||||
static ChatCommandTable addCollectionTable =
|
static ChatCommandTable addCollectionTable =
|
||||||
{
|
{
|
||||||
{ "set", HandleAddTransmogItemSet, SEC_MODERATOR, Console::No },
|
{"set", HandleAddTransmogItemSet, SEC_MODERATOR, Console::Yes},
|
||||||
{ "", HandleAddTransmogItem, SEC_MODERATOR, Console::No },
|
{"", HandleAddTransmogItem, SEC_MODERATOR, Console::Yes},
|
||||||
};
|
};
|
||||||
|
|
||||||
static ChatCommandTable transmogTable =
|
static ChatCommandTable transmogTable =
|
||||||
@@ -82,9 +83,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player)
|
if (!player)
|
||||||
|
{
|
||||||
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
||||||
if (!player || !player->IsConnected())
|
}
|
||||||
|
|
||||||
|
if (!player)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Player *target = player->GetConnectedPlayer();
|
Player *target = player->GetConnectedPlayer();
|
||||||
|
|
||||||
@@ -103,14 +109,30 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 itemId = itemTemplate->ItemId;
|
uint32 itemId = itemTemplate->ItemId;
|
||||||
uint32 accountId = target->GetSession()->GetAccountId();
|
uint32 accountId;
|
||||||
|
auto guid = player->GetGUID().GetCounter();
|
||||||
|
if (QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `guid` = {}", guid))
|
||||||
|
{
|
||||||
|
Field *fields = result->Fetch();
|
||||||
|
accountId = fields[0].Get<uint32>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream tempStream;
|
std::stringstream tempStream;
|
||||||
tempStream << std::hex << ItemQualityColors[itemTemplate->Quality];
|
tempStream << std::hex << ItemQualityColors[itemTemplate->Quality];
|
||||||
std::string itemQuality = tempStream.str();
|
std::string itemQuality = tempStream.str();
|
||||||
std::string itemName = itemTemplate->Name1;
|
std::string itemName = itemTemplate->Name1;
|
||||||
std::string nameLink = handler->playerLink(target->GetName());
|
|
||||||
|
bool isNotConsoleAndIsPlayerOnline = handler->GetSession() && target->GetSession();
|
||||||
|
|
||||||
if (sTransmogrification->AddCollectedAppearance(accountId, itemId))
|
if (sTransmogrification->AddCollectedAppearance(accountId, itemId))
|
||||||
{
|
{
|
||||||
|
if (isNotConsoleAndIsPlayerOnline)
|
||||||
|
{
|
||||||
|
std::string nameLink = handler->playerLink(target->GetName());
|
||||||
|
|
||||||
if (!(target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value))
|
if (!(target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value))
|
||||||
{
|
{
|
||||||
@@ -121,14 +143,19 @@ public:
|
|||||||
{
|
{
|
||||||
handler->PSendSysMessage(R"(|c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r has been added to the appearance collection of Player %s.)", itemQuality.c_str(), itemId, itemName.c_str(), nameLink);
|
handler->PSendSysMessage(R"(|c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r has been added to the appearance collection of Player %s.)", itemQuality.c_str(), itemId, itemName.c_str(), nameLink);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CharacterDatabase.Execute("INSERT INTO custom_unlocked_appearances (account_id, item_template_id) VALUES ({}, {})", accountId, itemId);
|
CharacterDatabase.Execute("INSERT INTO custom_unlocked_appearances (account_id, item_template_id) VALUES ({}, {})", accountId, itemId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (isNotConsoleAndIsPlayerOnline)
|
||||||
|
{
|
||||||
|
std::string nameLink = handler->playerLink(target->GetName());
|
||||||
handler->PSendSysMessage(R"(Player %s already has item |c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r in the appearance collection.)", nameLink, itemQuality.c_str(), itemId, itemName.c_str());
|
handler->PSendSysMessage(R"(Player %s already has item |c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r in the appearance collection.)", nameLink, itemQuality.c_str(), itemId, itemName.c_str());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -146,9 +173,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player)
|
if (!player)
|
||||||
|
{
|
||||||
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
||||||
if (!player || !player->IsConnected())
|
}
|
||||||
|
|
||||||
|
if (!player)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Player *target = player->GetConnectedPlayer();
|
Player *target = player->GetConnectedPlayer();
|
||||||
ItemSetEntry const *set = sItemSetStore.LookupEntry(uint32(itemSetId));
|
ItemSetEntry const *set = sItemSetStore.LookupEntry(uint32(itemSetId));
|
||||||
@@ -162,8 +194,20 @@ public:
|
|||||||
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
uint32 error = 0;
|
uint32 error = 0;
|
||||||
uint32 accountId = target->GetSession()->GetAccountId();
|
|
||||||
uint32 itemId;
|
uint32 itemId;
|
||||||
|
uint32 accountId;
|
||||||
|
|
||||||
|
auto guid = player->GetGUID().GetCounter();
|
||||||
|
if (QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `guid` = {}", guid))
|
||||||
|
{
|
||||||
|
Field *fields = result->Fetch();
|
||||||
|
accountId = fields[0].Get<uint32>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
|
for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
|
||||||
{
|
{
|
||||||
itemId = set->itemId[i];
|
itemId = set->itemId[i];
|
||||||
@@ -199,6 +243,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isNotConsoleAndIsPlayerOnline = handler->GetSession() && target->GetSession();
|
||||||
|
|
||||||
|
if (isNotConsoleAndIsPlayerOnline)
|
||||||
|
{
|
||||||
int locale = handler->GetSessionDbcLocale();
|
int locale = handler->GetSessionDbcLocale();
|
||||||
std::string setName = set->name[locale];
|
std::string setName = set->name[locale];
|
||||||
std::string nameLink = handler->playerLink(target->GetName());
|
std::string nameLink = handler->playerLink(target->GetName());
|
||||||
@@ -219,6 +267,7 @@ public:
|
|||||||
{
|
{
|
||||||
handler->PSendSysMessage("ItemSet |cffffffff|Hitemset:%d|h[%s %s]|h|r has been added to the appearance collection of Player %s.", uint32(itemSetId), setName.c_str(), localeNames[locale], nameLink);
|
handler->PSendSysMessage("ItemSet |cffffffff|Hitemset:%d|h[%s %s]|h|r has been added to the appearance collection of Player %s.", uint32(itemSetId), setName.c_str(), localeNames[locale], nameLink);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user